fbi-cde/crime-data-api

View on GitHub

Showing 117 of 117 total issues

Function base_query has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def base_query(self, field):
        select_query = 'SELECT b.:field, a.count, b.year FROM (SELECT :field , count, year::text'
        from_query = ' FROM :view_name'
        where_query = ' WHERE :field IS NOT NULL'

Severity: Minor
Found in crime_data/common/cdemodels.py - About 55 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

Avoid deeply nested control flow statements.
Open

                        if data_year == self.results[i].data_year:
                            d.value =  d.value + getattr(self.results[i], self.keys[j].column_name)
                    d.value = int(d.value)
Severity: Major
Found in crime_data/common/munger.py - About 45 mins to fix

    Function query has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def query(self, args):
            base_query = None
            qry = None
            param_dict = {}
            try:
    Severity: Minor
    Found in crime_data/common/cdemodels.py - About 45 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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, field, year=None, state_id=None, state_abbr=None, ori=None, as_json=True):
    Severity: Minor
    Found in crime_data/common/cdemodels.py - About 45 mins to fix

      Function get_offenses has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_offenses(offense):
          if offense == 'aggravated-assault':
              return ['Aggravated Assault']
          elif offense == 'burglary':
           return ['Burglary/Breaking & Entering']
      Severity: Minor
      Found in crime_data/resources/nibrs_counts.py - About 45 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

      Avoid deeply nested control flow statements.
      Open

                              if data_year == self.results[i].data_year and keytype ==  getattr(self.results[i], self.key_type):
                                  d.value =  d.value + getattr(self.results[i], self.keys[j].column_name)
                          d.value = int(d.value)
      Severity: Major
      Found in crime_data/common/munger.py - About 45 mins to fix

        Function base_query has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def base_query(self, field):
        
                query = 'SELECT b.:field, a.count, b.year FROM (SELECT :field ,stolen_value::text, recovered_value::text, year::text, count'
                query += ' FROM :view_name '
                where_query = ' WHERE :field IS NOT NULL'
        Severity: Minor
        Found in crime_data/common/cdemodels.py - About 45 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 has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def get(self, args, variable,queryType,state_abbr=None, offense_name=None):
        Severity: Minor
        Found in crime_data/resources/nibrs_counts.py - About 35 mins to fix

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

              def get(self, state = None, agency = None, year = None, county = None, explorer_offense = None):
          Severity: Minor
          Found in crime_data/common/newmodels.py - About 35 mins to fix

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

                def get(self, args, variable, state_id=None, state_abbr=None, ori=None):
            Severity: Minor
            Found in crime_data/resources/offenses.py - About 35 mins to fix

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

                  def get(self, args, variable, state_id=None, state_abbr=None, ori=None):
              Severity: Minor
              Found in crime_data/resources/hate_crime.py - About 35 mins to fix

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

                    def get(self, state = None, agency = None, year = None, county = None, classification = None):
                Severity: Minor
                Found in crime_data/common/newmodels.py - About 35 mins to fix

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

                      def get(self, args, variable, state_id=None, state_abbr=None, ori=None):
                  Severity: Minor
                  Found in crime_data/resources/offenders.py - About 35 mins to fix

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

                        def get(self, state = None, agency = None, year = None, county = None, explorer_offense = None):
                    Severity: Minor
                    Found in crime_data/common/newmodels.py - About 35 mins to fix

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

                          def __init__(self,ui_type,title,category,noun,short_title):
                      Severity: Minor
                      Found in crime_data/common/munger.py - About 35 mins to fix

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

                            def get(self, args, variable, state_id=None, state_abbr=None, ori=None):
                        Severity: Minor
                        Found in crime_data/resources/cargo_theft.py - About 35 mins to fix

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

                              def get(self, args, variable, state_id=None, state_abbr=None, ori=None):
                          Severity: Minor
                          Found in crime_data/resources/victims.py - About 35 mins to fix

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

                                def get(self, args, variable,queryType,ori=None, offense_name=None):
                            Severity: Minor
                            Found in crime_data/resources/nibrs_counts.py - About 35 mins to fix

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

                                  def __init__(self, field, year=None, state_id=None, ori=None,
                                               offense_name=None, state_abbr=None, explorer_offense=None, as_json=True):
                              
                                      self.as_json = as_json
                              
                              
                              Severity: Minor
                              Found in crime_data/common/cdemodels.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 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def get(self, state = None, agency = None, year = None, county = None, explorer_offense = None):
                                      """Get Agency Sums given a state/year/county/agency ori, etc."""
                                      query = AgencySums.query
                              
                                      if state:
                              Severity: Minor
                              Found in crime_data/common/newmodels.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

                              Severity
                              Category
                              Status
                              Source
                              Language