bdurand/us_geo

View on GitHub
data/lib/us_geo_data/urban_area.rb

Summary

Maintainability
C
1 day
Test Coverage

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_county_subdivisions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_county_subdivisions(urban_areas)
          foreach(data_file(USGeoData::URBAN_AREA_COUNTY_SUBDIVISION_REL_FILE), col_sep: "|") do |row|
            urban_area_geoid = row["GEOID_UA_20"]
            county_subdivision_geoid = row["GEOID_COUSUB_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

    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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        def dump_csv(output)
          csv = CSV.new(output)
          csv << ["GEOID", "Name", "Short Name", "Primary County GEOID", "Population", "Housing Units", "Land Area", "Water Area", "Latitude", "Longitude"]
          urban_area_data.each_value do |data|
            csv << [
    Severity: Major
    Found in data/lib/us_geo_data/urban_area.rb and 1 other location - About 1 hr to fix
    data/lib/us_geo_data/core_based_statistical_area.rb on lines 11..28

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 61.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. 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: Major
    Found in data/lib/us_geo_data/urban_area.rb and 1 other location - About 1 hr to fix
    data/lib/us_geo_data/urban_area.rb on lines 157..168

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 60.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        def add_county_subdivisions(urban_areas)
          foreach(data_file(USGeoData::URBAN_AREA_COUNTY_SUBDIVISION_REL_FILE), col_sep: "|") do |row|
            urban_area_geoid = row["GEOID_UA_20"]
            county_subdivision_geoid = row["GEOID_COUSUB_20"]
            overlap_land_area = row["AREALAND_PART"].to_f * SQUARE_METERS_TO_MILES
    Severity: Major
    Found in data/lib/us_geo_data/urban_area.rb and 1 other location - About 1 hr to fix
    data/lib/us_geo_data/urban_area.rb on lines 172..183

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 60.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 5 locations. Consider refactoring.
    Open

        def dump_county_subdivisions_csv(output)
          csv = CSV.new(output)
          csv << ["Urban Area GEOID", "County Subdivision GEOID", "Land Area", "Water Area"]
          urban_area_data.each_value do |urban_area|
            urban_area[:county_subdivisions].each do |county_subdivision_geoid, area|
    Severity: Major
    Found in data/lib/us_geo_data/urban_area.rb and 4 other locations - About 45 mins to fix
    data/lib/us_geo_data/urban_area.rb on lines 31..44
    data/lib/us_geo_data/urban_area.rb on lines 63..76
    data/lib/us_geo_data/zcta.rb on lines 28..41
    data/lib/us_geo_data/zcta.rb on lines 44..57

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 41.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 5 locations. Consider refactoring.
    Open

        def dump_counties_csv(output)
          csv = CSV.new(output)
          csv << ["Urban Area GEOID", "County GEOID", "Land Area", "Water Area"]
          urban_area_data.each_value do |urban_area|
            urban_area[:counties].each do |county_geoid, area|
    Severity: Major
    Found in data/lib/us_geo_data/urban_area.rb and 4 other locations - About 45 mins to fix
    data/lib/us_geo_data/urban_area.rb on lines 47..60
    data/lib/us_geo_data/urban_area.rb on lines 63..76
    data/lib/us_geo_data/zcta.rb on lines 28..41
    data/lib/us_geo_data/zcta.rb on lines 44..57

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 41.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 5 locations. Consider refactoring.
    Open

        def dump_zctas_csv(output)
          csv = CSV.new(output)
          csv << ["Urban Area GEOID", "ZCTA5", "Land Area", "Water Area"]
          urban_area_data.each_value do |urban_area|
            urban_area[:zctas].each do |zcta5, area|
    Severity: Major
    Found in data/lib/us_geo_data/urban_area.rb and 4 other locations - About 45 mins to fix
    data/lib/us_geo_data/urban_area.rb on lines 31..44
    data/lib/us_geo_data/urban_area.rb on lines 47..60
    data/lib/us_geo_data/zcta.rb on lines 28..41
    data/lib/us_geo_data/zcta.rb on lines 44..57

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 41.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    There are no issues that match your filters.

    Category
    Status