ActivityWatch/aw-server

View on GitHub

Showing 3 of 3 total issues

Function heartbeat has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def heartbeat(self, bucket_id: str, heartbeat: Event, pulsetime: float) -> Event:
        """
        Heartbeats are useful when implementing watchers that simply keep
        track of a state, how long it's in that state and when it changes.
        A single heartbeat always has a duration of zero.
Severity: Minor
Found in aw_server/api.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 _start has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def _start(storage_method, host: str, port: int, testing: bool=False, cors_origins: List[str] = []):
Severity: Minor
Found in aw_server/server.py - About 35 mins to fix

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

    def detect_version_ci() -> Optional[str]:
        for env_var in ["TRAVIS_TAG", "APPVEYOR_REPO_TAG_NAME"]:
            if env_var in os.environ:
                return os.environ[env_var]
        for env_var in ["TRAVIS_COMMIT", "APPVEYOR_REPO_COMMIT"]:
    Severity: Minor
    Found in aw_server/__about__.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

    Severity
    Category
    Status
    Source
    Language