18F/federalist-garden-build

View on GitHub

Showing 4 of 24 total issues

Function setup_node has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def setup_node(should_cache: bool, bucket, s3_client):
    '''
    Sets up node and installs dependencies.

    Uses the node version specified in the cloned repo's .nvmrc
Severity: Minor
Found in src/steps/build.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 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, filename, dir_prefix, site_prefix, base_url, cache_control):
Severity: Minor
Found in src/publishing/models.py - About 35 mins to fix

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

        def __init__(self, checksum_file, local_folder, bucket, s3_client, logger):
    Severity: Minor
    Found in src/steps/cache.py - About 35 mins to fix

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

          def do_POST(self):
              flush_print(f"\n{self.command} {self.path}")
      
              content_length = self.headers.get('Content-Length')
              length = int(content_length) if content_length else 0
      Severity: Minor
      Found in echo-server/run.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