Skip to content

Commit

Permalink
Fix some Naming/AccessorMethodName rubocop warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Mar 8, 2022
1 parent cfb4a70 commit 5d67fa3
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 12 deletions.
4 changes: 1 addition & 3 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def setup_user_auth
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)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def report_error(message, status = :bad_request)
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)
Expand Down Expand Up @@ -363,7 +363,7 @@ def deny_access(_exception)
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
Expand Down
2 changes: 1 addition & 1 deletion lib/diff_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def commit
@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 <osmChange> element
Expand Down
2 changes: 1 addition & 1 deletion lib/osm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def sql_for_distance(lat_field, lon_field)
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"
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/api/relations_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ def with_update_diff(rel, headers)
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"
Expand Down
6 changes: 3 additions & 3 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def session_for(user)
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
Expand All @@ -277,7 +277,7 @@ def xml_node_for_node(node)
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
Expand Down Expand Up @@ -308,7 +308,7 @@ def xml_node_for_way(way)
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
Expand Down

0 comments on commit 5d67fa3

Please sign in to comment.