hackedteam/vector-edk

View on GitHub
AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.py

Summary

Maintainability
F
2 mos
Test Coverage

File mhlib.py has 854 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""MH interface -- purely object-oriented (well, almost)

Executive summary:

import mhlib
Severity: Major
Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.py - About 2 days to fix

    Function parsesequence has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
    Open

        def parsesequence(self, seq):
            """Parse an MH sequence specification into a message list.
            Attempt to mimic mh-sequence(5) as close as possible.
            Also attempt to mimic observed behavior regarding which
            conditions cause which error messages."""
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.py - About 7 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

    Folder has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Folder:
        """Class representing a particular folder."""
    
        def __init__(self, mh, name):
            """Constructor."""
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.py - About 2 hrs to fix

      Function refilemessages has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def refilemessages(self, list, tofolder, keepsequences=0):
              """Refile one or more messages -- may raise os.error.
              'tofolder' is an open folder object."""
              errors = []
              refiled = {}
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.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 append has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def append(self, x):
              for i in range(len(self.pairs)):
                  lo, hi = self.pairs[i]
                  if x < lo: # Need to insert before
                      if x+1 == lo:
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.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 updateline has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      def updateline(file, key, value, casefold = 1):
          try:
              f = open(file, 'r')
              lines = f.readlines()
              f.close()
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.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 _parseindex has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def _parseindex(self, seq, all):
              """Internal: parse a message number (or cur, first, etc.)."""
              if isnumeric(seq):
                  try:
                      return int(seq)
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.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 pickline has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      def pickline(file, key, casefold = 1):
          try:
              f = open(file, 'r')
          except IOError:
              return None
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.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 removefromallsequences has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def removefromallsequences(self, list):
              """Remove one or more messages from all sequences (including last)
              -- but not from 'cur'!!!"""
              if hasattr(self, 'last') and self.last in list:
                  del self.last
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.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 listallsubfolders has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def listallsubfolders(self, name):
              """Return the names of subfolders in a given folder, recursively."""
              fullname = os.path.join(self.path, name)
              # Get the link count so we can avoid listing folders
              # that have no subfolders.
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.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 removemessages has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def removemessages(self, list):
              """Remove one or more messages -- may raise os.error."""
              errors = []
              deleted = []
              for n in list:
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.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 _copysequences has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def _copysequences(self, fromfolder, refileditems):
              """Helper for refilemessages() to copy sequences."""
              fromsequences = fromfolder.getsequences()
              tosequences = self.getsequences()
              changed = 0
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.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 getheadertext has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def getheadertext(self, pred = None):
              """Return the message's header text as a string.  If an
              argument is specified, it is used as a filter predicate to
              decide which headers to return (its argument is the header
              name converted to lower case)."""
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.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 putsequences has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def putsequences(self, sequences):
              """Write the set of sequences back to the folder."""
              fullname = self.getsequencesfilename()
              f = None
              for key, seq in sequences.iteritems():
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.py - About 35 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 createmessage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def createmessage(self, n, txt):
              """Create a message, with text from the open file txt."""
              path = self.getmessagefilename(n)
              backuppath = self.getmessagefilename(',%d' % n)
              try:
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.py - About 35 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 tostring has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def tostring(self):
              s = ''
              for lo, hi in self.pairs:
                  if lo == hi: t = repr(lo)
                  else: t = repr(lo) + self.rng + repr(hi)
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.py - About 35 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 movemessage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def movemessage(self, n, tofolder, ton):
              """Move one message over a specific destination message,
              which may or may not already exist."""
              path = self.getmessagefilename(n)
              # Open it to check that it exists
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.py - About 35 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 listsubfolders has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def listsubfolders(self, name):
              """Return the names of the subfolders in a given folder
              (prefixed with the given folder name)."""
              fullname = os.path.join(self.path, name)
              # Get the link count so we can avoid listing folders
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.py - About 35 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 fromstring has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def fromstring(self, data):
              new = []
              for part in data.split(self.sep):
                  list = []
                  for subp in part.split(self.rng):
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.py - About 35 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

      Avoid too many return statements within this function.
      Open

                      return all[i-1]
      Severity: Major
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                        return [n]
        Severity: Major
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return all[-1]
          Severity: Major
          Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                                return all[i:i+count]
            Severity: Major
            Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return seqs[seq]
              Severity: Major
              Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return r
                Severity: Major
                Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                  return all[i]
                  Severity: Major
                  Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.py - About 30 mins to fix

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

                        def getsequences(self):
                            """Return the set of sequences for the folder."""
                            sequences = {}
                            fullname = self.getsequencesfilename()
                            try:
                    Severity: Minor
                    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.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

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

                        def __init__(self, path = None, profile = None):
                            """Constructor."""
                            if profile is None: profile = MH_PROFILE
                            self.profile = os.path.expanduser(profile)
                            if path is None: path = self.getprofile('Path')
                    Severity: Minor
                    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.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 AppPkg/Applications/Python/Python-2.7.2/Lib/mhlib.py and 1 other location - About 2 mos to fix
                    vector-uefi/fd/efi/StdLib/lib/python.27/mhlib.py on lines 0..1005

                    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 6701.

                    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