From af2396433a3999fee1b671c359d9c79776424477 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Sep 2020 02:54:34 +0200 Subject: Bump oj from 3.10.12 to 3.10.13 (#14704) Bumps [oj](https://github.com/ohler55/oj) from 3.10.12 to 3.10.13. - [Release notes](https://github.com/ohler55/oj/releases) - [Changelog](https://github.com/ohler55/oj/blob/develop/CHANGELOG.md) - [Commits](https://github.com/ohler55/oj/compare/v3.10.12...v3.10.13) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'Gemfile.lock') diff --git a/Gemfile.lock b/Gemfile.lock index bf47faabe..e53cb9bef 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -99,7 +99,6 @@ GEM coderay (>= 1.0.0) erubi (>= 1.0.0) rack (>= 0.9.0) - bigdecimal (2.0.0) bindata (2.4.8) binding_of_caller (0.8.0) debug_inspector (>= 0.0.1) @@ -374,8 +373,7 @@ GEM concurrent-ruby (~> 1.0, >= 1.0.2) sidekiq (>= 3.5) statsd-ruby (~> 1.4, >= 1.4.0) - oj (3.10.12) - bigdecimal (>= 1.0, < 3) + oj (3.10.13) omniauth (1.9.1) hashie (>= 3.4.6) rack (>= 1.6.2, < 3) -- cgit From 65d78d4f947b94e70a1c4037606174accc24bc66 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Sep 2020 02:55:16 +0200 Subject: Bump parallel_tests from 3.1.0 to 3.2.0 (#14702) Bumps [parallel_tests](https://github.com/grosser/parallel_tests) from 3.1.0 to 3.2.0. - [Release notes](https://github.com/grosser/parallel_tests/releases) - [Changelog](https://github.com/grosser/parallel_tests/blob/master/CHANGELOG.md) - [Commits](https://github.com/grosser/parallel_tests/compare/v3.1.0...v3.2.0) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Gemfile.lock') diff --git a/Gemfile b/Gemfile index 464a3c358..00370745e 100644 --- a/Gemfile +++ b/Gemfile @@ -127,7 +127,7 @@ group :test do gem 'rspec-sidekiq', '~> 3.1' gem 'simplecov', '~> 0.19', require: false gem 'webmock', '~> 3.8' - gem 'parallel_tests', '~> 3.1' + gem 'parallel_tests', '~> 3.2' gem 'rspec_junit_formatter', '~> 0.4' end diff --git a/Gemfile.lock b/Gemfile.lock index e53cb9bef..a549b2713 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -398,7 +398,7 @@ GEM av (~> 0.9.0) paperclip (>= 2.5.2) parallel (1.19.2) - parallel_tests (3.1.0) + parallel_tests (3.2.0) parallel parser (2.7.1.4) ast (~> 2.4.1) @@ -751,7 +751,7 @@ DEPENDENCIES paperclip (~> 6.0) paperclip-av-transcoder (~> 0.6) parallel (~> 1.19) - parallel_tests (~> 3.1) + parallel_tests (~> 3.2) parslet pg (~> 1.2) pghero (~> 2.7) -- cgit From 0f568f8431290c6cd360638b846d6f76daa0beea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Sep 2020 02:55:48 +0200 Subject: Bump loofah from 2.6.0 to 2.7.0 (#14701) Bumps [loofah](https://github.com/flavorjones/loofah) from 2.6.0 to 2.7.0. - [Release notes](https://github.com/flavorjones/loofah/releases) - [Changelog](https://github.com/flavorjones/loofah/blob/master/CHANGELOG.md) - [Commits](https://github.com/flavorjones/loofah/compare/v2.6.0...v2.7.0) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Gemfile.lock') diff --git a/Gemfile.lock b/Gemfile.lock index a549b2713..638d3d5aa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -333,7 +333,7 @@ GEM activesupport (>= 4) railties (>= 4) request_store (~> 1.0) - loofah (2.6.0) + loofah (2.7.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) -- cgit From 476f7e8248eb7bddcf6a0ad035a84d72b918b836 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Sep 2020 02:56:08 +0200 Subject: Bump microformats from 4.2.0 to 4.2.1 (#14699) Bumps [microformats](https://github.com/microformats/microformats-ruby) from 4.2.0 to 4.2.1. - [Release notes](https://github.com/microformats/microformats-ruby/releases) - [Commits](https://github.com/microformats/microformats-ruby/compare/v4.2.0...v4.2.1) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Gemfile.lock') diff --git a/Gemfile.lock b/Gemfile.lock index 638d3d5aa..79117cf6c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -346,7 +346,7 @@ GEM redis (>= 3.0.5) memory_profiler (0.9.14) method_source (1.0.0) - microformats (4.2.0) + microformats (4.2.1) json (~> 2.2) nokogiri (~> 1.10) mime-types (3.3.1) -- cgit From 581c27510e369af901c6b5723271445cd9cf11f0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Sep 2020 02:56:32 +0200 Subject: Bump aws-sdk-core from 3.104.4 to 3.105.0 (#14694) Bumps [aws-sdk-core](https://github.com/aws/aws-sdk-ruby) from 3.104.4 to 3.105.0. - [Release notes](https://github.com/aws/aws-sdk-ruby/releases) - [Changelog](https://github.com/aws/aws-sdk-ruby/blob/master/gems/aws-sdk-core/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-ruby/commits) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Gemfile.lock') diff --git a/Gemfile.lock b/Gemfile.lock index 79117cf6c..b182971a6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -79,8 +79,8 @@ GEM cocaine (~> 0.5.3) awrence (1.1.1) aws-eventstream (1.1.0) - aws-partitions (1.358.0) - aws-sdk-core (3.104.4) + aws-partitions (1.362.0) + aws-sdk-core (3.105.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.239.0) aws-sigv4 (~> 1.1) -- cgit From e3b4d3179ac7945491500935f4e3c586f2e7abbc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Sep 2020 02:56:53 +0200 Subject: Bump aws-sdk-s3 from 1.78.0 to 1.79.1 (#14691) Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.78.0 to 1.79.1. - [Release notes](https://github.com/aws/aws-sdk-ruby/releases) - [Changelog](https://github.com/aws/aws-sdk-ruby/blob/master/gems/aws-sdk-s3/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-ruby/commits) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- Gemfile.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'Gemfile.lock') diff --git a/Gemfile b/Gemfile index 00370745e..3f53e3f63 100644 --- a/Gemfile +++ b/Gemfile @@ -20,7 +20,7 @@ gem 'makara', '~> 0.4' gem 'pghero', '~> 2.7' gem 'dotenv-rails', '~> 2.7' -gem 'aws-sdk-s3', '~> 1.78', require: false +gem 'aws-sdk-s3', '~> 1.79', require: false gem 'fog-core', '<= 2.1.0' gem 'fog-openstack', '~> 0.3', require: false gem 'paperclip', '~> 6.0' diff --git a/Gemfile.lock b/Gemfile.lock index b182971a6..36d4b0239 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -85,10 +85,10 @@ GEM aws-partitions (~> 1, >= 1.239.0) aws-sigv4 (~> 1.1) jmespath (~> 1.0) - aws-sdk-kms (1.36.0) + aws-sdk-kms (1.37.0) aws-sdk-core (~> 3, >= 3.99.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.78.0) + aws-sdk-s3 (1.79.1) aws-sdk-core (~> 3, >= 3.104.3) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.1) @@ -680,7 +680,7 @@ DEPENDENCIES active_record_query_trace (~> 1.7) addressable (~> 2.7) annotate (~> 3.1) - aws-sdk-s3 (~> 1.78) + aws-sdk-s3 (~> 1.79) better_errors (~> 2.7) binding_of_caller (~> 0.7) blurhash (~> 0.1) -- cgit From 5c87891ea36648955db27529b57a35b49dac1fbd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Sep 2020 02:57:12 +0200 Subject: Bump hamlit from 2.11.0 to 2.11.1 (#14689) Bumps [hamlit](https://github.com/k0kubun/hamlit) from 2.11.0 to 2.11.1. - [Release notes](https://github.com/k0kubun/hamlit/releases) - [Changelog](https://github.com/k0kubun/hamlit/blob/master/CHANGELOG.md) - [Commits](https://github.com/k0kubun/hamlit/compare/v2.11.0...v2.11.1) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Gemfile.lock') diff --git a/Gemfile.lock b/Gemfile.lock index 36d4b0239..524b435a9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -246,7 +246,7 @@ GEM http (~> 4.0) nokogiri (~> 1.8) oj (~> 3.0) - hamlit (2.11.0) + hamlit (2.11.1) temple (>= 0.8.2) thor tilt -- cgit From 10f180417e137e469eac3e7b11de90aa9edcaf13 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Sep 2020 02:58:51 +0200 Subject: Bump aws-partitions from 1.362.0 to 1.363.0 (#14713) Bumps [aws-partitions](https://github.com/aws/aws-sdk-ruby) from 1.362.0 to 1.363.0. - [Release notes](https://github.com/aws/aws-sdk-ruby/releases) - [Changelog](https://github.com/aws/aws-sdk-ruby/blob/master/gems/aws-partitions/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-ruby/commits) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Gemfile.lock') diff --git a/Gemfile.lock b/Gemfile.lock index 524b435a9..4157e1269 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -79,7 +79,7 @@ GEM cocaine (~> 0.5.3) awrence (1.1.1) aws-eventstream (1.1.0) - aws-partitions (1.362.0) + aws-partitions (1.363.0) aws-sdk-core (3.105.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.239.0) -- cgit 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 --- .codeclimate.yml | 2 +- .rubocop.yml | 175 ++++++++++++++++++++- Gemfile | 2 +- Gemfile.lock | 8 +- 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 +- lib/mastodon/redis_config.rb | 2 +- lib/mastodon/version.rb | 6 +- lib/paperclip/color_extractor.rb | 4 +- 21 files changed, 203 insertions(+), 32 deletions(-) (limited to 'Gemfile.lock') diff --git a/.codeclimate.yml b/.codeclimate.yml index b4ec9400e..9c9b4517a 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -30,7 +30,7 @@ plugins: channel: eslint-7 rubocop: enabled: true - channel: rubocop-0-82 + channel: rubocop-0-88 sass-lint: enabled: true exclude_patterns: diff --git a/.rubocop.yml b/.rubocop.yml index 25e0fa940..14728bf0e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -25,30 +25,68 @@ Layout/AccessModifierIndentation: Layout/EmptyLineAfterMagicComment: Enabled: false +Layout/EmptyLineAfterGuardClause: + Enabled: false + +Layout/EmptyLinesAroundAttributeAccessor: + Enabled: true + +Layout/HashAlignment: + Enabled: false + # EnforcedHashRocketStyle: table + # EnforcedColonStyle: table + +Layout/SpaceAroundMethodCallOperator: + Enabled: true + Layout/SpaceInsideHashLiteralBraces: EnforcedStyle: space +Lint/DeprecatedOpenSSLConstant: + Enabled: true + +Lint/DuplicateElsifCondition: + Enabled: true + +Lint/MixedRegexpCaptureTypes: + Enabled: true + +Lint/RaiseException: + Enabled: true + +Lint/StructNewOverride: + Enabled: true + Lint/UselessAccessModifier: ContextCreatingMethods: - class_methods Metrics/AbcSize: Max: 100 + Exclude: + - 'lib/mastodon/*_cli.rb' Metrics/BlockLength: - Max: 35 + Max: 55 Exclude: - 'lib/tasks/**/*' + - 'lib/mastodon/*_cli.rb' Metrics/BlockNesting: Max: 3 + Exclude: + - 'lib/mastodon/*_cli.rb' Metrics/ClassLength: CountComments: false - Max: 300 + Max: 400 + Exclude: + - 'lib/mastodon/*_cli.rb' Metrics/CyclomaticComplexity: Max: 25 + Exclude: + - 'lib/mastodon/*_cli.rb' Layout/LineLength: AllowURI: true @@ -56,7 +94,9 @@ Layout/LineLength: Metrics/MethodLength: CountComments: false - Max: 55 + Max: 65 + Exclude: + - 'lib/mastodon/*_cli.rb' Metrics/ModuleLength: CountComments: false @@ -67,24 +107,29 @@ Metrics/ParameterLists: CountKeywordArgs: true Metrics/PerceivedComplexity: - Max: 20 + Max: 25 Naming/MemoizedInstanceVariableName: Enabled: false +Naming/MethodParameterName: + Enabled: true + Rails: Enabled: true -Rails/EnumHash: +Rails/ApplicationController: Enabled: false + Exclude: + - 'app/controllers/well_known/**/*.rb' -Rails/HasAndBelongsToMany: +Rails/BelongsTo: Enabled: false -Rails/SkipsModelValidations: +Rails/ContentTag: Enabled: false -Rails/HttpStatus: +Rails/EnumHash: Enabled: false Rails/Exit: @@ -92,9 +137,60 @@ Rails/Exit: - 'lib/mastodon/*' - 'lib/cli.rb' +Rails/FilePath: + Enabled: false + +Rails/HasAndBelongsToMany: + Enabled: false + +Rails/HasManyOrHasOneDependent: + Enabled: false + Rails/HelperInstanceVariable: Enabled: false +Rails/HttpStatus: + Enabled: false + +Rails/IndexBy: + Enabled: false + +Rails/InverseOf: + Enabled: false + +Rails/LexicallyScopedActionFilter: + Enabled: false + +Rails/OutputSafety: + Enabled: true + +Rails/RakeEnvironment: + Enabled: false + +Rails/RedundantForeignKey: + Enabled: false + +Rails/SkipsModelValidations: + Enabled: false + +Rails/UniqueValidationWithoutIndex: + Enabled: false + +Style/AccessorGrouping: + Enabled: true + +Style/AccessModifierDeclarations: + Enabled: false + +Style/ArrayCoercion: + Enabled: true + +Style/BisectedAttrAccessor: + Enabled: true + +Style/CaseLikeIf: + Enabled: false + Style/ClassAndModuleChildren: Enabled: false @@ -109,6 +205,15 @@ Style/Documentation: Style/DoubleNegation: Enabled: true +Style/ExpandPathArguments: + Enabled: false + +Style/ExponentialNotation: + Enabled: true + +Style/FormatString: + Enabled: false + Style/FormatStringToken: Enabled: false @@ -118,9 +223,33 @@ Style/FrozenStringLiteralComment: Style/GuardClause: Enabled: false +Style/HashAsLastArrayItem: + Enabled: false + +Style/HashEachMethods: + Enabled: true + +Style/HashLikeCase: + Enabled: true + +Style/HashTransformKeys: + Enabled: true + +Style/HashTransformValues: + Enabled: false + +Style/IfUnlessModifier: + Enabled: false + +Style/InverseMethods: + Enabled: false + Style/Lambda: Enabled: false +Style/MutableConstant: + Enabled: false + Style/PercentLiteralDelimiters: PreferredDelimiters: '%i': '()' @@ -129,9 +258,36 @@ Style/PercentLiteralDelimiters: Style/PerlBackrefs: AutoCorrect: false +Style/RedundantAssignment: + Enabled: false + +Style/RedundantFetchBlock: + Enabled: true + +Style/RedundantFileExtensionInRequire: + Enabled: true + +Style/RedundantRegexpCharacterClass: + Enabled: false + +Style/RedundantRegexpEscape: + Enabled: false + +Style/RedundantReturn: + Enabled: true + Style/RegexpLiteral: Enabled: false +Style/RescueStandardError: + Enabled: false + +Style/SignalException: + Enabled: false + +Style/SlicingWithRange: + Enabled: true + Style/SymbolArray: Enabled: false @@ -140,3 +296,6 @@ Style/TrailingCommaInArrayLiteral: Style/TrailingCommaInHashLiteral: EnforcedStyleForMultiline: 'comma' + +Style/UnpackFirst: + Enabled: false diff --git a/Gemfile b/Gemfile index 3f53e3f63..6a683d586 100644 --- a/Gemfile +++ b/Gemfile @@ -140,7 +140,7 @@ group :development do gem 'letter_opener', '~> 1.7' gem 'letter_opener_web', '~> 1.4' gem 'memory_profiler' - gem 'rubocop', '~> 0.86', require: false + gem 'rubocop', '~> 0.88', require: false gem 'rubocop-rails', '~> 2.6', require: false gem 'brakeman', '~> 4.9', require: false gem 'bundler-audit', '~> 0.7', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 4157e1269..1e289c30a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -535,13 +535,13 @@ GEM rspec-support (3.9.3) rspec_junit_formatter (0.4.1) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (0.86.0) + rubocop (0.88.0) parallel (~> 1.10) - parser (>= 2.7.0.1) + parser (>= 2.7.1.1) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.7) rexml - rubocop-ast (>= 0.0.3, < 1.0) + rubocop-ast (>= 0.1.0, < 1.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 2.0) rubocop-ast (0.3.0) @@ -778,7 +778,7 @@ DEPENDENCIES rspec-rails (~> 4.0) rspec-sidekiq (~> 3.1) rspec_junit_formatter (~> 0.4) - rubocop (~> 0.86) + rubocop (~> 0.88) rubocop-rails (~> 2.6) ruby-progressbar (~> 1.10) sanitize (~> 5.2) 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 diff --git a/lib/mastodon/redis_config.rb b/lib/mastodon/redis_config.rb index e9db9122f..c3c8ff800 100644 --- a/lib/mastodon/redis_config.rb +++ b/lib/mastodon/redis_config.rb @@ -23,7 +23,7 @@ end setup_redis_env_url setup_redis_env_url(:cache, false) -namespace = ENV.fetch('REDIS_NAMESPACE') { nil } +namespace = ENV.fetch('REDIS_NAMESPACE', nil) cache_namespace = namespace ? namespace + '_cache' : 'cache' REDIS_CACHE_PARAMS = { diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb index 7aa6cb2c7..7b940d1f8 100644 --- a/lib/mastodon/version.rb +++ b/lib/mastodon/version.rb @@ -33,16 +33,16 @@ module Mastodon end def repository - ENV.fetch('GITHUB_REPOSITORY') { 'tootsuite/mastodon' } + ENV.fetch('GITHUB_REPOSITORY', 'tootsuite/mastodon') end def source_base_url - ENV.fetch('SOURCE_BASE_URL') { "https://github.com/#{repository}" } + ENV.fetch('SOURCE_BASE_URL', "https://github.com/#{repository}") end # specify git tag or commit hash here def source_tag - ENV.fetch('SOURCE_TAG') { nil } + ENV.fetch('SOURCE_TAG', nil) end def source_url diff --git a/lib/paperclip/color_extractor.rb b/lib/paperclip/color_extractor.rb index c8bb771a0..f850dc067 100644 --- a/lib/paperclip/color_extractor.rb +++ b/lib/paperclip/color_extractor.rb @@ -89,7 +89,7 @@ module Paperclip end end - # rubocop:disable Style/MethodParameterName + # rubocop:disable Naming/MethodParameterName def rgb_to_hsl(r, g, b) r /= 255.0 g /= 255.0 @@ -156,7 +156,7 @@ module Paperclip [(r * 255).round, (g * 255).round, (b * 255).round] end - # rubocop:enable Style/MethodParameterName + # rubocop:enable Naming/MethodParameterName def lighten_or_darken(color, by) hue, saturation, light = rgb_to_hsl(color.r, color.g, color.b) -- cgit