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,13 +296,13 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def preferred_languages
|
||||
@languages ||= if params[:locale]
|
||||
Locale.list(params[:locale])
|
||||
elsif current_user
|
||||
current_user.preferred_languages
|
||||
else
|
||||
Locale.list(http_accept_language.user_preferred_languages)
|
||||
end
|
||||
@preferred_languages ||= if params[:locale]
|
||||
Locale.list(params[:locale])
|
||||
elsif current_user
|
||||
current_user.preferred_languages
|
||||
else
|
||||
Locale.list(http_accept_language.user_preferred_languages)
|
||||
end
|
||||
end
|
||||
|
||||
helper_method :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
|
||||
|
|
|
@ -10,10 +10,10 @@ class SwfController < ApplicationController
|
|||
# ====================================================================
|
||||
# Public methods
|
||||
|
||||
# ---- trackpoints compile SWF of trackpoints
|
||||
# ---- trackpoints compile SWF of trackpoints
|
||||
|
||||
def trackpoints
|
||||
# - Initialise
|
||||
# - Initialise
|
||||
|
||||
baselong = params["baselong"].to_f
|
||||
basey = params["basey"].to_f
|
||||
|
@ -23,7 +23,7 @@ class SwfController < ApplicationController
|
|||
params["xmax"], params["ymax"])
|
||||
start = params["start"].to_i
|
||||
|
||||
# - Begin movie
|
||||
# - Begin movie
|
||||
|
||||
bounds_left = 0
|
||||
bounds_right = 320 * 20
|
||||
|
@ -31,13 +31,13 @@ class SwfController < ApplicationController
|
|||
bounds_top = 240 * 20
|
||||
|
||||
m = ""
|
||||
m += swf_record(9, 255.chr + 155.chr + 155.chr) # Background
|
||||
m += swf_record(9, 255.chr + 155.chr + 155.chr) # Background
|
||||
absx = 0
|
||||
absy = 0
|
||||
xl = yb = 9999999
|
||||
xr = yt = -9999999
|
||||
|
||||
# - Send SQL for GPS tracks
|
||||
# - Send SQL for GPS tracks
|
||||
|
||||
b = ""
|
||||
lasttime = 0
|
||||
|
@ -84,7 +84,7 @@ class SwfController < ApplicationController
|
|||
m += swf_record(2, pack_u16(1) + pack_rect(xl, xr, yb, yt) + r)
|
||||
m += swf_record(4, pack_u16(1) + pack_u16(1))
|
||||
|
||||
# - Create Flash header and write to browser
|
||||
# - Create Flash header and write to browser
|
||||
|
||||
m += swf_record(1, "") # Show frame
|
||||
m += swf_record(0, "") # End
|
||||
|
@ -108,7 +108,7 @@ class SwfController < ApplicationController
|
|||
s += 2.chr # Two line styles
|
||||
s += pack_u16(0) + 0.chr + 255.chr + 255.chr # Width 5, RGB #00FFFF
|
||||
s += pack_u16(0) + 255.chr + 0.chr + 255.chr # Width 5, RGB #FF00FF
|
||||
s += 34.chr # 2 fill, 2 line index bits
|
||||
s += 34.chr # 2 fill, 2 line index bits
|
||||
s
|
||||
end
|
||||
|
||||
|
@ -120,7 +120,7 @@ class SwfController < ApplicationController
|
|||
d = "001001" # Line style change, moveTo
|
||||
l = [length_sb(x), length_sb(y)].max
|
||||
d += format("%05b%0*b%0*b", l, l, x, l, y)
|
||||
d += col # Select line style
|
||||
d += col # Select line style
|
||||
d
|
||||
end
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -38,8 +38,8 @@ class PopulateNodeTagsAndRemove < ActiveRecord::Migration[5.0]
|
|||
create_table :node_tags, :id => false do |t|
|
||||
t.column :id, :bigint, :null => false
|
||||
t.column :version, :bigint, :null => false
|
||||
t.column :k, :string, :default => "", :null => false
|
||||
t.column :v, :string, :default => "", :null => false
|
||||
t.column :k, :string, :default => "", :null => false
|
||||
t.column :v, :string, :default => "", :null => false
|
||||
end
|
||||
|
||||
# now get the data back
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -40,7 +40,7 @@ module Potlatch
|
|||
break if key == ""
|
||||
arr[key] = getvalue(s)
|
||||
end
|
||||
s.getbyte # skip the 9 'end of object' value
|
||||
s.getbyte # skip the 9 'end of object' value
|
||||
arr
|
||||
end
|
||||
|
||||
|
@ -162,11 +162,11 @@ module Potlatch
|
|||
# The Potlatch class is a helper for Potlatch
|
||||
class Potlatch
|
||||
# ----- getpresets
|
||||
# in: none
|
||||
# does: reads tag preset menus, colours, and autocomplete config files
|
||||
# out: [0] presets, [1] presetmenus, [2] presetnames,
|
||||
# [3] colours, [4] casing, [5] areas, [6] autotags
|
||||
# (all hashes)
|
||||
# in: none
|
||||
# does: reads tag preset menus, colours, and autocomplete config files
|
||||
# out: [0] presets, [1] presetmenus, [2] presetnames,
|
||||
# [3] colours, [4] casing, [5] areas, [6] autotags
|
||||
# (all hashes)
|
||||
def self.get_presets
|
||||
Rails.logger.info(" Message: getpresets")
|
||||
|
||||
|
@ -176,7 +176,7 @@ module Potlatch
|
|||
presetnames = { "point" => {}, "way" => {}, "POI" => {} }
|
||||
presettype = ""
|
||||
presetcategory = ""
|
||||
# StringIO.open(txt) do |file|
|
||||
# StringIO.open(txt) do |file|
|
||||
File.open(Rails.root.join("config", "potlatch", "presets.txt")) do |file|
|
||||
file.each_line do |line|
|
||||
t = line.chomp
|
||||
|
|
|
@ -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