]> git.openstreetmap.org Git - rails.git/commitdiff
Fix rubocop warnings
authorTom Hughes <tom@compton.nu>
Mon, 31 Oct 2016 21:24:10 +0000 (21:24 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 31 Oct 2016 21:24:10 +0000 (21:24 +0000)
app/helpers/user_roles_helper.rb
app/models/relation.rb
app/models/user.rb
config/initializers/konacha.rb
lib/bounding_box.rb
lib/classic_pagination/pagination.rb
lib/diff_reader.rb

index b6961cd8b02021715b6f8436bbf293dbf4b28f03..7093a96b2b160dc9d4733d69ab58d74075813082 100644 (file)
@@ -1,6 +1,8 @@
 module UserRolesHelper
   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
 
   def role_icon(user, role)
index ed37d159af3422437bdda4d00ce0319b381a3417..e5e4ec894c8d699ca781e69bc6564b376d8988c5 100644 (file)
@@ -370,7 +370,7 @@ class Relation < ActiveRecord::Base
       # materially change the rest of the relation.
       any_relations =
         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
                          # add all non-relation bounding boxes to the changeset
index 2cdb9404663ae26902506a6a59ab9e4e9ec0f242..e6d7a4e46f31cfbbc3a7f2b3d7a88944ffabd4f2 100644 (file)
@@ -216,8 +216,8 @@ class User < ActiveRecord::Base
   def spam_score
     changeset_score = changesets.size * 50
     trace_score = traces.size * 50
-    diary_entry_score = diary_entries.inject(0) { |a, e| a + e.body.spam_score }
-    diary_comment_score = diary_comments.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) { |acc, elem| acc + elem.body.spam_score }
 
     score = description.spam_score / 4.0
     score += diary_entries.where("created_at > ?", 1.day.ago).count * 10
index f97b19aaf73087f915f8d45fad2f86f031ecabd4..f0145f5e0a29b421b23874bec7c10102ab5c1775 100644 (file)
@@ -1,5 +1,7 @@
-Konacha.configure do |config|
-  require "capybara/poltergeist"
-  config.spec_dir = "test/javascripts"
-  config.driver   = :poltergeist
-end if defined?(Konacha)
+if defined?(Konacha)
+  Konacha.configure do |config|
+    require "capybara/poltergeist"
+    config.spec_dir = "test/javascripts"
+    config.driver   = :poltergeist
+  end
+end
index 9f6c3d9d515184c588f1f8896a39fb7f27253cab..11e831cfe08dd70cc6c214d1244224bc519fb974 100644 (file)
@@ -43,14 +43,22 @@ class BoundingBox
     # 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
     if bbox.complete?
-      @min_lon = [-SCALED_LON_LIMIT,
-                  bbox.min_lon + margin * (min_lon - max_lon)].max if bbox.min_lon < min_lon
-      @min_lat = [-SCALED_LAT_LIMIT,
-                  bbox.min_lat + margin * (min_lat - max_lat)].max if bbox.min_lat < min_lat
-      @max_lon = [+SCALED_LON_LIMIT,
-                  bbox.max_lon + margin * (max_lon - min_lon)].min if bbox.max_lon > max_lon
-      @max_lat = [+SCALED_LAT_LIMIT,
-                  bbox.max_lat + margin * (max_lat - min_lat)].min if bbox.max_lat > max_lat
+      if bbox.min_lon < min_lon
+        @min_lon = [-SCALED_LON_LIMIT,
+                    bbox.min_lon + margin * (min_lon - max_lon)].max
+      end
+      if bbox.min_lat < min_lat
+        @min_lat = [-SCALED_LAT_LIMIT,
+                    bbox.min_lat + margin * (min_lat - max_lat)].max
+      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
     self
   end
index 36653ee02435af468ffa47f4b661f5e7328ef6d2..f12ff095f7ebd3ee0f657879ba9349d133faf22f 100644 (file)
@@ -93,9 +93,10 @@ module ActionController
       valid_options << :actions unless in_action
 
       unknown_option_keys = options.keys - valid_options
-      raise ActionController::ActionControllerError,
-            "Unknown options: #{unknown_option_keys.join(', ')}" unless
-              unknown_option_keys.empty?
+      unless unknown_option_keys.empty?
+        raise ActionController::ActionControllerError,
+              "Unknown options: #{unknown_option_keys.join(', ')}"
+      end
 
       options[:singular_name] ||= ActiveSupport::Inflector.singularize(collection_id.to_s)
       options[:class_name] ||= ActiveSupport::Inflector.camelize(options[:singular_name])
index c6e4780eb7dd16dada98581cd4613edc125078c3..c2e7f18394a8769ec284ecb276d45af329f16477 100644 (file)
@@ -85,8 +85,10 @@ class DiffReader
   def with_model
     with_element do |model_name, _model_attributes|
       model = MODELS[model_name]
-      raise OSM::APIBadUserInput.new("Unexpected element type #{model_name}, " +
-                                     "expected node, way or relation.") if model.nil?
+      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
       # with a document. this means that there's no encoding parameter,
       # which means basically nothing works.