Showing 12 of 12 total issues
File api.py
has 309 lines of code (exceeds 250 allowed). Consider refactoring. Open
import functools
import json
import logging
from datetime import datetime
from pathlib import Path
File rest.py
has 308 lines of code (exceeds 250 allowed). Consider refactoring. Open
import json
import traceback
from functools import wraps
from threading import Lock
from typing import Dict
ServerAPI
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class ServerAPI:
def __init__(self, db, testing) -> None:
self.db = db
self.settings = Settings(testing)
self.testing = testing
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.
- Read upRead up
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 parse_settings
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_settings():
import argparse
""" CLI Arguments """
parser = argparse.ArgumentParser(description="Starts an ActivityWatch server")
Function parse_settings
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def parse_settings():
import argparse
""" CLI Arguments """
parser = argparse.ArgumentParser(description="Starts an ActivityWatch server")
- Read upRead up
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 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function _start
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _start(
Function create_bucket
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_bucket(
Function update_bucket
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def update_bucket(
Function host_header_check
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def host_header_check(f):
"""
Protects against DNS rebinding attacks (see https://github.com/ActivityWatch/activitywatch/security/advisories/GHSA-v9fg-6g9j-h4x4)
Some discussion in Syncthing how they do it: https://github.com/syncthing/syncthing/issues/4819
- Read upRead up
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_tag_exact
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_tag_exact():
rev = get_rev()
p = subprocess.run(
["git", "describe", "--tags", "--abbrev=0", "--exact-match", rev],
capture_output=True,
- Read upRead up
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"