From: Tom Hughes Date: Wed, 2 Sep 2020 06:18:21 +0000 (+0100) Subject: Handle new rubocop warnings X-Git-Tag: live~2508 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/b7432e943222d5499d135afb4f6431ed4c3c988d Handle new rubocop warnings --- diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 05c4f63e2..87bf43bc3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2020-08-09 18:49:49 UTC using RuboCop version 0.89.0. +# on 2020-09-02 06:16:56 UTC using RuboCop version 0.90.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -188,6 +188,11 @@ Rails/OutputSafety: Rails/TimeZone: Enabled: false +# Offense count: 1 +Style/CombinableLoops: + Exclude: + - 'db/migrate/021_move_to_innodb.rb' + # Offense count: 572 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. @@ -217,6 +222,16 @@ Style/OptionalBooleanParameter: - 'test/models/trace_test.rb' - 'test/models/tracetag_test.rb' +# Offense count: 6 +# Configuration parameters: AllowModifier. +Style/SoleNestedConditional: + Exclude: + - 'app/controllers/user_blocks_controller.rb' + - 'app/models/old_way.rb' + - 'app/validators/characters_validator.rb' + - 'app/validators/whitespace_validator.rb' + - 'lib/classic_pagination/pagination.rb' + # Offense count: 28 # Cop supports --auto-correct. Style/StringConcatenation: diff --git a/app/controllers/api/amf_controller.rb b/app/controllers/api/amf_controller.rb index fc8a304bb..c903cc8e7 100644 --- a/app/controllers/api/amf_controller.rb +++ b/app/controllers/api/amf_controller.rb @@ -87,7 +87,7 @@ module Api result = [-5, nil] else case message - when "putway" then + when "putway" orn = renumberednodes.dup result = putway(renumberednodes, *args) result[4] = renumberednodes.reject { |k, _v| orn.key?(k) } @@ -96,7 +96,7 @@ module Api result = putrelation(renumberednodes, renumberedways, *args) when "deleteway" result = deleteway(*args) - when "putpoi" then + when "putpoi" result = putpoi(*args) renumberednodes[result[2]] = result[3] if result[0].zero? && result[2] != result[3] when "startchangeset" diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ed9c124b1..b3596b376 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -616,13 +616,13 @@ class UsersController < ApplicationController user.languages = params[:user][:languages].split(",") case params[:avatar_action] - when "new" then + when "new" user.avatar.attach(params[:user][:avatar]) user.image_use_gravatar = false - when "delete" then + when "delete" user.avatar.purge_later user.image_use_gravatar = false - when "gravatar" then + when "gravatar" user.avatar.purge_later user.image_use_gravatar = true end diff --git a/app/models/concerns/geo_record.rb b/app/models/concerns/geo_record.rb index a5635c172..23101856a 100644 --- a/app/models/concerns/geo_record.rb +++ b/app/models/concerns/geo_record.rb @@ -5,10 +5,6 @@ module GeoRecord # and not e.g. 4.0e-05 # Unfortunately you can't extend Numeric classes directly (e.g. `Coord < Float`). class Coord < DelegateClass(Float) - def initialize(obj) - super(obj) - end - def to_s format("%.7f", :coord => self) end diff --git a/lib/osm.rb b/lib/osm.rb index a4ac7fc57..04cbf17fa 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -247,10 +247,6 @@ module OSM ## # raised when user input couldn't be parsed class APIBadUserInput < APIError - def initialize(message) - super message - end - def status :bad_request end @@ -259,10 +255,6 @@ module OSM ## # raised when bounding box is invalid class APIBadBoundingBox < APIError - def initialize(message) - super message - end - def status :bad_request end