codeforamerica/brigade

View on GitHub

Showing 10 of 18 total issues

Function rsvps has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

def rsvps(brigadeid=None):
    ''' Show the Brigade rsvps '''

    if brigadeid:
        brigade = cfapi.find_brigade(brigadeid)
Severity: Minor
Found in brigade/views.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 initializeMap has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

window.Brigade.initializeMap = function(geoJSON) {
  // Provide your access token
  L.mapbox.accessToken = 'pk.eyJ1IjoiY29kZWZvcmFtZXJpY2EiLCJhIjoiY2pldDMwMzlnMHF3ZjMzbzUyMzNpdms4MSJ9.ZN9PlYN-2GGF_HQtY0zWWw';

  // Create a map in the div #map
Severity: Major
Found in brigade/static/js/application.js - About 2 hrs to fix

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

    def projects(brigadeid=None):
        ''' Display a list of projects '''
    
        # is this an exisiting group
        if brigadeid:
    Severity: Minor
    Found in brigade/views.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 friendly_time has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def friendly_time(dt, past_="ago", future_="from now", default="Just now"):
        ''' Returns string representing "time since" or "time until" e.g. 3 days ago, 5 hours from now etc.
        '''
    
        now = datetime.utcnow()
    Severity: Minor
    Found in filters/__init__.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 get_brigades has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_brigades(official_brigades_only=False):
        # Get location of all civic tech orgs
        got = get(BASE_URL + "/organizations.geojson")
        geojson = got.json()
        brigades = []
    Severity: Minor
    Found in cfapi/__init__.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 get_official_brigades_by_state has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_official_brigades_by_state():
        brigades = get_brigades(official_brigades_only=True)
        states = {}
        for brigade in brigades:
            # Find all two-letter state abbreviations in the brigade's city (e.g.
    Severity: Minor
    Found in cfapi/__init__.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 brigade has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def brigade(brigadeid):
        ''' Get this Brigade's info '''
    
        brigade = cfapi.find_brigade(brigadeid)
        if not brigade:
    Severity: Minor
    Found in brigade/views.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 update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    function update(){
      var list = document.getElementsByClassName("card"); //loop through all HTML elements with the class card. 
      // var list = document.getElementsByTagName("card"); 
      //uncomment line above if you want to use <card> instead of <div class='card'>
      var len = list.length;
    Severity: Minor
    Found in brigade/static/js/card-depth.js - 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 register has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def register(self, app, options, first_registration=False):
            sitemap = Sitemap(app=app)
    
            @app.route('/robots.txt')
            def static_from_root():
    Severity: Minor
    Found in brigade/sitemap.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 nav_link has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def nav_link(page, text, **kwargs):
        if 'class_name' in kwargs:
            classes = kwargs['class_name']
            del kwargs['class_name']
        else:
    Severity: Minor
    Found in filters/__init__.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