Skip to content

Commit

Permalink
Update rubocop version & fix offences (#768)
Browse files Browse the repository at this point in the history
* Update Rubocop to 1.11
* Fix a bunch of offenses
  • Loading branch information
Vitalina-Vakulchyk authored Mar 12, 2021
1 parent 0470c5e commit 891472d
Show file tree
Hide file tree
Showing 77 changed files with 1,415 additions and 582 deletions.
19 changes: 11 additions & 8 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
inherit_from: .rubocop_todo.yml

AllCops:
NewCops: enable

Layout/AccessModifierIndentation:
EnforcedStyle: outdent

Layout/AlignHash:
Layout/HashAlignment:
EnforcedLastArgumentHashStyle: always_ignore

Layout/AlignParameters:
Layout/ParameterAlignment:
EnforcedStyle: with_fixed_indentation

Layout/CaseIndentation:
EnforcedStyle: end

Layout/IndentArray:
Layout/EndAlignment:
EnforcedStyleAlignWith: variable

Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent

Layout/IndentHash:
Layout/FirstHashElementIndentation:
EnforcedStyle: consistent

Layout/IndentHeredoc:
Layout/HeredocIndentation:
Enabled: false

Layout/MultilineMethodCallIndentation:
Expand All @@ -33,9 +39,6 @@ Layout/SpaceInsideHashLiteralBraces:
Lint/AmbiguousBlockAssociation:
Enabled: false

Lint/EndAlignment:
EnforcedStyleAlignWith: variable

Style/Alias:
EnforcedStyle: prefer_alias_method

Expand Down
136 changes: 114 additions & 22 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,136 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-09-09 17:05:47 +0700 using RuboCop version 0.42.0.
# on 2021-03-11 12:44:08 UTC using RuboCop version 1.11.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 42
# Offense count: 1
# Configuration parameters: Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'chewy.gemspec'

# Offense count: 3
# Configuration parameters: AllowedMethods.
# AllowedMethods: enums
Lint/ConstantDefinitionInBlock:
Exclude:
- 'lib/chewy.rb'
- 'lib/chewy/rspec/update_index.rb'
- 'spec/chewy/config_spec.rb'

# Offense count: 12
# Configuration parameters: AllowComments, AllowEmptyLambdas.
Lint/EmptyBlock:
Exclude:
- 'lib/sequel/plugins/chewy_observe.rb'
- 'spec/chewy/minitest/helpers_spec.rb'
- 'spec/chewy/rspec/update_index_spec.rb'
- 'spec/chewy/search/scrolling_spec.rb'
- 'spec/chewy/strategy/atomic_spec.rb'
- 'spec/chewy/strategy_spec.rb'
- 'spec/chewy/type/import/bulk_request_spec.rb'
- 'spec/chewy/type/witchcraft_spec.rb'
- 'spec/chewy_spec.rb'

# Offense count: 3
Lint/MissingSuper:
Exclude:
- 'lib/chewy/strategy/atomic.rb'
- 'lib/chewy/type/adapter/object.rb'
- 'lib/chewy/type/adapter/orm.rb'

# Offense count: 36
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 48
Max: 41

# Offense count: 4
# Configuration parameters: CountComments.
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 300
Max: 269

# Offense count: 14
# Offense count: 13
# Configuration parameters: IgnoredMethods.
Metrics/CyclomaticComplexity:
Max: 13

# Offense count: 1450
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
# URISchemes: http, https
Metrics/LineLength:
Max: 198
Max: 12

# Offense count: 38
# Configuration parameters: CountComments.
# Offense count: 44
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
Metrics/MethodLength:
Max: 33
Max: 29

# Offense count: 1
# Configuration parameters: CountComments.
# Offense count: 2
# Configuration parameters: CountComments, CountAsOne.
Metrics/ModuleLength:
Max: 180
Max: 174

# Offense count: 14
# Offense count: 18
# Configuration parameters: IgnoredMethods.
Metrics/PerceivedComplexity:
Max: 15
Max: 13

# Offense count: 93
# Offense count: 11
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers.
# SupportedStyles: snake_case, normalcase, non_integer
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339
Naming/VariableNumber:
Exclude:
- 'spec/chewy/fields/root_spec.rb'

# Offense count: 5
Style/DocumentDynamicEvalDefinition:
Exclude:
- 'lib/chewy/index/actions.rb'
- 'lib/chewy/repository.rb'
- 'lib/chewy/search/pagination/kaminari.rb'
- 'lib/chewy/type/crutch.rb'
- 'lib/chewy/type/witchcraft.rb'

# Offense count: 63
Style/Documentation:
Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
Style/EvalWithLocation:
Exclude:
- 'spec/chewy/index_spec.rb'

# Offense count: 208
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Enabled: false

# Offense count: 2
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'lib/chewy.rb'
- 'spec/support/active_record.rb'

# Offense count: 12
# Cop supports --auto-correct.
Style/IfUnlessModifier:
Exclude:
- 'lib/chewy.rb'
- 'lib/chewy/railtie.rb'
- 'lib/chewy/rspec/update_index.rb'
- 'lib/chewy/search/query_proxy.rb'
- 'lib/chewy/type/adapter/mongoid.rb'
- 'lib/chewy/type/adapter/sequel.rb'
- 'lib/chewy/type/import.rb'
- 'lib/chewy/type/witchcraft.rb'
- 'spec/support/active_record.rb'

# Offense count: 64
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 191
4 changes: 3 additions & 1 deletion Guardfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ guard :rspec, cmd: 'rspec' do
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m|
["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"]
end
watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
watch('config/routes.rb') { 'spec/routing' }
watch('app/controllers/application_controller.rb') { 'spec/controllers' }
Expand Down
6 changes: 3 additions & 3 deletions chewy.gemspec
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
lib = File.expand_path('../lib', __FILE__)
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'chewy/version'

Gem::Specification.new do |spec| # rubocop:disable BlockLength
Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
spec.name = 'chewy'
spec.version = Chewy::VERSION
spec.authors = ['Toptal, LLC', 'pyromaniac']
Expand All @@ -25,7 +25,7 @@ Gem::Specification.new do |spec| # rubocop:disable BlockLength
spec.add_development_dependency 'rspec', '>= 3.7.0'
spec.add_development_dependency 'rspec-collection_matchers'
spec.add_development_dependency 'rspec-its'
spec.add_development_dependency 'rubocop', '0.52.1'
spec.add_development_dependency 'rubocop', '1.11'
spec.add_development_dependency 'sqlite3'
spec.add_development_dependency 'timecop'

Expand Down
24 changes: 12 additions & 12 deletions gemfiles/rails.5.2.activerecord.gemfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# This file was generated by Appraisal

source "https://rubygems.org"
source 'https://rubygems.org'

gem "activerecord", "~> 5.2.0"
gem "activesupport", "~> 5.2.0"
gem "activejob", "~> 5.2.0"
gem "resque", require: false
gem "shoryuken", require: false
gem "aws-sdk-sqs", require: false
gem "sidekiq", require: false
gem "kaminari-core", "~> 1.1.0", require: false
gem "will_paginate", require: false
gem "parallel", require: false
gem 'activejob', '~> 5.2.0'
gem 'activerecord', '~> 5.2.0'
gem 'activesupport', '~> 5.2.0'
gem 'aws-sdk-sqs', require: false
gem 'kaminari-core', '~> 1.1.0', require: false
gem 'parallel', require: false
gem 'resque', require: false
gem 'rspec_junit_formatter', '~> 0.4.1'
gem 'shoryuken', require: false
gem 'sidekiq', require: false
gem 'will_paginate', require: false

gemspec path: "../"
gemspec path: '../'
24 changes: 12 additions & 12 deletions gemfiles/rails.5.2.mongoid.6.4.gemfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# This file was generated by Appraisal

source "https://rubygems.org"
source 'https://rubygems.org'

gem "mongoid", "~> 6.4.0"
gem "activesupport", "~> 5.2.0"
gem "activejob", "~> 5.2.0"
gem "resque", require: false
gem "shoryuken", require: false
gem "aws-sdk-sqs", require: false
gem "sidekiq", require: false
gem "kaminari-core", "~> 1.1.0", require: false
gem "will_paginate", require: false
gem "parallel", require: false
gem 'activejob', '~> 5.2.0'
gem 'activesupport', '~> 5.2.0'
gem 'aws-sdk-sqs', require: false
gem 'kaminari-core', '~> 1.1.0', require: false
gem 'mongoid', '~> 6.4.0'
gem 'parallel', require: false
gem 'resque', require: false
gem 'rspec_junit_formatter', '~> 0.4.1'
gem 'shoryuken', require: false
gem 'sidekiq', require: false
gem 'will_paginate', require: false

gemspec path: "../"
gemspec path: '../'
24 changes: 12 additions & 12 deletions gemfiles/rails.6.0.activerecord.gemfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# This file was generated by Appraisal

source "https://rubygems.org"
source 'https://rubygems.org'

gem "activerecord", "~> 6.0.0"
gem "activesupport", "~> 6.0.0"
gem "activejob", "~> 6.0.0"
gem "resque", require: false
gem "shoryuken", require: false
gem "aws-sdk-sqs", require: false
gem "sidekiq", require: false
gem "kaminari-core", "~> 1.1.0", require: false
gem "will_paginate", require: false
gem "parallel", require: false
gem 'activejob', '~> 6.0.0'
gem 'activerecord', '~> 6.0.0'
gem 'activesupport', '~> 6.0.0'
gem 'aws-sdk-sqs', require: false
gem 'kaminari-core', '~> 1.1.0', require: false
gem 'parallel', require: false
gem 'resque', require: false
gem 'rspec_junit_formatter', '~> 0.4.1'
gem 'shoryuken', require: false
gem 'sidekiq', require: false
gem 'will_paginate', require: false

gemspec path: "../"
gemspec path: '../'
24 changes: 12 additions & 12 deletions gemfiles/rails.6.1.activerecord.gemfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# This file was generated by Appraisal

source "https://rubygems.org"
source 'https://rubygems.org'

gem "activerecord", "~> 6.1.0"
gem "activesupport", "~> 6.1.0"
gem "activejob", "~> 6.1.0"
gem "resque", require: false
gem "shoryuken", require: false
gem "aws-sdk-sqs", require: false
gem "sidekiq", require: false
gem "kaminari-core", "~> 1.1.0", require: false
gem "will_paginate", require: false
gem "parallel", require: false
gem 'activejob', '~> 6.1.0'
gem 'activerecord', '~> 6.1.0'
gem 'activesupport', '~> 6.1.0'
gem 'aws-sdk-sqs', require: false
gem 'kaminari-core', '~> 1.1.0', require: false
gem 'parallel', require: false
gem 'resque', require: false
gem 'rspec_junit_formatter', '~> 0.4.1'
gem 'shoryuken', require: false
gem 'sidekiq', require: false
gem 'will_paginate', require: false

gem 'rexml' if RUBY_VERSION >= '3.0.0'

gemspec path: "../"
gemspec path: '../'
14 changes: 7 additions & 7 deletions gemfiles/sequel.4.45.gemfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# This file was generated by Appraisal

source "https://rubygems.org"
source 'https://rubygems.org'

gem "sequel", "~> 4.45.0"
gem "activesupport", "~> 5.1.0"
gem "kaminari-core", "~> 1.1.0", require: false
gem "will_paginate", require: false
gem "parallel", require: false
gem 'activesupport', '~> 5.1.0'
gem 'kaminari-core', '~> 1.1.0', require: false
gem 'parallel', require: false
gem 'sequel', '~> 4.45.0'
gem 'will_paginate', require: false

gemspec path: "../"
gemspec path: '../'
Loading

0 comments on commit 891472d

Please sign in to comment.