From 8972e5f7f643c7a851de68b131b5b49844818ec5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Sep 2020 03:04:00 +0200 Subject: Bump rubocop from 0.86.0 to 0.88.0 (#14412) * Bump rubocop from 0.86.0 to 0.88.0 Bumps [rubocop](https://github.com/rubocop-hq/rubocop) from 0.86.0 to 0.88.0. - [Release notes](https://github.com/rubocop-hq/rubocop/releases) - [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop-hq/rubocop/compare/v0.86.0...v0.88.0) Signed-off-by: dependabot[bot] * Fix for latest RuboCop Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Yamagishi Kazutoshi --- app/controllers/api/base_controller.rb | 1 + app/controllers/concerns/challengable_concern.rb | 1 - app/controllers/concerns/signature_verification.rb | 2 +- app/helpers/application_helper.rb | 2 ++ app/lib/activitypub/linked_data_signature.rb | 4 ++-- app/lib/entity_cache.rb | 2 +- app/lib/formatter.rb | 2 ++ app/lib/request.rb | 2 +- app/lib/sidekiq_error_handler.rb | 2 ++ app/models/preview_card.rb | 2 ++ app/models/user.rb | 8 ++++---- app/services/fetch_link_card_service.rb | 2 ++ app/services/notify_service.rb | 2 ++ app/services/update_account_service.rb | 4 ++-- 14 files changed, 24 insertions(+), 12 deletions(-) (limited to 'app') diff --git a/app/controllers/api/base_controller.rb b/app/controllers/api/base_controller.rb index 045e7dd26..467225547 100644 --- a/app/controllers/api/base_controller.rb +++ b/app/controllers/api/base_controller.rb @@ -71,6 +71,7 @@ class Api::BaseController < ApplicationController def limit_param(default_limit) return default_limit unless params[:limit] + [params[:limit].to_i.abs, default_limit * 2].min end diff --git a/app/controllers/concerns/challengable_concern.rb b/app/controllers/concerns/challengable_concern.rb index b29d90b3c..2995a25e0 100644 --- a/app/controllers/concerns/challengable_concern.rb +++ b/app/controllers/concerns/challengable_concern.rb @@ -32,7 +32,6 @@ module ChallengableConcern if params.key?(:form_challenge) if challenge_passed? session[:challenge_passed_at] = Time.now.utc - return else flash.now[:alert] = I18n.t('challenge.invalid_password') render_challenge diff --git a/app/controllers/concerns/signature_verification.rb b/app/controllers/concerns/signature_verification.rb index 18f549de9..f69c62ec2 100644 --- a/app/controllers/concerns/signature_verification.rb +++ b/app/controllers/concerns/signature_verification.rb @@ -131,7 +131,7 @@ module SignatureVerification end def verify_signature(account, signature, compare_signed_string) - if account.keypair.public_key.verify(OpenSSL::Digest::SHA256.new, signature, compare_signed_string) + if account.keypair.public_key.verify(OpenSSL::Digest.new('SHA256'), signature, compare_signed_string) @signed_request_account = account @signed_request_account end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 716df0bac..5512a9543 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -162,6 +162,8 @@ module ApplicationHelper end json = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(state_params), serializer: InitialStateSerializer).to_json + # rubocop:disable Rails/OutputSafety content_tag(:script, json_escape(json).html_safe, id: 'initial-state', type: 'application/json') + # rubocop:enable Rails/OutputSafety end end diff --git a/app/lib/activitypub/linked_data_signature.rb b/app/lib/activitypub/linked_data_signature.rb index f52a8f406..e853a970e 100644 --- a/app/lib/activitypub/linked_data_signature.rb +++ b/app/lib/activitypub/linked_data_signature.rb @@ -27,7 +27,7 @@ class ActivityPub::LinkedDataSignature document_hash = hash(@json.without('signature')) to_be_verified = options_hash + document_hash - if creator.keypair.public_key.verify(OpenSSL::Digest::SHA256.new, Base64.decode64(signature), to_be_verified) + if creator.keypair.public_key.verify(OpenSSL::Digest.new('SHA256'), Base64.decode64(signature), to_be_verified) creator end end @@ -44,7 +44,7 @@ class ActivityPub::LinkedDataSignature to_be_signed = options_hash + document_hash keypair = sign_with.present? ? OpenSSL::PKey::RSA.new(sign_with) : creator.keypair - signature = Base64.strict_encode64(keypair.sign(OpenSSL::Digest::SHA256.new, to_be_signed)) + signature = Base64.strict_encode64(keypair.sign(OpenSSL::Digest.new('SHA256'), to_be_signed)) @json.merge('signature' => options.merge('signatureValue' => signature)) end diff --git a/app/lib/entity_cache.rb b/app/lib/entity_cache.rb index afdbd70f2..89cbf8d2c 100644 --- a/app/lib/entity_cache.rb +++ b/app/lib/entity_cache.rb @@ -16,7 +16,7 @@ class EntityCache end def emoji(shortcodes, domain) - shortcodes = [shortcodes] unless shortcodes.is_a?(Array) + shortcodes = Array(shortcodes) cached = Rails.cache.read_multi(*shortcodes.map { |shortcode| to_key(:emoji, shortcode, domain) }) uncached_ids = [] diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb index e6f5d7a63..7f217ae9f 100644 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@ -135,6 +135,7 @@ class Formatter end end + # rubocop:disable Metrics/BlockNesting def encode_custom_emojis(html, emojis, animate = false) return html if emojis.empty? @@ -189,6 +190,7 @@ class Formatter html end + # rubocop:enable Metrics/BlockNesting def rewrite(text, entities) text = text.to_s diff --git a/app/lib/request.rb b/app/lib/request.rb index bcba1eebf..89fbeaf95 100644 --- a/app/lib/request.rb +++ b/app/lib/request.rb @@ -114,7 +114,7 @@ class Request def signature algorithm = 'rsa-sha256' - signature = Base64.strict_encode64(@keypair.sign(OpenSSL::Digest::SHA256.new, signed_string)) + signature = Base64.strict_encode64(@keypair.sign(OpenSSL::Digest.new('SHA256'), signed_string)) "keyId=\"#{key_id}\",algorithm=\"#{algorithm}\",headers=\"#{signed_headers.keys.join(' ').downcase}\",signature=\"#{signature}\"" end diff --git a/app/lib/sidekiq_error_handler.rb b/app/lib/sidekiq_error_handler.rb index b07817d45..ab555b1be 100644 --- a/app/lib/sidekiq_error_handler.rb +++ b/app/lib/sidekiq_error_handler.rb @@ -17,8 +17,10 @@ class SidekiqErrorHandler private + # rubocop:disable Naming/MethodParameterName def limit_backtrace_and_raise(e) e.set_backtrace(e.backtrace.first(BACKTRACE_LIMIT)) raise e end + # rubocop:enable Naming/MethodParameterName end diff --git a/app/models/preview_card.rb b/app/models/preview_card.rb index 235928260..a6ec839f8 100644 --- a/app/models/preview_card.rb +++ b/app/models/preview_card.rb @@ -72,6 +72,7 @@ class PreviewCard < ApplicationRecord class << self private + # rubocop:disable Naming/MethodParameterName def image_styles(f) styles = { original: { @@ -85,6 +86,7 @@ class PreviewCard < ApplicationRecord styles[:original][:format] = 'jpg' if f.instance.image_content_type == 'image/gif' styles end + # rubocop:enable Naming/MethodParameterName end private diff --git a/app/models/user.rb b/app/models/user.rb index 7e3b37475..dbee08988 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -253,16 +253,16 @@ class User < ApplicationRecord @shows_application ||= settings.show_application end + # rubocop:disable Naming/MethodParameterName def token_for_app(a) return nil if a.nil? || a.owner != self - Doorkeeper::AccessToken - .find_or_create_by(application_id: a.id, resource_owner_id: id) do |t| - + Doorkeeper::AccessToken.find_or_create_by(application_id: a.id, resource_owner_id: id) do |t| t.scopes = a.scopes t.expires_in = Doorkeeper.configuration.access_token_expires_in t.use_refresh_token = Doorkeeper.configuration.refresh_token_enabled? end end + # rubocop:enable Naming/MethodParameterName def activate_session(request) session_activations.activate(session_id: SecureRandom.hex, @@ -413,7 +413,7 @@ class User < ApplicationRecord end def notify_staff_about_pending_account! - User.staff.includes(:account).each do |u| + User.staff.includes(:account).find_each do |u| next unless u.allows_pending_account_emails? AdminMailer.new_pending_account(u.account, self).deliver_later end diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb index beab449b2..7efa31054 100644 --- a/app/services/fetch_link_card_service.rb +++ b/app/services/fetch_link_card_service.rb @@ -78,6 +78,7 @@ class FetchLinkCardService < BaseService uri.host.blank? || TagManager.instance.local_url?(uri.to_s) || !%w(http https).include?(uri.scheme) end + # rubocop:disable Naming/MethodParameterName def mention_link?(a) @status.mentions.any? do |mention| a['href'] == ActivityPub::TagManager.instance.url_for(mention.account) @@ -88,6 +89,7 @@ class FetchLinkCardService < BaseService # Avoid links for hashtags and mentions (microformats) a['rel']&.include?('tag') || a['class']&.match?(/u-url|h-card/) || mention_link?(a) end + # rubocop:enable Naming/MethodParameterName def attempt_oembed service = FetchOEmbedService.new diff --git a/app/services/notify_service.rb b/app/services/notify_service.rb index 9364a6ae8..abd676494 100644 --- a/app/services/notify_service.rb +++ b/app/services/notify_service.rb @@ -13,7 +13,9 @@ class NotifyService < BaseService push_to_conversation! if direct_message? send_email! if email_enabled? rescue ActiveRecord::RecordInvalid + # rubocop:disable Style/RedundantReturn return + # rubocop:enable Style/RedundantReturn end private diff --git a/app/services/update_account_service.rb b/app/services/update_account_service.rb index 666db5c71..77f794e17 100644 --- a/app/services/update_account_service.rb +++ b/app/services/update_account_service.rb @@ -12,8 +12,8 @@ class UpdateAccountService < BaseService check_links(account) process_hashtags(account) end - rescue Mastodon::DimensionsValidationError, Mastodon::StreamValidationError => de - account.errors.add(:avatar, de.message) + rescue Mastodon::DimensionsValidationError, Mastodon::StreamValidationError => e + account.errors.add(:avatar, e.message) false end -- cgit