codeforamerica/streetsearch

View on GitHub

Showing 5 of 10 total issues

Function seek_backwards has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def seek_backwards(text, fragment, index, matches, placeid):
    logger.debug('text | fragment | index | matches %s | %s | %s | %s' % (text,fragment,index,matches))
    if index == 0:
        return matches
    prev_index = index - 1
Severity: Minor
Found in geocoder.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 populateMap has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function populateMap(response) {
  // add a new layer to the map
  lg.features = L.geoJson(null, {
    style: { color: '#0a1e0a', weight: 5 },
    onEachFeature: function (feature, layer) {
Severity: Minor
Found in static/scripts.js - About 1 hr to fix

    Function geocode_text has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def geocode_text(sentence, placename):
    
        placeids = {'nyc':'ub16000us3651000',
                    'sf':'ub16000us0667000',
                    'chicago':'ub16000us1714000',
    Severity: Minor
    Found in geocoder.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 seek_backwards has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def seek_backwards(text, fragment, index, matches, placeid):
    Severity: Minor
    Found in geocoder.py - About 35 mins to fix

      Avoid too many return statements within this function.
      Open

              return seek_backwards(text, test_string, prev_index, new_matches, placeid)
      Severity: Major
      Found in geocoder.py - About 30 mins to fix
        Severity
        Category
        Status
        Source
        Language