Fix rubocop warnings

This commit is contained in:
Tom Hughes 2016-10-31 21:24:10 +00:00
parent 96b1bff9fb
commit 282ff4936c
7 changed files with 37 additions and 22 deletions

View file

@ -1,6 +1,8 @@
module UserRolesHelper module UserRolesHelper
def role_icons(user) def role_icons(user)
UserRole::ALL_ROLES.reduce("".html_safe) { |a, e| a + " " + role_icon(user, e) } UserRole::ALL_ROLES.reduce("".html_safe) do |acc, elem|
acc + " " + role_icon(user, elem)
end
end end
def role_icon(user, role) def role_icon(user, role)

View file

@ -370,7 +370,7 @@ class Relation < ActiveRecord::Base
# materially change the rest of the relation. # materially change the rest of the relation.
any_relations = any_relations =
changed_members.collect { |_id, type| type == "relation" } changed_members.collect { |_id, type| type == "relation" }
.inject(false) { |a, e| a || e } .inject(false) { |acc, elem| acc || elem }
update_members = if tags_changed || any_relations update_members = if tags_changed || any_relations
# add all non-relation bounding boxes to the changeset # add all non-relation bounding boxes to the changeset

View file

@ -216,8 +216,8 @@ class User < ActiveRecord::Base
def spam_score def spam_score
changeset_score = changesets.size * 50 changeset_score = changesets.size * 50
trace_score = traces.size * 50 trace_score = traces.size * 50
diary_entry_score = diary_entries.inject(0) { |a, e| a + e.body.spam_score } diary_entry_score = diary_entries.inject(0) { |acc, elem| acc + elem.body.spam_score }
diary_comment_score = diary_comments.inject(0) { |a, e| a + e.body.spam_score } diary_comment_score = diary_comments.inject(0) { |acc, elem| acc + elem.body.spam_score }
score = description.spam_score / 4.0 score = description.spam_score / 4.0
score += diary_entries.where("created_at > ?", 1.day.ago).count * 10 score += diary_entries.where("created_at > ?", 1.day.ago).count * 10

View file

@ -1,5 +1,7 @@
Konacha.configure do |config| if defined?(Konacha)
require "capybara/poltergeist" Konacha.configure do |config|
config.spec_dir = "test/javascripts" require "capybara/poltergeist"
config.driver = :poltergeist config.spec_dir = "test/javascripts"
end if defined?(Konacha) config.driver = :poltergeist
end
end

View file

@ -43,14 +43,22 @@ class BoundingBox
# only try to expand the bbox if there is a value for every coordinate # only try to expand the bbox if there is a value for every coordinate
# which there will be from the previous line as long as array does not contain a nil # which there will be from the previous line as long as array does not contain a nil
if bbox.complete? if bbox.complete?
@min_lon = [-SCALED_LON_LIMIT, if bbox.min_lon < min_lon
bbox.min_lon + margin * (min_lon - max_lon)].max if bbox.min_lon < min_lon @min_lon = [-SCALED_LON_LIMIT,
@min_lat = [-SCALED_LAT_LIMIT, bbox.min_lon + margin * (min_lon - max_lon)].max
bbox.min_lat + margin * (min_lat - max_lat)].max if bbox.min_lat < min_lat end
@max_lon = [+SCALED_LON_LIMIT, if bbox.min_lat < min_lat
bbox.max_lon + margin * (max_lon - min_lon)].min if bbox.max_lon > max_lon @min_lat = [-SCALED_LAT_LIMIT,
@max_lat = [+SCALED_LAT_LIMIT, bbox.min_lat + margin * (min_lat - max_lat)].max
bbox.max_lat + margin * (max_lat - min_lat)].min if bbox.max_lat > max_lat end
if bbox.max_lon > max_lon
@max_lon = [+SCALED_LON_LIMIT,
bbox.max_lon + margin * (max_lon - min_lon)].min
end
if bbox.max_lat > max_lat
@max_lat = [+SCALED_LAT_LIMIT,
bbox.max_lat + margin * (max_lat - min_lat)].min
end
end end
self self
end end

View file

@ -93,9 +93,10 @@ module ActionController
valid_options << :actions unless in_action valid_options << :actions unless in_action
unknown_option_keys = options.keys - valid_options unknown_option_keys = options.keys - valid_options
raise ActionController::ActionControllerError, unless unknown_option_keys.empty?
"Unknown options: #{unknown_option_keys.join(', ')}" unless raise ActionController::ActionControllerError,
unknown_option_keys.empty? "Unknown options: #{unknown_option_keys.join(', ')}"
end
options[:singular_name] ||= ActiveSupport::Inflector.singularize(collection_id.to_s) options[:singular_name] ||= ActiveSupport::Inflector.singularize(collection_id.to_s)
options[:class_name] ||= ActiveSupport::Inflector.camelize(options[:singular_name]) options[:class_name] ||= ActiveSupport::Inflector.camelize(options[:singular_name])

View file

@ -85,8 +85,10 @@ class DiffReader
def with_model def with_model
with_element do |model_name, _model_attributes| with_element do |model_name, _model_attributes|
model = MODELS[model_name] model = MODELS[model_name]
raise OSM::APIBadUserInput.new("Unexpected element type #{model_name}, " + if model.nil?
"expected node, way or relation.") if model.nil? raise OSM::APIBadUserInput.new("Unexpected element type #{model_name}, " +
"expected node, way or relation.")
end
# new in libxml-ruby >= 2, expand returns an element not associated # new in libxml-ruby >= 2, expand returns an element not associated
# with a document. this means that there's no encoding parameter, # with a document. this means that there's no encoding parameter,
# which means basically nothing works. # which means basically nothing works.