ActivityWatch/aw-qt

View on GitHub

Showing 11 of 11 total issues

Function _interactive_cli has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

def _interactive_cli(manager: Manager) -> None:
    while True:
        answer = input("> ")
        if answer == "q":
            break
Severity: Minor
Found in aw_qt/main.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 main has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def main(
    testing: bool,
    verbose: bool,
    autostart_modules: Optional[str],
    no_gui: bool,
Severity: Minor
Found in aw_qt/main.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 _discover_modules_system has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def _discover_modules_system() -> List["Module"]:
    """Find all aw- modules in PATH"""
    search_paths = os.get_exec_path()

    # Needed because PyInstaller adds the executable dir to the PATH
Severity: Minor
Found in aw_qt/manager.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 _build_rootmenu has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def _build_rootmenu(self) -> None:
        menu = QMenu(self._parent)

        if self.testing:
            menu.addAction("Running in testing mode")  # .setEnabled(False)
Severity: Minor
Found in aw_qt/trayicon.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 stop has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def stop(self) -> None:
        """
        Stops a module, and waits until it terminates.
        """
        # TODO: What if a module doesn't stop? Add timeout to p.wait() and then do a p.kill() if timeout is hit
Severity: Minor
Found in aw_qt/manager.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 main has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def main(
Severity: Minor
Found in aw_qt/main.py - About 35 mins to fix

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

    def is_executable(path: str, filename: str) -> bool:
        if not os.path.isfile(path):
            return False
        # On windows all files ending with .exe are executables
        if platform.system() == "Windows":
    Severity: Minor
    Found in aw_qt/manager.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 _discover_modules_in_directory has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def _discover_modules_in_directory(path: str) -> List["Module"]:
        """Look for modules in given directory path and recursively in subdirs matching aw-*"""
        modules = []
        matches = glob(os.path.join(path, "aw-*"))
        for path in matches:
    Severity: Minor
    Found in aw_qt/manager.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 print_status has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def print_status(self, module_name: Optional[str] = None) -> None:
            header = "name                status      type"
            if module_name:
                # find module
                module = next((m for m in self.modules if m.name == module_name), None)
    Severity: Minor
    Found in aw_qt/manager.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

    Avoid too many return statements within this function.
    Open

            return True
    Severity: Major
    Found in aw_qt/manager.py - About 30 mins to fix

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

          def autostart(self, autostart_modules: List[str]) -> None:
              # NOTE: Currently impossible to autostart a system module if a bundled module with the same name exists
      
              # We only want to autostart modules that are both in found modules and are asked to autostart.
              for name in autostart_modules:
      Severity: Minor
      Found in aw_qt/manager.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