bdurand/us_geo

View on GitHub

Showing 31 of 68 total issues

Method core_based_statistical_area_data has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def core_based_statistical_area_data
      unless defined?(@core_based_statistical_area_data)
        core_based_statistical_areas = {}
        foreach(data_file(USGeoData::CBSA_DELINEATION_FILE), col_sep: ",") do |row|
          cbsa_code = row["CBSA Code"]
Severity: Minor
Found in data/lib/us_geo_data/core_based_statistical_area.rb - 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

Method breadcrumb_links has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def breadcrumb_links(active = nil)
    return {} if @breadcrumbs.blank?

    objects = @breadcrumbs.values
    region = objects.detect { |b| b.is_a?(USGeo::Region) }
Severity: Minor
Found in explorer_app/app/helpers/application_helper.rb - 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

Method foreach has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def foreach(csv_file, options = {}, &block)
      options = {headers: true}.merge(options)
      encoding = options.delete(:encoding) || "UTF-8"
      file = (csv_file.is_a?(String) ? File.open(csv_file, encoding: encoding) : csv_file)
      begin
Severity: Minor
Found in data/lib/us_geo_data/processor.rb - 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

Method metropolitan_division_data has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def metropolitan_division_data
      unless defined?(@metropolitan_division_data)
        metropolitan_divisions = {}

        foreach(data_file(USGeoData::CBSA_DELINEATION_FILE), col_sep: ",") do |row|
Severity: Minor
Found in data/lib/us_geo_data/metropolitan_division.rb - 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

Method dump_all has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def dump_all(files = nil)
      files = Array(files)
      counties = County.new
      states = State.new(counties: counties)

Severity: Minor
Found in data/lib/us_geo_data.rb - About 1 hr to fix

    Method preprocess has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def preprocess
          counties_file = File.open(processed_file(COUNTIES_FILE), "w")
          subdivisions_file = File.open(processed_file(SUBDIVISIONS_FILE), "w")
          places_file = File.open(processed_file(PLACES_FILE), "w")
          place_counties_file = File.open(processed_file(PLACE_COUNTIES_FILE), "w")
    Severity: Minor
    Found in data/lib/us_geo_data/gnis.rb - About 1 hr to fix

      Method dump_all has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def dump_all(files = nil)
            files = Array(files)
            counties = County.new
            states = State.new(counties: counties)
      
      
      Severity: Minor
      Found in data/lib/us_geo_data.rb - 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

      Method preprocess has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def preprocess
            counties_file = File.open(processed_file(COUNTIES_FILE), "w")
            subdivisions_file = File.open(processed_file(SUBDIVISIONS_FILE), "w")
            places_file = File.open(processed_file(PLACES_FILE), "w")
            place_counties_file = File.open(processed_file(PLACE_COUNTIES_FILE), "w")
      Severity: Minor
      Found in data/lib/us_geo_data/gnis.rb - 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

      Method breadcrumb_links has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def breadcrumb_links(active = nil)
          return {} if @breadcrumbs.blank?
      
          objects = @breadcrumbs.values
          region = objects.detect { |b| b.is_a?(USGeo::Region) }
      Severity: Minor
      Found in explorer_app/app/helpers/application_helper.rb - About 1 hr to fix

        Method core_based_statistical_area_data has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def core_based_statistical_area_data
              unless defined?(@core_based_statistical_area_data)
                core_based_statistical_areas = {}
                foreach(data_file(USGeoData::CBSA_DELINEATION_FILE), col_sep: ",") do |row|
                  cbsa_code = row["CBSA Code"]
        Severity: Minor
        Found in data/lib/us_geo_data/core_based_statistical_area.rb - About 1 hr to fix

          Method add_urban_areas has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def add_urban_areas(places)
                overlaps = {}
                foreach(data_file(USGeoData::PLACE_URBAN_AREA_REL_FILE), col_sep: "|") do |row|
                  urban_area_geoid = row["GEOID_UA_20"]
                  place_geoid = row["GEOID_PLACE_20"]
          Severity: Minor
          Found in data/lib/us_geo_data/place.rb - 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

          Method add_urban_areas has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def add_urban_areas(zctas)
                overlaps = {}
                foreach(data_file(USGeoData::ZCTA_URBAN_AREA_REL_FILE), col_sep: "|") do |row|
                  urban_area_geoid = row["GEOID_UA_20"]
                  zcta5 = row["GEOID_ZCTA5_20"]
          Severity: Minor
          Found in data/lib/us_geo_data/zcta.rb - 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

          Method add_extra_counties has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def add_extra_counties(counties)
                foreach(data_file(USGeoData::EXTRA_COUNTIES_FILE), col_sep: ",") do |row|
                  county_geoid = row["GEOID"]
                  data = counties[county_geoid] || {}
                  data[:geoid] = county_geoid
          Severity: Minor
          Found in data/lib/us_geo_data/county.rb - 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

          Method combined_statistical_area_data has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def combined_statistical_area_data
                unless defined?(@combined_statistical_area_data)
                  combined_statistical_areas = {}
          
                  foreach(data_file(USGeoData::CBSA_DELINEATION_FILE), col_sep: ",") do |row|
          Severity: Minor
          Found in data/lib/us_geo_data/combined_statistical_area.rb - 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

          Method zcta_10_to_20_mappings has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def zcta_10_to_20_mappings
                mapping = {}
                foreach(data_file(USGeoData::ZCTA_10_ZCTA_20_REL_FILE), col_sep: "|") do |row|
                  old_geoid = row["GEOID_ZCTA5_10"]
                  new_geoid = row["GEOID_ZCTA5_20"]
          Severity: Minor
          Found in data/lib/us_geo_data/zcta.rb - 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

          Method dump_csv has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def dump_csv(output)
                csv = CSV.new(output)
                csv << ["GEOID", "GNIS ID", "Name", "Short Name", "State", "CBSA", "Metropolitan Division", "Central", "Time Zone", "Time Zone 2", "FIPS Class", "Population", "Housing Units", "Land Area", "Water Area", "Latitude", "Longitude"]
                county_data.each_value do |data|
                  unless data[:time_zone] && data[:gnis_id] && data[:fips_class]
          Severity: Minor
          Found in data/lib/us_geo_data/county.rb - About 1 hr to fix

            Method place_data has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def place_data
                  unless defined?(@place_data)
                    places = {}
            
                    gnis_places = gnis_place_mapping
            Severity: Minor
            Found in data/lib/us_geo_data/place.rb - About 1 hr to fix

              Method urban_area_data has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def urban_area_data
                    unless defined?(@urban_area_data)
                      urban_areas = {}
              
                      foreach(data_file(USGeoData::URBAN_AREA_GAZETTEER_FILE), col_sep: "\t") do |row|
              Severity: Minor
              Found in data/lib/us_geo_data/urban_area.rb - About 1 hr to fix

                Method add_zctas has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def add_zctas(urban_areas)
                      foreach(data_file(USGeoData::ZCTA_URBAN_AREA_REL_FILE), col_sep: "|") do |row|
                        urban_area_geoid = row["GEOID_UA_20"]
                        zcta5 = row["GEOID_ZCTA5_20"]
                        overlap_land_area = row["AREALAND_PART"].to_f * SQUARE_METERS_TO_MILES
                Severity: Minor
                Found in data/lib/us_geo_data/urban_area.rb - 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

                Method add_counties has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def add_counties(urban_areas)
                      foreach(data_file(USGeoData::URBAN_AREA_COUNTY_REL_FILE), col_sep: "|") do |row|
                        urban_area_geoid = row["GEOID_UA_20"]
                        county_geoid = row["GEOID_COUNTY_20"]
                        urban_area_land_area = row["AREALAND_UA_20"].to_f * SQUARE_METERS_TO_MILES
                Severity: Minor
                Found in data/lib/us_geo_data/urban_area.rb - 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

                Severity
                Category
                Status
                Source
                Language