Skip to content

Appease the rubocop static code analyzer #71

@specious

Description

@specious

Running rubocop on the latest code on our production branch (9e9e521), I see 24 (ostensibly superficial) offenses. Looks like most of them have to do with double quoted string literals:

Inspecting 71 files
....................................C.................W................

Offenses:

config/initializers/customization.rb:2:42: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
AdoptAThing::Application.config.x.city = "Durham"
                                         ^^^^^^^^
config/initializers/customization.rb:2:50: C: Final newline missing.
AdoptAThing::Application.config.x.city = "Durham"
                                                 
lib/tasks/data.rake:9:21: C: Freeze mutable objects assigned to constants.
    TYPES_TO_SKIP = ["HEADWALL", "END SECTION"]
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/tasks/data.rake:9:22: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
    TYPES_TO_SKIP = ["HEADWALL", "END SECTION"]
                     ^^^^^^^^^^
lib/tasks/data.rake:9:34: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
    TYPES_TO_SKIP = ["HEADWALL", "END SECTION"]
                                 ^^^^^^^^^^^^^
lib/tasks/data.rake:17:28: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
    output_csv = File.open("durham_drains.csv", "w")
                           ^^^^^^^^^^^^^^^^^^^
lib/tasks/data.rake:17:49: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
    output_csv = File.open("durham_drains.csv", "w")
                                                ^^^
lib/tasks/data.rake:19:9: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
    ids["objectIds"].each_slice(150).each do |chunk|
        ^^^^^^^^^^^
lib/tasks/data.rake:24:12: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
      data["features"].each do |d|
           ^^^^^^^^^^
lib/tasks/data.rake:25:42: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
        next if TYPES_TO_SKIP.include? d["attributes"]["TYPE"]
                                         ^^^^^^^^^^^^
lib/tasks/data.rake:25:56: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
        next if TYPES_TO_SKIP.include? d["attributes"]["TYPE"]
                                                       ^^^^^^
lib/tasks/data.rake:26:31: C: Prefer single-quoted strings inside interpolations.
        output_csv.write("#{d["geometry"]["x"]},#{d["geometry"]["y"]},#{d["attributes"]["OWNER"]},#{d["attributes"]["OPERATIONALAREA"]},#{d["attributes"]["TYPE"]},#{d["attributes"]["FORM"]}\n")
                              ^^^^^^^^^^
lib/tasks/data.rake:26:43: C: Prefer single-quoted strings inside interpolations.
        output_csv.write("#{d["geometry"]["x"]},#{d["geometry"]["y"]},#{d["attributes"]["OWNER"]},#{d["attributes"]["OPERATIONALAREA"]},#{d["attributes"]["TYPE"]},#{d["attributes"]["FORM"]}\n")
                                          ^^^
lib/tasks/data.rake:26:53: C: Prefer single-quoted strings inside interpolations.
        output_csv.write("#{d["geometry"]["x"]},#{d["geometry"]["y"]},#{d["attributes"]["OWNER"]},#{d["attributes"]["OPERATIONALAREA"]},#{d["attributes"]["TYPE"]},#{d["attributes"]["FORM"]}\n")
                                                    ^^^^^^^^^^
lib/tasks/data.rake:26:65: C: Prefer single-quoted strings inside interpolations.
        output_csv.write("#{d["geometry"]["x"]},#{d["geometry"]["y"]},#{d["attributes"]["OWNER"]},#{d["attributes"]["OPERATIONALAREA"]},#{d["attributes"]["TYPE"]},#{d["attributes"]["FORM"]}\n")
                                                                ^^^
lib/tasks/data.rake:26:75: C: Prefer single-quoted strings inside interpolations.
        output_csv.write("#{d["geometry"]["x"]},#{d["geometry"]["y"]},#{d["attributes"]["OWNER"]},#{d["attributes"]["OPERATIONALAREA"]},#{d["attributes"]["TYPE"]},#{d["attributes"]["FORM"]}\n")
                                                                          ^^^^^^^^^^^^
lib/tasks/data.rake:26:89: C: Prefer single-quoted strings inside interpolations.
        output_csv.write("#{d["geometry"]["x"]},#{d["geometry"]["y"]},#{d["attributes"]["OWNER"]},#{d["attributes"]["OPERATIONALAREA"]},#{d["attributes"]["TYPE"]},#{d["attributes"]["FORM"]}\n")
                                                                                        ^^^^^^^
lib/tasks/data.rake:26:103: C: Prefer single-quoted strings inside interpolations.
        output_csv.write("#{d["geometry"]["x"]},#{d["geometry"]["y"]},#{d["attributes"]["OWNER"]},#{d["attributes"]["OPERATIONALAREA"]},#{d["attributes"]["TYPE"]},#{d["attributes"]["FORM"]}\n")
                                                                                                      ^^^^^^^^^^^^
lib/tasks/data.rake:26:117: C: Prefer single-quoted strings inside interpolations.
        output_csv.write("#{d["geometry"]["x"]},#{d["geometry"]["y"]},#{d["attributes"]["OWNER"]},#{d["attributes"]["OPERATIONALAREA"]},#{d["attributes"]["TYPE"]},#{d["attributes"]["FORM"]}\n")
                                                                                                                    ^^^^^^^^^^^^^^^^^
lib/tasks/data.rake:26:141: C: Prefer single-quoted strings inside interpolations.
        output_csv.write("#{d["geometry"]["x"]},#{d["geometry"]["y"]},#{d["attributes"]["OWNER"]},#{d["attributes"]["OPERATIONALAREA"]},#{d["attributes"]["TYPE"]},#{d["attributes"]["FORM"]}\n")
                                                                                                                                            ^^^^^^^^^^^^
lib/tasks/data.rake:26:155: C: Prefer single-quoted strings inside interpolations.
        output_csv.write("#{d["geometry"]["x"]},#{d["geometry"]["y"]},#{d["attributes"]["OWNER"]},#{d["attributes"]["OPERATIONALAREA"]},#{d["attributes"]["TYPE"]},#{d["attributes"]["FORM"]}\n")
                                                                                                                                                          ^^^^^^
lib/tasks/data.rake:26:168: C: Prefer single-quoted strings inside interpolations.
        output_csv.write("#{d["geometry"]["x"]},#{d["geometry"]["y"]},#{d["attributes"]["OWNER"]},#{d["attributes"]["OPERATIONALAREA"]},#{d["attributes"]["TYPE"]},#{d["attributes"]["FORM"]}\n")
                                                                                                                                                                       ^^^^^^^^^^^^
lib/tasks/data.rake:26:182: C: Prefer single-quoted strings inside interpolations.
        output_csv.write("#{d["geometry"]["x"]},#{d["geometry"]["y"]},#{d["attributes"]["OWNER"]},#{d["attributes"]["OPERATIONALAREA"]},#{d["attributes"]["TYPE"]},#{d["attributes"]["FORM"]}\n")
                                                                                                                                                                                     ^^^^^^
lib/tasks/data.rake:47:7: W: Useless assignment to variable - thing. Did you mean thing_hash?
      thing = Thing.create(thing_hash)
      ^^^^^

71 files inspected, 24 offenses detected

I'd like to open this thread as a step towards resolving the differences between rubocop's stylistic preferences and our source code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions