Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
Bump rubocop from 0.86.0 to 0.88.0 (mastodon#14412)
Browse files Browse the repository at this point in the history
* 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](rubocop/rubocop@v0.86.0...v0.88.0)

Signed-off-by: dependabot[bot] <[email protected]>

* Fix for latest RuboCop

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Yamagishi Kazutoshi <[email protected]>
  • Loading branch information
dependabot[bot] and ykzts authored Sep 1, 2020
1 parent 10f1804 commit 8972e5f
Show file tree
Hide file tree
Showing 21 changed files with 203 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
175 changes: 167 additions & 8 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,78 @@ 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
Enabled: false

Metrics/MethodLength:
CountComments: false
Max: 55
Max: 65
Exclude:
- 'lib/mastodon/*_cli.rb'

Metrics/ModuleLength:
CountComments: false
Expand All @@ -67,34 +107,90 @@ 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:
Exclude:
- '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

Expand All @@ -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

Expand All @@ -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': '()'
Expand All @@ -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

Expand All @@ -140,3 +296,6 @@ Style/TrailingCommaInArrayLiteral:

Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: 'comma'

Style/UnpackFirst:
Enabled: false
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/api/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def set_pagination_headers(next_path = nil, prev_path = nil)

def limit_param(default_limit)
return default_limit unless params[:limit]

[params[:limit].to_i.abs, default_limit * 2].min
end

Expand Down
1 change: 0 additions & 1 deletion app/controllers/concerns/challengable_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def require_challenge!
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
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/signature_verification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def verify_signature_strength!
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
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ def render_initial_state
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
4 changes: 2 additions & 2 deletions app/lib/activitypub/linked_data_signature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def verify_account!
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
Expand All @@ -44,7 +44,7 @@ def sign!(creator, sign_with: nil)
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
Expand Down
2 changes: 1 addition & 1 deletion app/lib/entity_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def mention(username, domain)
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 = []

Expand Down
2 changes: 2 additions & 0 deletions app/lib/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def count_tag_nesting(tag)
end
end

# rubocop:disable Metrics/BlockNesting
def encode_custom_emojis(html, emojis, animate = false)
return html if emojis.empty?

Expand Down Expand Up @@ -189,6 +190,7 @@ def encode_custom_emojis(html, emojis, animate = false)

html
end
# rubocop:enable Metrics/BlockNesting

def rewrite(text, entities)
text = text.to_s
Expand Down
Loading

0 comments on commit 8972e5f

Please sign in to comment.