ActivityWatch/aw-core

View on GitHub

Showing 45 of 45 total issues

Function get_events has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def get_events(
        self,
        bucket_id: str,
        limit: int,
        starttime: Optional[datetime] = None,
Severity: Minor
Found in aw_datastore/storages/mongodb.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 setup_logging has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def setup_logging(
    name: str,
    testing=False,
    verbose=False,
    log_stderr=True,
Severity: Minor
Found in aw_core/log.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 chunk_events_by_key has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def chunk_events_by_key(
    events: List[Event], key: str, pulsetime: float = 5.0
) -> List[Event]:
    """
    "Chunks" adjacent events together which have the same value for a key, and stores the
Severity: Minor
Found in aw_transform/chunk_events_by_key.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 create_bucket has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def create_bucket(
Severity: Minor
Found in aw_datastore/storages/sqlite.py - About 45 mins to fix

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

        def create_bucket(
    Severity: Minor
    Found in aw_datastore/storages/abstract.py - About 45 mins to fix

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

          def create_bucket(
      Severity: Minor
      Found in aw_datastore/storages/mongodb.py - About 45 mins to fix

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

            def create_bucket(
        Severity: Minor
        Found in aw_datastore/storages/peewee.py - About 45 mins to fix

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

          def setup_logging(
          Severity: Minor
          Found in aw_core/log.py - About 45 mins to fix

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

                def create_bucket(
            Severity: Minor
            Found in aw_datastore/storages/memory.py - About 45 mins to fix

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

                  def create_bucket(
              Severity: Minor
              Found in aw_datastore/datastore.py - About 45 mins to fix

                Consider simplifying this complex logical expression.
                Open

                            if char == "'" and prev_char != "\\" and not double_quote:
                                single_quote = not single_quote
                            elif char == '"' and prev_char != "\\" and not single_quote:
                                double_quote = not double_quote
                            elif single_quote or double_quote:
                Severity: Major
                Found in aw_query/query2.py - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                              if char == "'" and prev_char != "\\" and not double_quote:
                                  single_quote = not single_quote
                              elif char == '"' and prev_char != "\\" and not single_quote:
                                  double_quote = not double_quote
                              elif double_quote or single_quote:
                  Severity: Major
                  Found in aw_query/query2.py - About 40 mins to fix

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

                    def query(
                    Severity: Minor
                    Found in aw_query/query2.py - About 35 mins to fix

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

                      def logs(ctx, module_name: str = None, since: datetime = None, level: str = None):
                          from aw_core.dirs import get_log_dir
                      
                          testing = ctx.parent.params["testing"]
                          logdir: Path = Path(get_log_dir(None))
                      Severity: Minor
                      Found in aw_cli/__main__.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 check has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def check(string: str):
                              token = ""
                              for i, char in enumerate(string):
                                  if char.isalpha() or char == "_":
                                      token += char
                      Severity: Minor
                      Found in aw_query/query2.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 check has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def check(string: str):
                              token = ""
                              quotes_type = string[0]
                              if quotes_type != '"' and quotes_type != "'":
                                  return token, string
                      Severity: Minor
                      Found in aw_query/query2.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 heartbeat_merge has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def heartbeat_merge(
                          last_event: Event, heartbeat: Event, pulsetime: float
                      ) -> Optional[Event]:
                          """
                          Merges two events if they have identical data
                      Severity: Minor
                      Found in aw_transform/heartbeats.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 q2_typecheck has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def q2_typecheck(f):
                          """Decorator that typechecks using `_verify_variable_is_type`"""
                          sig = signature(f)
                      
                          @wraps(f)
                      Severity: Minor
                      Found in aw_query/functions.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

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

                          def conditional_commit(self, num_statements):
                              """
                              Only commit transactions if:
                               - We have a lot of statements in our transaction
                               - Was a while ago since last commit
                      Severity: Minor
                      Found in aw_datastore/storages/sqlite.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

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

                          def duration(self, duration: Duration) -> None:
                              if isinstance(duration, timedelta):
                                  self["duration"] = duration
                              elif isinstance(duration, numbers.Real):
                                  self["duration"] = timedelta(seconds=duration)  # type: ignore
                      Severity: Minor
                      Found in aw_core/models.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