SpamExperts/se-mailbox

View on GitHub

Showing 11 of 13 total issues

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

    def __init__(self, dirname, factory=None, create=True, access=0o700,
                 uid=None, gid=None):
        """Like the parent but allows specification of permission, uid, and
        gid if creating."""
        # pylint: disable=W0233, W0231
Severity: Minor
Found in se_mailbox/se_mailbox.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

Function remove_folder has a Cognitive Complexity of 16 (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 scandir.scandir(os.path.join(path, 'new')):
            if len(entry.name) < 1 or entry.name[0] != '.':
Severity: Minor
Found in se_mailbox/smaildir.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 _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 se_mailbox/smaildir.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 acquire has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def acquire(self):
        """Acquire the lock, if possible. If the lock is in use, it check
        again every `wait` seconds. It does this until it either gets the
        lock or exceeds `timeout` number of seconds, in which case it throws
        an exception."""
Severity: Minor
Found in se_mailbox/filelock.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 size has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def size(self):
        """Get the size of the folder (bytes, number of messages)."""
        if not os.path.exists(self.size_fn):
            return self.recalculate()
        size_stat = os.stat(self.size_fn)
Severity: Minor
Found in se_mailbox/se_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 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, dirname, factory=None, create=True, access=0o700,
Severity: Minor
Found in se_mailbox/se_mailbox.py - About 45 mins to fix

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

        def get_quota(self):
            """Load the size_quota and count_quota for this folder."""
            self.size_quota = None
            self.count_quota = None
            if not os.path.exists(self.size_fn):
    Severity: Minor
    Found in se_mailbox/se_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

    Avoid deeply nested control flow statements.
    Open

                                if e.errno != 17:
                                    raise
                        os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXG |
    Severity: Major
    Found in se_mailbox/se_mailbox.py - About 45 mins to fix

      Consider simplifying this complex logical expression.
      Open

              if (((self.count_quota and total_count > self.count_quota) or
                   (self.size_quota and total_size > self.size_quota)) and
                      (i == 0 or (time.time() - size_stat.st_mtime) > 15 * 60)):
                  return self.recalculate()
              return total_size, total_count
      Severity: Major
      Found in se_mailbox/se_mailbox.py - About 40 mins to fix

        Function release has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def release(self):
                """Get rid of the lock by deleting the lockfile.
                When working in a `with` statement, this gets automatically called
                at the end."""
                if hasattr(self, "is_locked") and self.is_locked:
        Severity: Minor
        Found in se_mailbox/filelock.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 recalculate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def recalculate(self):
                """Recalculate the space used by this folder, and store in the
                maildirsize cache."""
                # We are meant to look for a "maildirfolder" file in the current
                # directory, and if there is one, then this is a subfolder and we
        Severity: Minor
        Found in se_mailbox/se_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

        Severity
        Category
        Status
        Source
        Language