]> git.openstreetmap.org Git - rails.git/commitdiff
Fix new rubocop warnings
authorTom Hughes <tom@compton.nu>
Tue, 21 May 2024 17:21:56 +0000 (18:21 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 21 May 2024 17:21:56 +0000 (18:21 +0100)
app/controllers/api/changeset_comments_controller.rb
app/controllers/api/changesets_controller.rb
app/controllers/changesets_controller.rb
app/controllers/friendships_controller.rb
app/controllers/messages_controller.rb
app/models/issue.rb
app/models/user.rb

index 756e56dccdfb706d8d6e7c4456683fcc232eb08c..e8d3f4c3a8df2c5dbcc1ae77f864d77057846449 100644 (file)
@@ -105,7 +105,7 @@ module Api
     ##
     # Check if the current user has exceed the rate limit for comments
     def rate_limit_exceeded?
     ##
     # Check if the current user has exceed the rate limit for comments
     def rate_limit_exceeded?
-      recent_comments = current_user.changeset_comments.where("created_at >= ?", Time.now.utc - 1.hour).count
+      recent_comments = current_user.changeset_comments.where(:created_at => Time.now.utc - 1.hour..).count
 
       recent_comments >= current_user.max_changeset_comments_per_hour
     end
 
       recent_comments >= current_user.max_changeset_comments_per_hour
     end
index 616d3fdec9d5360232740ed876d17e4a30bd8bcb..2e21f0c75e10387bbec4126c03c073ffd2fd20c9 100644 (file)
@@ -331,7 +331,7 @@ module Api
         changesets.where("closed_at >= ? and created_at <= ?", from, to)
       else
         # if there is no comma, assume its a lower limit on time
         changesets.where("closed_at >= ? and created_at <= ?", from, to)
       else
         # if there is no comma, assume its a lower limit on time
-        changesets.where("closed_at >= ?", Time.parse(time).utc)
+        changesets.where(:closed_at => Time.parse(time).utc..)
       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.
       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.
index 19ec9c91ef5967a53661817e5f1966c08ae0400e..a5ddaf364fe44ae48dafeaa5f0e9761830e2ee98 100644 (file)
@@ -60,7 +60,7 @@ class ChangesetsController < ApplicationController
         changesets = changesets.where(:user => current_user.nearby)
       end
 
         changesets = changesets.where(:user => current_user.nearby)
       end
 
-      changesets = changesets.where("changesets.id <= ?", @params[:max_id]) if @params[:max_id]
+      changesets = changesets.where(:changesets => { :id => ..@params[:max_id] }) if @params[:max_id]
 
       @changesets = changesets.order("changesets.id DESC").limit(20).preload(:user, :changeset_tags, :comments)
 
 
       @changesets = changesets.order("changesets.id DESC").limit(20).preload(:user, :changeset_tags, :comments)
 
@@ -88,7 +88,7 @@ class ChangesetsController < ApplicationController
     if @changeset.user.active? && @changeset.user.data_public?
       changesets = conditions_nonempty(@changeset.user.changesets)
       @next_by_user = changesets.where("id > ?", @changeset.id).reorder(:id => :asc).first
     if @changeset.user.active? && @changeset.user.data_public?
       changesets = conditions_nonempty(@changeset.user.changesets)
       @next_by_user = changesets.where("id > ?", @changeset.id).reorder(:id => :asc).first
-      @prev_by_user = changesets.where("id < ?", @changeset.id).reorder(:id => :desc).first
+      @prev_by_user = changesets.where(:id => ...@changeset.id).reorder(:id => :desc).first
     end
     render :layout => map_layout
   rescue ActiveRecord::RecordNotFound
     end
     render :layout => map_layout
   rescue ActiveRecord::RecordNotFound
index 7b14f2e820799d3c9f47a2092cbdcbe646d552cc..ab54cbfd1b31f7dcd8fec56d4e23ec9c5c92908e 100644 (file)
@@ -19,7 +19,7 @@ class FriendshipsController < ApplicationController
       friendship.befriendee = @friend
       if current_user.friends_with?(@friend)
         flash[:warning] = t ".already_a_friend", :name => @friend.display_name
       friendship.befriendee = @friend
       if current_user.friends_with?(@friend)
         flash[:warning] = t ".already_a_friend", :name => @friend.display_name
-      elsif current_user.friendships.where("created_at >= ?", Time.now.utc - 1.hour).count >= current_user.max_friends_per_hour
+      elsif current_user.friendships.where(:created_at => Time.now.utc - 1.hour..).count >= current_user.max_friends_per_hour
         flash.now[:error] = t ".limit_exceeded"
       elsif friendship.save
         flash[:notice] = t ".success", :name => @friend.display_name
         flash.now[:error] = t ".limit_exceeded"
       elsif friendship.save
         flash[:notice] = t ".success", :name => @friend.display_name
index 111a31f96ae8cf4b27ce108215368aad5207d78b..adfbd9157992537c18c35b35beb1c67513dbef03 100644 (file)
@@ -42,7 +42,7 @@ class MessagesController < ApplicationController
     @message.sender = current_user
     @message.sent_on = Time.now.utc
 
     @message.sender = current_user
     @message.sent_on = Time.now.utc
 
-    if current_user.sent_messages.where("sent_on >= ?", Time.now.utc - 1.hour).count >= current_user.max_messages_per_hour
+    if current_user.sent_messages.where(:sent_on => Time.now.utc - 1.hour..).count >= current_user.max_messages_per_hour
       flash.now[:error] = t ".limit_exceeded"
       render :action => "new"
     elsif @message.save
       flash.now[:error] = t ".limit_exceeded"
       render :action => "new"
     elsif @message.save
index 54947be303d569e76691e7959b17b7568a7e69ab..a3f82ee40b11881bddf5d5226404f8209668f614 100644 (file)
@@ -50,11 +50,11 @@ class Issue < ApplicationRecord
   scope :visible_to, ->(user) { where(:assigned_role => user.roles.map(&:role)) }
 
   def read_reports
   scope :visible_to, ->(user) { where(:assigned_role => user.roles.map(&:role)) }
 
   def read_reports
-    resolved_at.present? ? reports.where("updated_at < ?", resolved_at) : nil
+    resolved_at.present? ? reports.where(:updated_at => ...resolved_at) : nil
   end
 
   def unread_reports
   end
 
   def unread_reports
-    resolved_at.present? ? reports.where("updated_at >= ?", resolved_at) : reports
+    resolved_at.present? ? reports.where(:updated_at => resolved_at..) : reports
   end
 
   include AASM
   end
 
   include AASM
index 192f52ac4e74ebd440d073d9b8676b0799699c90..e4067a350fe822dac17a0adfd90d0f4b8cb43c63 100644 (file)
@@ -411,7 +411,7 @@ class User < ApplicationRecord
   def max_messages_per_hour
     account_age_in_seconds = Time.now.utc - created_at
     account_age_in_hours = account_age_in_seconds / 3600
   def max_messages_per_hour
     account_age_in_seconds = Time.now.utc - created_at
     account_age_in_hours = account_age_in_seconds / 3600
-    recent_messages = messages.where("sent_on >= ?", Time.now.utc - 3600).count
+    recent_messages = messages.where(:sent_on => Time.now.utc - 3600..).count
     max_messages = account_age_in_hours.ceil + recent_messages - (active_reports * 10)
     max_messages.clamp(0, Settings.max_messages_per_hour)
   end
     max_messages = account_age_in_hours.ceil + recent_messages - (active_reports * 10)
     max_messages.clamp(0, Settings.max_messages_per_hour)
   end
@@ -419,7 +419,7 @@ class User < ApplicationRecord
   def max_friends_per_hour
     account_age_in_seconds = Time.now.utc - created_at
     account_age_in_hours = account_age_in_seconds / 3600
   def max_friends_per_hour
     account_age_in_seconds = Time.now.utc - created_at
     account_age_in_hours = account_age_in_seconds / 3600
-    recent_friends = Friendship.where(:befriendee => self).where("created_at >= ?", Time.now.utc - 3600).count
+    recent_friends = Friendship.where(:befriendee => self).where(:created_at => Time.now.utc - 3600..).count
     max_friends = account_age_in_hours.ceil + recent_friends - (active_reports * 10)
     max_friends.clamp(0, Settings.max_friends_per_hour)
   end
     max_friends = account_age_in_hours.ceil + recent_friends - (active_reports * 10)
     max_friends.clamp(0, Settings.max_friends_per_hour)
   end