src/triage/component/collate/spacetime.py

Summary

Maintainability
C
7 hrs
Test Coverage

Function validate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def validate(self, conn):
        """
        SpacetimeAggregations ensure that no intervals extend beyond the absolute
        minimum time.
        """
Severity: Minor
Found in src/triage/component/collate/spacetime.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 colname_aggregate_lookup has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def colname_aggregate_lookup(self):
        """A reverse lookup from column name to the source collate.Aggregate

        Will error if the Aggregation contains duplicate column names
        """
Severity: Minor
Found in src/triage/component/collate/spacetime.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 14 arguments (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(
Severity: Major
Found in src/triage/component/collate/spacetime.py - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

                            if col.name in lookup:
                                raise ValueError("Duplicate feature column name found: ", col.name)
                            lookup[col.name] = agg
    Severity: Major
    Found in src/triage/component/collate/spacetime.py - About 45 mins to fix

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

          def get_selects(self):
              """
              Constructs select queries for this aggregation
      
              Returns: a dictionary of group : queries pairs where
      Severity: Minor
      Found in src/triage/component/collate/spacetime.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 get_imputation_rules has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_imputation_rules(self):
              """
              Constructs a dictionary to lookup an imputation rule from an associated
              column name.
      
      
      Severity: Minor
      Found in src/triage/component/collate/spacetime.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

      Line too long (95 > 88 characters)
      Open

                                  raise ValueError("Duplicate feature column name found: ", col.name)

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Blank line contains whitespace
      Open

                  

      Trailing whitespace is superfluous.

      The warning returned varies on whether the line itself is blank,
      for easier filtering for those who want to indent their blank lines.
      
      Okay: spam(1)\n#
      W291: spam(1) \n#
      W293: class Foo(object):\n    \n    bang = 12

      Line too long (90 > 88 characters)
      Open

                      """SUM(CASE WHEN "{col}" IS NULL THEN 1 ELSE 0 END) AS "{col}" """.format(

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (92 > 88 characters)
      Open

                  output_date_column: name of date column in aggregated output, defaults to "date"

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (104 > 88 characters)
      Open

                              f"(select * from {self.from_obj}) from_obj join {self.state_table} cohort on ( "

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (90 > 88 characters)
      Open

              # imputation starts from the state table and left joins into the aggregation table

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (105 > 88 characters)
      Open

                      query = ex.select(columns=columns, from_obj=make_sql_clause(from_obj, ex.text)).group_by(

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (89 > 88 characters)
      Open

              Returns: string for a common column prefix for columns in that group and interval

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      There are no issues that match your filters.

      Category
      Status