SpamExperts/se-mailbox

View on GitHub
se_mailbox/se_mailbox.py

Summary

Maintainability
C
1 day
Test Coverage

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

        There are no issues that match your filters.

        Category
        Status