async-worker/aiologger

View on GitHub
aiologger/handlers/files.py

Summary

Maintainability
D
1 day
Test Coverage
A
92%

Function compute_rollover has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

    def compute_rollover(self, current_time: int) -> int:
        """
        Work out the rollover time based on the specified time.

        If we are rolling over at midnight or weekly, then the interval is
Severity: Minor
Found in aiologger/handlers/files.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

File files.py has 390 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# The following code and documentation was inspired, and in some cases
# copied and modified, from the work of Vinay Sajip and contributors
# on cpython's logging package

import abc
Severity: Minor
Found in aiologger/handlers/files.py - About 5 hrs to fix

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

        def __init__(
            self,
            filename: str,
            when: RolloverInterval = RolloverInterval.HOURS,
            interval: int = 1,
    Severity: Minor
    Found in aiologger/handlers/files.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 __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Major
    Found in aiologger/handlers/files.py - About 1 hr to fix

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

          def __init__(
      Severity: Minor
      Found in aiologger/handlers/files.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if dst_now != dst_at_rollover:
                                    if not dst_now:
                                        # DST kicks in before next rollover, so we need to deduct an hour
                                        new_rollover_at -= ONE_HOUR_IN_SECONDS
                                    else:
        Severity: Major
        Found in aiologger/handlers/files.py - About 45 mins to fix

          There are no issues that match your filters.

          Category
          Status