hackedteam/vector-edk

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

Summary

Maintainability
F
6 mos
Test Coverage

File mailbox.py has 1842 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#! /usr/bin/env python

"""Read/write support for Maildir, mbox, MH, Babyl, and MMDF mailboxes."""

# Notes for authors of new mailbox subclasses:
Severity: Major
Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.py - About 5 days to fix

    Function _install_message has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
    Open

        def _install_message(self, message):
            """Write message contents and return (start, stop)."""
            start = self._file.tell()
            if isinstance(message, BabylMessage):
                special_labels = []
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 _explain_to has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        def _explain_to(self, message):
            """Copy Maildir-specific state to message insofar as possible."""
            if isinstance(message, MaildirMessage):
                message.set_flags(self.get_flags())
                message.set_subdir(self.get_subdir())
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 _explain_to has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        def _explain_to(self, message):
            """Copy mbox- or MMDF-specific state to message insofar as possible."""
            if isinstance(message, MaildirMessage):
                flags = set(self.get_flags())
                if 'O' in flags:
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 _lock_file has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

    def _lock_file(f, dotlock=True):
        """Lock file f using lockf and dot locking."""
        dotlock_done = False
        try:
            if fcntl:
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 _explain_to has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

        def _explain_to(self, message):
            """Copy Babyl-specific state to message insofar as possible."""
            if isinstance(message, MaildirMessage):
                labels = set(self.get_labels())
                if 'unseen' in labels:
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 _explain_to has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        def _explain_to(self, message):
            """Copy MH-specific state to message insofar as possible."""
            if isinstance(message, MaildirMessage):
                sequences = set(self.get_sequences())
                if 'unseen' in sequences:
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.py - About 3 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

    Mailbox has 30 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Mailbox:
        """A group of messages in a particular place."""
    
        def __init__(self, path, factory=None, create=True):
            """Initialize a Mailbox instance."""
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.py - About 3 hrs to fix

      Maildir has 24 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Maildir(Mailbox):
          """A qmail-style Maildir mailbox."""
      
          colon = ':'
      
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.py - About 2 hrs to fix

        MH has 22 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class MH(Mailbox):
            """An MH mailbox."""
        
            def __init__(self, path, factory=None, create=True):
                """Initialize an MH instance."""
        Severity: Minor
        Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.py - About 2 hrs to fix

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

              def set_sequences(self, sequences):
                  """Set sequences using the given name-to-key-list dictionary."""
                  f = open(os.path.join(self._path, '.mh_sequences'), 'r+')
                  try:
                      os.close(os.open(f.name, os.O_WRONLY | os.O_TRUNC))
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 flush has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def flush(self):
                  """Write any pending changes to disk."""
                  if not self._pending:
                      return
          
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 _dump_message has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def _dump_message(self, message, target, mangle_from_=False):
                  # Most files are opened in binary mode to allow predictable seeking.
                  # To get native line endings on disk, the user-friendly \n line endings
                  # used in strings and by email.Message are translated here.
                  """Dump message contents to target file."""
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 _refresh has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def _refresh(self):
                  """Update table of contents mapping."""
                  # If it has been less than two seconds since the last _refresh() call,
                  # we have to unconditionally re-read the mailbox just in case it has
                  # been modified, because os.path.mtime() has a 2 sec resolution in the
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 pack has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def pack(self):
                  """Re-name messages to eliminate numbering gaps. Invalidates keys."""
                  sequences = self.get_sequences()
                  prev = 0
                  changes = []
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 _create_tmp has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              def _create_tmp(self):
                  """Create a file in the tmp subdirectory and open and return it."""
                  now = time.time()
                  hostname = socket.gethostname()
                  if '/' in hostname:
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 remove_folder has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              def remove_folder(self, folder):
                  """Delete the named folder, which must be empty."""
                  path = os.path.join(self._path, '.' + folder)
                  for entry in os.listdir(os.path.join(path, 'new')) + \
                               os.listdir(os.path.join(path, 'cur')):
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 _generate_toc has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def _generate_toc(self):
                  """Generate key-to-(start, stop) table of contents."""
                  starts, stops = [], []
                  self._file.seek(0)
                  next_pos = 0
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 add has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def add(self, message):
                  """Add message and return assigned key."""
                  tmp_file = self._create_tmp()
                  try:
                      self._dump_message(message, tmp_file)
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 _generate_toc has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def _generate_toc(self):
                  """Generate key-to-(start, stop) table of contents."""
                  starts, stops = [], []
                  self._file.seek(0)
                  next_pos = 0
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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_message has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_message(self, key):
                  """Return a Message representation or raise a KeyError."""
                  try:
                      if self._locked:
                          f = open(os.path.join(self._path, str(key)), 'r+')
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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_sequences has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_sequences(self):
                  """Return a name-to-key-list dictionary to define each sequence."""
                  results = {}
                  f = open(os.path.join(self._path, '.mh_sequences'), 'r')
                  try:
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 add has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def add(self, message):
                  """Add message and return assigned key."""
                  keys = self.keys()
                  if len(keys) == 0:
                      new_key = 1
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 __init__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(self, path, factory=None, create=True):
                  """Initialize a single-file mailbox."""
                  Mailbox.__init__(self, path, factory, create)
                  try:
                      f = open(self._path, 'rb+')
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 get_message has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_message(self, key):
                  """Return a Message representation or raise a KeyError."""
                  start, stop = self._lookup(key)
                  self._file.seek(start)
                  self._file.readline()   # Skip '1,' line specifying labels.
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(self, dirname, factory=rfc822.Message, create=True):
                  """Initialize a Maildir instance."""
                  Mailbox.__init__(self, dirname, factory, create)
                  self._paths = {
                      'tmp': os.path.join(self._path, 'tmp'),
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 update_visible has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def update_visible(self):
                  """Update and/or sensibly generate a set of visible headers."""
                  for header in self._visible.keys():
                      if header in self:
                          self._visible.replace_header(header, self[header])
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 set_flags has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def set_flags(self, flags):
                  """Set the given flags and unset all others."""
                  flags = set(flags)
                  status_flags, xstatus_flags = '', ''
                  for flag in ('R', 'O'):
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 get_string has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_string(self, key):
                  """Return a string representation or raise a KeyError."""
                  try:
                      if self._locked:
                          f = open(os.path.join(self._path, str(key)), 'r+')
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 _dump_sequences has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def _dump_sequences(self, message, key):
                  """Inspect a new MHMessage and update sequences appropriately."""
                  pending_sequences = message.get_sequences()
                  all_sequences = self.get_sequences()
                  for name, key_list in all_sequences.iteritems():
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def update(self, arg=None):
                  """Change the messages that correspond to certain keys."""
                  if hasattr(arg, 'iteritems'):
                      source = arg.iteritems()
                  elif hasattr(arg, 'items'):
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 _generate_toc has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def _generate_toc(self):
                  """Generate key-to-(start, stop) table of contents."""
                  starts, stops = [], []
                  self._file.seek(0)
                  while True:
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(self, message=None):
                  """Initialize a Message instance."""
                  if isinstance(message, email.message.Message):
                      self._become_message(copy.deepcopy(message))
                      if isinstance(message, Message):
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 _install_message has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def _install_message(self, message):
                  """Format a message and blindly write to self._file."""
                  from_line = None
                  if isinstance(message, str) and message.startswith('From '):
                      newline = message.find('\n')
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 __setitem__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def __setitem__(self, key, message):
                  """Replace the keyed message; raise KeyError if it doesn't exist."""
                  path = os.path.join(self._path, str(key))
                  try:
                      f = open(path, 'rb+')
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 next has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def next(self):
                  """Return the next message in a one-time iteration."""
                  if not hasattr(self, '_onetime_keys'):
                      self._onetime_keys = self.iterkeys()
                  while True:
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 get_string has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_string(self, key):
                  """Return a string representation or raise a KeyError."""
                  start, stop = self._lookup(key)
                  self._file.seek(start)
                  self._file.readline()   # Skip '1,' line specifying labels.
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 _search_end has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def _search_end(self):
                  while 1:
                      pos = self.fp.tell()
                      line = self.fp.readline()
                      if not line:
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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 readlines has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def readlines(self, sizehint=None):
                  """Read multiple lines."""
                  result = []
                  for line in self:
                      result.append(line)
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/mailbox.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/mailbox.py and 1 other location - About 5 mos to fix
          AppPkg/Applications/Python/Python-2.7.2/Lib/mailbox.py on lines 0..2171

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

          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