18F/domain-scan

View on GitHub
scanners/pagedata.py

Summary

Maintainability
D
1 day
Test Coverage

Function scan has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
Open

def scan(domain: str, environment: dict, options: dict) -> dict:
    logging.debug("Scan function called with options: %s" % options)

    results = {}

Severity: Minor
Found in scanners/pagedata.py - About 1 day 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

Avoid deeply nested control flow statements.
Open

                            if event == 'string':
                                counter = counter + 1

                            # see if there is a 'conformsTo' field, which indicates that it might
                            # be open-data compliant.
Severity: Major
Found in scanners/pagedata.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                                if prefix.endswith('.conformsTo') or prefix.endswith('.conformsto'):
                                    results[page]['opendata_conforms_to'] = ' '.join([value, results[page]['opendata_conforms_to']])
    
                                # see if there is a 'measurementType' field, which indicates that it might
                                # be code.gov compliant.  Taken from https://code.gov/about/compliance/inventory-code
    Severity: Major
    Found in scanners/pagedata.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                                  if prefix.endswith('measurementType.ifOther') or prefix.endswith('measurementtype.ifOther'):
                                      results[page]['codegov_measurementtype'] = ' '.join([value, results[page]['codegov_measurementtype']])
      
      
      Severity: Major
      Found in scanners/pagedata.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                    if prefix.endswith('.measurementType') or prefix.endswith('.measurementtype'):
                                        results[page]['codegov_measurementtype'] = ' '.join([value, results[page]['codegov_measurementtype']])
                                    if prefix.endswith('measurementType.method') or prefix.endswith('measurementtype.method'):
        Severity: Major
        Found in scanners/pagedata.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                      if prefix.endswith('measurementType.method') or prefix.endswith('measurementtype.method'):
                                          results[page]['codegov_measurementtype'] = ' '.join([value, results[page]['codegov_measurementtype']])
                                      if prefix.endswith('measurementType.ifOther') or prefix.endswith('measurementtype.ifOther'):
          Severity: Major
          Found in scanners/pagedata.py - About 45 mins to fix

            There are no issues that match your filters.

            Category
            Status