ActivityWatch/aw-client

View on GitHub

Showing 13 of 13 total issues

File client.py has 344 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json
import logging
import socket
import os
import threading
Severity: Minor
Found in aw_client/client.py - About 4 hrs to fix

    ActivityWatchClient has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ActivityWatchClient:
        def __init__(
            self,
            client_name: str = "unknown",
            testing=False,
    Severity: Minor
    Found in aw_client/client.py - About 2 hrs to fix

      Function _check_event has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      def _check_event(e: Event, pattern: Union[str, Pattern]) -> bool:
          for k, v in e.data.items():
              if isinstance(v, str):
                  if isinstance(pattern, str):
                      if pattern in v.lower():
      Severity: Minor
      Found in examples/redact_sensitive.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 _redact_event has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      def _redact_event(e: Event, pattern: Union[str, Pattern]) -> Event:
          e = deepcopy(e)
          for k, v in e.data.items():
              if isinstance(v, str):
                  if isinstance(pattern, str):
      Severity: Minor
      Found in examples/redact_sensitive.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 main has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def main():
          global DRYRUN
          if "--wet" in sys.argv:
              DRYRUN = False
      
      
      Severity: Minor
      Found in examples/redact_sensitive.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 _redact_bucket has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def _redact_bucket(bucket_id: str, pattern: Union[str, Pattern]):
          print("\nChecking bucket: {}".format(bucket_id))
      
          events = aw.get_events(bucket_id, limit=-1)
          sensitive_ids = _find_sensitive(events, pattern)
      Severity: Minor
      Found in examples/redact_sensitive.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 a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self, client_name):
              self.lockfile = os.path.join(get_cache_dir("client_locks"), client_name)
              logger.debug("SingleInstance lockfile: " + self.lockfile)
              if sys.platform == "win32":
                  try:
      Severity: Minor
      Found in aw_client/singleinstance.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 heartbeat has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def heartbeat(
              self,
              bucket_id: str,
              event: Event,
              pulsetime: float,
      Severity: Minor
      Found in aw_client/client.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 run has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def run(self) -> None:
              self._stop_event.clear()
              while not self.should_stop():
                  # Connect
                  while not self._try_connect():
      Severity: Minor
      Found in aw_client/client.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 query has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def query(
      Severity: Major
      Found in aw_client/cli.py - About 50 mins to fix

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

            def __init__(
        Severity: Minor
        Found in aw_client/client.py - About 35 mins to fix

          Function heartbeat has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def heartbeat(
          Severity: Minor
          Found in aw_client/client.py - About 35 mins to fix

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

            def query(
                obj: _Context,
                path: str,
                cache: bool,
                _json: bool,
            Severity: Minor
            Found in aw_client/cli.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

            Severity
            Category
            Status
            Source
            Language