ActivityWatch/aw-core

View on GitHub

Showing 49 of 49 total issues

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

    def match(self, e: Event) -> bool:
        if self.select_keys:
            values = [e.data.get(key, None) for key in self.select_keys]
        else:
            values = list(e.data.values())
Severity: Minor
Found in aw_transform/classify.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 parse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def parse(string: str, namespace: dict) -> QToken:
        entries_str = string[1:-1]
        d: Dict[str, QToken] = {}
        while len(entries_str) > 0:
            entries_str = entries_str.strip()
Severity: Minor
Found in aw_query/query2.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 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      def update_bucket(
                  Severity: Minor
                  Found in aw_datastore/storages/memory.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 double_quote or single_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 single_quote or double_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 setup_logging has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

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

                            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 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 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

                            Severity
                            Category
                            Status
                            Source
                            Language