hackedteam/vector-edk

View on GitHub
vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py

Summary

Maintainability
F
3 mos
Test Coverage

File difflib.py has 1469 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#! /usr/bin/env python

"""
Module difflib -- helpers for computing deltas between objects.
Severity: Major
Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 3 days to fix

    Function _mdiff has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring.
    Open

    def _mdiff(fromlines, tolines, context=None, linejunk=None,
               charjunk=IS_CHARACTER_JUNK):
        r"""Returns generator yielding marked up from/to side by side differences.
    
        Arguments:
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 1 day to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function context_diff has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

    def context_diff(a, b, fromfile='', tofile='',
                     fromfiledate='', tofiledate='', n=3, lineterm='\n'):
        r"""
        Compare two sequences of lines; generate the delta as a context diff.
    
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 5 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function _fancy_replace has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

        def _fancy_replace(self, a, alo, ahi, b, blo, bhi):
            r"""
            When replacing one block of lines with another, search the blocks
            for *similar* lines; the best-matching pair (if any) is used as a
            synch point, and intraline difference marking is done on the
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 5 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function unified_diff has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

    def unified_diff(a, b, fromfile='', tofile='', fromfiledate='',
                     tofiledate='', n=3, lineterm='\n'):
        r"""
        Compare two sequences of lines; generate the delta as a unified diff.
    
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 4 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function get_matching_blocks has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_matching_blocks(self):
            """Return list of triples describing matching subsequences.
    
            Each triple is of the form (i, j, n), and means that
            a[i:i+n] == b[j:j+n].  The triples are monotonically increasing in
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function find_longest_match has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_longest_match(self, alo, ahi, blo, bhi):
            """Find longest matching block in a[alo:ahi] and b[blo:bhi].
    
            If isjunk is not defined:
    
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function _line_wrapper has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def _line_wrapper(self,diffs):
            """Returns iterator that splits (wraps) mdiff text lines"""
    
            # pull from/to data and flags from mdiff iterator
            for fromdata,todata,flag in diffs:
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function __chain_b has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def __chain_b(self):
            # Because isjunk is a user-defined (not C) function, and we test
            # for junk a LOT, it's important to minimize the number of calls.
            # Before the tricks described here, __chain_b was by far the most
            # time-consuming routine in the whole module!  If anyone sees
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function make_table has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def make_table(self,fromlines,tolines,fromdesc='',todesc='',context=False,
                       numlines=5):
            """Returns HTML table of side by side comparison with change highlights
    
            Arguments:
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function _convert_flags has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def _convert_flags(self,fromlist,tolist,flaglist,context,numlines):
            """Makes list of "next" links"""
    
            # all anchor names will be generated using the unique "to" prefix
            toprefix = self._prefix[1]
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function _split_line has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def _split_line(self,data_list,line_num,text):
            """Builds list of text lines by splitting text lines at wrap point
    
            This function will determine if the input text line needs to be
            wrapped (split) into separate lines.  If so, the first wrap point
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function get_opcodes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_opcodes(self):
            """Return list of 5-tuples describing how to turn a into b.
    
            Each tuple is of the form (tag, i1, i2, j1, j2).  The first tuple
            has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function unified_diff has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def unified_diff(a, b, fromfile='', tofile='', fromfiledate='',
    Severity: Major
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 1 hr to fix

      Function context_diff has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def context_diff(a, b, fromfile='', tofile='',
      Severity: Major
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 1 hr to fix

        Function compare has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def compare(self, a, b):
                r"""
                Compare two sequences of lines; generate the resulting delta.
        
                Each sequence must contain individual single-line strings ending with
        Severity: Minor
        Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 55 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function quick_ratio has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def quick_ratio(self):
                """Return an upper bound on ratio() relatively quickly.
        
                This isn't defined beyond that it is an upper bound on .ratio(), and
                is faster to compute.
        Severity: Minor
        Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 55 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function _fancy_helper has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def _fancy_helper(self, a, alo, ahi, b, blo, bhi):
        Severity: Minor
        Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              for line in a[i1:i2]:
                                  yield prefix[tag] + line
          
          Severity: Major
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 45 mins to fix

            Function make_table has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def make_table(self,fromlines,tolines,fromdesc='',todesc='',context=False,
            Severity: Minor
            Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 45 mins to fix

              Function get_grouped_opcodes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_grouped_opcodes(self, n=3):
                      """ Isolate change clusters by eliminating ranges with no changes.
              
                      Return a generator of groups with upto n lines of context.
                      Each group is in the same format as returned by get_opcodes().
              Severity: Minor
              Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 45 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function _plain_replace has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def _plain_replace(self, a, alo, ahi, b, blo, bhi):
              Severity: Minor
              Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 45 mins to fix

                Function make_file has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def make_file(self,fromlines,tolines,fromdesc='',todesc='',context=False,
                Severity: Minor
                Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 45 mins to fix

                  Function _fancy_replace has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def _fancy_replace(self, a, alo, ahi, b, blo, bhi):
                  Severity: Minor
                  Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        for line in b[j1:j2]:
                                            yield prefix[tag] + line
                    
                    Severity: Major
                    Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 45 mins to fix

                      Function _mdiff has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      def _mdiff(fromlines, tolines, context=None, linejunk=None,
                      Severity: Minor
                      Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 35 mins to fix

                        Function _convert_flags has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def _convert_flags(self,fromlist,tolist,flaglist,context,numlines):
                        Severity: Minor
                        Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 35 mins to fix

                          Function _fancy_helper has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def _fancy_helper(self, a, alo, ahi, b, blo, bhi):
                                  g = []
                                  if alo < ahi:
                                      if blo < bhi:
                                          g = self._fancy_replace(a, alo, ahi, b, blo, bhi)
                          Severity: Minor
                          Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py - About 25 mins to fix

                          Cognitive Complexity

                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                          A method's cognitive complexity is based on a few simple rules:

                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                          • Code is considered more complex for each "break in the linear flow of the code"
                          • Code is considered more complex when "flow breaking structures are nested"

                          Further reading

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                          Severity: Major
                          Found in vector-uefi/fd/efi/StdLib/lib/python.27/difflib.py and 1 other location - About 2 mos to fix
                          AppPkg/Applications/Python/Python-2.7.2/Lib/difflib.py on lines 0..2059

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 7920.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          There are no issues that match your filters.

                          Category
                          Status