]> cat aescling's git repositories - mastodon.git/commitdiff
Fix rubocop warning (#14288)
authorabcang <abcang1015@gmail.com>
Tue, 14 Jul 2020 17:05:07 +0000 (02:05 +0900)
committerGitHub <noreply@github.com>
Tue, 14 Jul 2020 17:05:07 +0000 (19:05 +0200)
* Fix rubocop warning

* use limit variable

* use ContextCreatingMethods option

.rubocop.yml
app/controllers/auth/sessions_controller.rb
app/controllers/tags_controller.rb
app/lib/activitypub/activity/create.rb
app/lib/proof_provider/keybase/config_serializer.rb
app/lib/request.rb
app/lib/settings/scoped_settings.rb
app/models/concerns/omniauthable.rb

index 3a11f700092a0de18a136697cb7abc49006bdad0..25e0fa940b719fe66c416f9ac2445521a2df9eae 100644 (file)
@@ -28,6 +28,10 @@ Layout/EmptyLineAfterMagicComment:
 Layout/SpaceInsideHashLiteralBraces:
   EnforcedStyle: space
 
+Lint/UselessAccessModifier:
+  ContextCreatingMethods:
+    - class_methods
+
 Metrics/AbcSize:
   Max: 100
 
index 2415e2ef322b2daa2cc599ed08970dbf6a211539..1fd755334b359e3bfdaeaf018636ace9100e69c8 100644 (file)
@@ -46,6 +46,7 @@ class Auth::SessionsController < Devise::SessionsController
       user   = User.authenticate_with_ldap(user_params) if Devise.ldap_authentication
       user ||= User.authenticate_with_pam(user_params) if Devise.pam_authentication
       user ||= User.find_for_authentication(email: user_params[:email])
+      user
     end
   end
 
index 234a0c41174994e82c314e6afb180cdbb7e086a6..6426a7d695260faad5db9f5907a8642f321eab64 100644 (file)
@@ -27,7 +27,7 @@ class TagsController < ApplicationController
         expires_in 0, public: true
 
         limit     = params[:limit].present? ? [params[:limit].to_i, PAGE_SIZE_MAX].min : PAGE_SIZE
-        @statuses = HashtagQueryService.new.call(@tag, filter_params, nil, @local).limit(PAGE_SIZE)
+        @statuses = HashtagQueryService.new.call(@tag, filter_params, nil, @local).limit(limit)
         @statuses = cache_collection(@statuses, Status)
 
         render xml: RSS::TagSerializer.render(@tag, @statuses)
index d3d460551621a71dd370ae04b5fb4f4d8df79c0b..e81452e3cae83e398af501225db538be170163b4 100644 (file)
@@ -45,7 +45,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
 
     RedisLock.acquire(lock_options) do |lock|
       if lock.acquired?
-        return if delete_arrived_first?(object_uri) || poll_vote?
+        return if delete_arrived_first?(object_uri) || poll_vote? # rubocop:disable Lint/NonLocalExitFromIterator
 
         @status = find_existing_status
 
index fbce7aeee8c65147c437f775b989d026b3fa4ce5..c6c364d316f38f46d7f749219f22bfb1600c803c 100644 (file)
@@ -55,7 +55,7 @@ class ProofProvider::Keybase::ConfigSerializer < ActiveModel::Serializer
   end
 
   def profile_url
-    CGI.unescape(short_account_url('%{username}')) # rubocop:disable Style/FormatStringToken
+    CGI.unescape(short_account_url('%{username}'))
   end
 
   def check_url
index 247c32958ac591d153b8aa2603194d3a67802b01..bcba1eebf645c8eaa078e6e2e3e3dbe30df5eb28 100644 (file)
@@ -231,6 +231,7 @@ class Request
             begin
               sock.connect_nonblock(addr_by_socket[sock])
             rescue Errno::EISCONN
+              # Do nothing
             rescue => e
               sock.close
               outer_e = e
index 9ca39510acd3a3ac567de71cd6b60c021946055f..3bec9bd569d0ecc9ee923f18294a3bcf59842f03 100644 (file)
@@ -11,7 +11,7 @@ module Settings
       @object = object
     end
 
-    # rubocop:disable Style/MethodMissing
+    # rubocop:disable Style/MethodMissingSuper
     def method_missing(method, *args)
       method_name = method.to_s
       # set a value for a variable
@@ -24,7 +24,7 @@ module Settings
         self[method_name]
       end
     end
-    # rubocop:enable Style/MethodMissing
+    # rubocop:enable Style/MethodMissingSuper
 
     def respond_to_missing?(*)
       true
@@ -48,7 +48,6 @@ module Settings
       record.update!(value: value)
 
       Rails.cache.write(Setting.cache_key(key, @object), value)
-      value
     end
 
     def [](key)
index 736da6c1ded4cc2e9384a6ea881e0f67c2747763..4ea219537abaa2591f72a44be42f2e763b9268ba 100644 (file)
@@ -57,7 +57,7 @@ module Omniauthable
 
       user = User.new(user_params_from_auth(email, auth))
 
-      user.account.avatar_remote_url = auth.info.image if auth.info.image =~ /\A#{URI.regexp(%w(http https))}\z/
+      user.account.avatar_remote_url = auth.info.image if auth.info.image =~ /\A#{URI::DEFAULT_PARSER.make_regexp(%w(http https))}\z/
       user.skip_confirmation!
       user.save!
       user