From 5d67fa3908b835f7a2f099ca8525b64bcc9fe9e2 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 8 Mar 2022 19:10:05 +0000 Subject: [PATCH] Fix some Naming/AccessorMethodName rubocop warnings --- .rubocop_todo.yml | 4 +--- app/controllers/api_controller.rb | 2 +- app/controllers/application_controller.rb | 4 ++-- lib/diff_reader.rb | 2 +- lib/osm.rb | 2 +- test/controllers/api/relations_controller_test.rb | 2 +- test/test_helper.rb | 6 +++--- 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 64781f919..8c1ce723c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -99,12 +99,10 @@ Metrics/PerceivedComplexity: Minitest/MultipleAssertions: Max: 52 -# Offense count: 3 +# Offense count: 1 Naming/AccessorMethodName: Exclude: - - 'app/controllers/application_controller.rb' - 'app/helpers/title_helper.rb' - - 'lib/osm.rb' # Offense count: 8 # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros. diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 2d8d51dd8..050c455cd 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -100,7 +100,7 @@ class ApiController < ApplicationController elsif Authenticator.new(self, [:token]).allow? # self.current_user setup by OAuth else - username, passwd = get_auth_data # parse from headers + username, passwd = auth_data # parse from headers # authenticate per-scheme self.current_user = if username.nil? nil # no authentication provided - perhaps first connect (client should retry after 401) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index bb32e7e6e..1d6865405 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -161,7 +161,7 @@ class ApplicationController < ActionController::Base response.headers["Error"] = message if request.headers["X-Error-Format"]&.casecmp("xml")&.zero? - result = OSM::API.new.get_xml_doc + result = OSM::API.new.xml_doc result.root.name = "osmError" result.root << (XML::Node.new("status") << "#{Rack::Utils.status_code(status)} #{Rack::Utils::HTTP_STATUS_CODES[status]}") result.root << (XML::Node.new("message") << message) @@ -363,7 +363,7 @@ class ApplicationController < ActionController::Base end # extract authorisation credentials from headers, returns user = nil if none - def get_auth_data + def auth_data if request.env.key? "X-HTTP_AUTHORIZATION" # where mod_rewrite might have put it authdata = request.env["X-HTTP_AUTHORIZATION"].to_s.split elsif request.env.key? "REDIRECT_X_HTTP_AUTHORIZATION" # mod_fcgi diff --git a/lib/diff_reader.rb b/lib/diff_reader.rb index 1189c86d0..d1987a936 100644 --- a/lib/diff_reader.rb +++ b/lib/diff_reader.rb @@ -128,7 +128,7 @@ class DiffReader @reader.read raise OSM::APIBadUserInput, "Document element should be 'osmChange'." if @reader.name != "osmChange" - result = OSM::API.new.get_xml_doc + result = OSM::API.new.xml_doc result.root.name = "diffResult" # loop at the top level, within the element diff --git a/lib/osm.rb b/lib/osm.rb index ee0b8d903..e258aaaf0 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -445,7 +445,7 @@ module OSM end class API - def get_xml_doc + def xml_doc doc = XML::Document.new doc.encoding = XML::Encoding::UTF_8 root = XML::Node.new "osm" diff --git a/test/controllers/api/relations_controller_test.rb b/test/controllers/api/relations_controller_test.rb index ec86e07a5..eb8f8e022 100644 --- a/test/controllers/api/relations_controller_test.rb +++ b/test/controllers/api/relations_controller_test.rb @@ -1036,7 +1036,7 @@ module Api version = nil with_controller(Api::ChangesetsController.new) do - doc = OSM::API.new.get_xml_doc + doc = OSM::API.new.xml_doc change = XML::Node.new "osmChange" doc.root = change modify = XML::Node.new "modify" diff --git a/test/test_helper.rb b/test/test_helper.rb index 421ae8698..7157abf5a 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -255,7 +255,7 @@ module ActiveSupport end def xml_for_node(node) - doc = OSM::API.new.get_xml_doc + doc = OSM::API.new.xml_doc doc.root << xml_node_for_node(node) doc end @@ -277,7 +277,7 @@ module ActiveSupport end def xml_for_way(way) - doc = OSM::API.new.get_xml_doc + doc = OSM::API.new.xml_doc doc.root << xml_node_for_way(way) doc end @@ -308,7 +308,7 @@ module ActiveSupport end def xml_for_relation(relation) - doc = OSM::API.new.get_xml_doc + doc = OSM::API.new.xml_doc doc.root << xml_node_for_relation(relation) doc end -- 2.39.5