Fix new rubocop warnings
This commit is contained in:
parent
6fba59724a
commit
1f2ac59d1d
18 changed files with 56 additions and 53 deletions
|
@ -38,6 +38,9 @@ Naming/FileName:
|
|||
- 'script/locale/reload-languages'
|
||||
- 'script/update-spam-blocks'
|
||||
|
||||
Naming/UncommunicativeMethodParamName:
|
||||
Enabled: false
|
||||
|
||||
Rails/ApplicationRecord:
|
||||
Enabled: false
|
||||
|
||||
|
|
|
@ -110,17 +110,17 @@ class AmfController < ApplicationController
|
|||
def amf_handle_error(call, rootobj, rootid)
|
||||
yield
|
||||
rescue OSM::APIAlreadyDeletedError => ex
|
||||
return [-4, ex.object, ex.object_id]
|
||||
[-4, ex.object, ex.object_id]
|
||||
rescue OSM::APIVersionMismatchError => ex
|
||||
return [-3, [rootobj, rootid], [ex.type.downcase, ex.id, ex.latest]]
|
||||
[-3, [rootobj, rootid], [ex.type.downcase, ex.id, ex.latest]]
|
||||
rescue OSM::APIUserChangesetMismatchError => ex
|
||||
return [-2, ex.to_s]
|
||||
[-2, ex.to_s]
|
||||
rescue OSM::APIBadBoundingBox => ex
|
||||
return [-2, "Sorry - I can't get the map for that area. The server said: #{ex}"]
|
||||
[-2, "Sorry - I can't get the map for that area. The server said: #{ex}"]
|
||||
rescue OSM::APIError => ex
|
||||
return [-1, ex.to_s]
|
||||
[-1, ex.to_s]
|
||||
rescue StandardError => ex
|
||||
return [-2, "An unusual error happened (in #{call}). The server said: #{ex}"]
|
||||
[-2, "An unusual error happened (in #{call}). The server said: #{ex}"]
|
||||
end
|
||||
|
||||
def amf_handle_error_with_timeout(call, rootobj, rootid)
|
||||
|
@ -437,9 +437,9 @@ class AmfController < ApplicationController
|
|||
revdates.collect! { |d| [(d + 1).strftime("%d %b %Y, %H:%M:%S")] + revusers[d.to_i] }
|
||||
revdates.uniq!
|
||||
|
||||
return ["way", wayid, revdates]
|
||||
["way", wayid, revdates]
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
return ["way", wayid, []]
|
||||
["way", wayid, []]
|
||||
end
|
||||
|
||||
# Find history of a node. Returns 'node', id, and an array of previous versions as above.
|
||||
|
@ -448,9 +448,9 @@ class AmfController < ApplicationController
|
|||
history = Node.find(nodeid).old_nodes.unredacted.reverse.collect do |old_node|
|
||||
[(old_node.timestamp + 1).strftime("%d %b %Y, %H:%M:%S")] + change_user(old_node)
|
||||
end
|
||||
return ["node", nodeid, history]
|
||||
["node", nodeid, history]
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
return ["node", nodeid, []]
|
||||
["node", nodeid, []]
|
||||
end
|
||||
|
||||
def change_user(obj)
|
||||
|
@ -865,7 +865,7 @@ class AmfController < ApplicationController
|
|||
end
|
||||
|
||||
def getlocales
|
||||
@locales ||= Locale.list(Dir.glob(Rails.root.join("config", "potlatch", "locales", "*")).collect { |f| File.basename(f, ".yml") })
|
||||
@getlocales ||= Locale.list(Dir.glob(Rails.root.join("config", "potlatch", "locales", "*")).collect { |f| File.basename(f, ".yml") })
|
||||
end
|
||||
|
||||
##
|
||||
|
|
|
@ -296,7 +296,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def preferred_languages
|
||||
@languages ||= if params[:locale]
|
||||
@preferred_languages ||= if params[:locale]
|
||||
Locale.list(params[:locale])
|
||||
elsif current_user
|
||||
current_user.preferred_languages
|
||||
|
|
|
@ -507,7 +507,7 @@ class ChangesetController < ApplicationController
|
|||
# restrict changes to those closed during a particular time period
|
||||
def conditions_time(changesets, time)
|
||||
if time.nil?
|
||||
return changesets
|
||||
changesets
|
||||
elsif time.count(",") == 1
|
||||
# if there is a range, i.e: comma separated, then the first is
|
||||
# low, second is high - same as with bounding boxes.
|
||||
|
@ -517,10 +517,10 @@ class ChangesetController < ApplicationController
|
|||
raise OSM::APIBadUserInput, "bad time range" if times.size != 2
|
||||
|
||||
from, to = times.collect { |t| Time.parse(t) }
|
||||
return changesets.where("closed_at >= ? and created_at <= ?", from, to)
|
||||
changesets.where("closed_at >= ? and created_at <= ?", from, to)
|
||||
else
|
||||
# if there is no comma, assume its a lower limit on time
|
||||
return changesets.where("closed_at >= ?", Time.parse(time))
|
||||
changesets.where("closed_at >= ?", Time.parse(time))
|
||||
end
|
||||
# stupid Time seems to throw both of these for bad parsing, so
|
||||
# we have to catch both and ensure the correct code path is taken.
|
||||
|
|
|
@ -48,7 +48,7 @@ class DiaryEntryController < ApplicationController
|
|||
|
||||
if current_user != @diary_entry.user
|
||||
redirect_to :action => "view", :id => params[:id]
|
||||
elsif params[:diary_entry] && @diary_entry.update_attributes(entry_params)
|
||||
elsif params[:diary_entry] && @diary_entry.update(entry_params)
|
||||
redirect_to :action => "view", :id => params[:id]
|
||||
end
|
||||
|
||||
|
@ -192,13 +192,13 @@ class DiaryEntryController < ApplicationController
|
|||
|
||||
def hide
|
||||
entry = DiaryEntry.find(params[:id])
|
||||
entry.update_attributes(:visible => false)
|
||||
entry.update(:visible => false)
|
||||
redirect_to :action => "list", :display_name => entry.user.display_name
|
||||
end
|
||||
|
||||
def hidecomment
|
||||
comment = DiaryComment.find(params[:comment])
|
||||
comment.update_attributes(:visible => false)
|
||||
comment.update(:visible => false)
|
||||
redirect_to :action => "view", :display_name => comment.diary_entry.user.display_name, :id => comment.diary_entry.id
|
||||
end
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class OauthClientsController < ApplicationController
|
|||
|
||||
def update
|
||||
@client_application = current_user.client_applications.find(params[:id])
|
||||
if @client_application.update_attributes(application_params)
|
||||
if @client_application.update(application_params)
|
||||
flash[:notice] = t "oauth_clients.update.flash"
|
||||
redirect_to :action => "show", :id => @client_application.id
|
||||
else
|
||||
|
|
|
@ -60,7 +60,7 @@ class UserBlocksController < ApplicationController
|
|||
if @user_block.creator != current_user
|
||||
flash[:error] = t("user_block.update.only_creator_can_edit")
|
||||
redirect_to :action => "edit"
|
||||
elsif @user_block.update_attributes(
|
||||
elsif @user_block.update(
|
||||
:ends_at => Time.now.getutc + @block_period.hours,
|
||||
:reason => params[:user_block][:reason],
|
||||
:needs_view => params[:user_block][:needs_view]
|
||||
|
|
|
@ -72,7 +72,7 @@ class ClientApplication < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def credentials
|
||||
@oauth_client ||= OAuth::Consumer.new(key, secret)
|
||||
@credentials ||= OAuth::Consumer.new(key, secret)
|
||||
end
|
||||
|
||||
def create_request_token(_params = {})
|
||||
|
|
|
@ -52,7 +52,7 @@ class OauthToken < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def invalidate!
|
||||
update_attributes(:invalidated_at => Time.now)
|
||||
update(:invalidated_at => Time.now)
|
||||
end
|
||||
|
||||
def authorized?
|
||||
|
|
|
@ -189,7 +189,7 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def preferred_languages
|
||||
@locales ||= Locale.list(languages)
|
||||
@preferred_languages ||= Locale.list(languages)
|
||||
end
|
||||
|
||||
def nearby(radius = NEARBY_RADIUS, num = NEARBY_USERS)
|
||||
|
|
|
@ -63,7 +63,7 @@ class UserBlock < ActiveRecord::Base
|
|||
# revokes the block, allowing the user to use the API again. the argument
|
||||
# is the user object who is revoking the ban.
|
||||
def revoke!(revoker)
|
||||
update_attributes(
|
||||
update(
|
||||
:ends_at => Time.now.getutc,
|
||||
:revoker_id => revoker.id,
|
||||
:needs_view => false
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require "yaml"
|
||||
|
||||
if File.exist?(piwik_file = File.expand_path("../../piwik.yml", __FILE__))
|
||||
if File.exist?(piwik_file = File.expand_path("../piwik.yml", __dir__))
|
||||
PIWIK = YAML.load_file(piwik_file)
|
||||
end
|
||||
|
|
|
@ -514,9 +514,9 @@ module OSM
|
|||
country = "GB" if country == "UK"
|
||||
end
|
||||
|
||||
return country
|
||||
country
|
||||
rescue StandardError
|
||||
return nil
|
||||
nil
|
||||
end
|
||||
|
||||
def self.ip_location(ip_address)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env ruby
|
||||
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
||||
|
||||
APP_PATH = File.expand_path("../../config/application", __FILE__)
|
||||
require File.expand_path("../../config/boot", __FILE__)
|
||||
APP_PATH = File.expand_path("../config/application", __dir__)
|
||||
require File.expand_path("../config/boot", __dir__)
|
||||
require "rails/commands"
|
||||
|
|
|
@ -2,7 +2,7 @@ require "coveralls"
|
|||
Coveralls.wear!("rails")
|
||||
|
||||
ENV["RAILS_ENV"] = "test"
|
||||
require File.expand_path("../../config/environment", __FILE__)
|
||||
require File.expand_path("../config/environment", __dir__)
|
||||
require "rails/test_help"
|
||||
require "webmock/minitest"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue