Skip to content

Commit

Permalink
Add new rubocop rules and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Dec 9, 2024
1 parent 18d57ee commit 332d2cd
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 35 deletions.
98 changes: 66 additions & 32 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ require:

AllCops:
Exclude:
- '.internal_test_app/**/*'
- 'bin/**/*'
- 'db/**/*'
- 'spec/internal/**/*'
- 'vendor/**/*'
- ".internal_test_app/**/*"
- "bin/**/*"
- "db/**/*"
- "spec/internal/**/*"
- "vendor/**/*"
TargetRubyVersion: 3.1
DisplayCopNames: true
SuggestExtensions: false
Expand Down Expand Up @@ -42,62 +42,62 @@ Lint/StructNewOverride:

Metrics/AbcSize:
Exclude:
- 'app/controllers/spotlight/home_pages_controller.rb'
- 'app/services/spotlight/exhibit_import_export_service.rb'
- "app/controllers/spotlight/home_pages_controller.rb"
- "app/services/spotlight/exhibit_import_export_service.rb"

Metrics/ModuleLength:
Exclude:
- 'app/helpers/spotlight/application_helper.rb'
- 'app/models/concerns/spotlight/solr_document.rb'
- 'spec/fixtures/**/*'
- "app/helpers/spotlight/application_helper.rb"
- "app/models/concerns/spotlight/solr_document.rb"
- "spec/fixtures/**/*"

Metrics/BlockLength:
Exclude:
- Rakefile
- blacklight-spotlight.gemspec
- config/**/*
- 'lib/tasks/*'
- 'spec/**/*'
- 'app/models/spotlight/blacklight_configuration.rb'
- 'app/models/spotlight/resource.rb'
- "lib/tasks/*"
- "spec/**/*"
- "app/models/spotlight/blacklight_configuration.rb"
- "app/models/spotlight/resource.rb"

Metrics/ClassLength:
Max: 150
Exclude:
- 'app/models/spotlight/resources/iiif_manifest.rb'
- 'app/controllers/spotlight/browse_controller.rb'
- 'app/services/spotlight/exhibit_import_export_service.rb'
- 'lib/generators/spotlight/**/*' # Generators tend to have longer class lengths due to their lengthy public API
- "app/models/spotlight/resources/iiif_manifest.rb"
- "app/controllers/spotlight/browse_controller.rb"
- "app/services/spotlight/exhibit_import_export_service.rb"
- "lib/generators/spotlight/**/*" # Generators tend to have longer class lengths due to their lengthy public API

Naming/PredicateName:
Exclude:
- 'app/models/concerns/spotlight/ar_light.rb'
- "app/models/concerns/spotlight/ar_light.rb"

Metrics/MethodLength:
Exclude:
- 'app/controllers/spotlight/home_pages_controller.rb'
- 'app/services/spotlight/exhibit_import_export_service.rb'
- 'lib/generators/spotlight/**/*'
- 'spec/fixtures/**/*'
- "app/controllers/spotlight/home_pages_controller.rb"
- "app/services/spotlight/exhibit_import_export_service.rb"
- "lib/generators/spotlight/**/*"
- "spec/fixtures/**/*"

Metrics/CyclomaticComplexity:
Exclude:
- 'app/controllers/spotlight/home_pages_controller.rb'
- 'app/services/spotlight/exhibit_import_export_service.rb'
- "app/controllers/spotlight/home_pages_controller.rb"
- "app/services/spotlight/exhibit_import_export_service.rb"

Metrics/PerceivedComplexity:
Exclude:
- 'app/controllers/spotlight/home_pages_controller.rb'
- 'app/services/spotlight/exhibit_import_export_service.rb'
- "app/controllers/spotlight/home_pages_controller.rb"
- "app/services/spotlight/exhibit_import_export_service.rb"

Rails:
Enabled: true

RSpec/DescribeClass:
Exclude:
- 'spec/features/**/*'
- 'spec/views/**/*'
- 'spec/i18n_spec.rb'
- "spec/features/**/*"
- "spec/views/**/*"
- "spec/i18n_spec.rb"

# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Expand All @@ -109,7 +109,7 @@ RSpec/NestedGroups:
RSpec/MultipleExpectations:
Max: 9
Exclude:
- 'spec/features/**/*'
- "spec/features/**/*"

Style/ExponentialNotation:
Enabled: true
Expand All @@ -132,7 +132,7 @@ Style/StringLiterals:

Style/Documentation:
Exclude:
- 'spec/**/*'
- "spec/**/*"

Style/DoubleNegation:
Enabled: false
Expand Down Expand Up @@ -474,3 +474,37 @@ Rails/WhereRange: # new in 2.25
Enabled: true
Gemspec/AddRuntimeDependency: # new in 1.65
Enabled: true
Lint/DuplicateSetElement: # new in 1.67
Enabled: true
Lint/HashNewWithKeywordArgumentsAsDefault: # new in 1.69
Enabled: true
Lint/NumericOperationWithConstantResult: # new in 1.69
Enabled: true
Lint/UnescapedBracketInRegexp: # new in 1.68
Enabled: true
Lint/UselessDefined: # new in 1.69
Enabled: true
Lint/UselessNumericOperation: # new in 1.66
Enabled: true
Style/AmbiguousEndlessMethodDefinition: # new in 1.68
Enabled: true
Style/BitwisePredicate: # new in 1.68
Enabled: true
Style/CombinableDefined: # new in 1.68
Enabled: true
Style/DigChain: # new in 1.69
Enabled: true
Style/FileNull: # new in 1.69
Enabled: true
Style/FileTouch: # new in 1.69
Enabled: true
Style/KeywordArgumentsMerging: # new in 1.68
Enabled: true
Style/RedundantInterpolationUnfreeze: # new in 1.66
Enabled: true
Style/SafeNavigationChainLength: # new in 1.68
Enabled: true
RSpec/StringAsInstanceDoubleConstant: # new in 3.1
Enabled: true
Rails/EnumSyntax: # new in 2.26
Enabled: true
2 changes: 1 addition & 1 deletion spec/controllers/spotlight/bulk_actions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
end

let(:search) { FactoryBot.create(:search, exhibit:) }
let(:search_session) { instance_double('::Search', query_params: { q: 'map' }) }
let(:search_session) { instance_double(Search, query_params: { q: 'map' }) }

describe 'POST change_visibility' do
it 'redirects and sets a notice' do
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/spotlight/catalog_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@
it 'sets instance variables for the previous and next documents based on the return of previous_and_next_documents_for_search' do
allow_any_instance_of(controller.search_service_class).to receive(:previous_and_next_documents_for_search).with(
0, current_browse_category.query_params
).and_return([instance_double('SolrResponse', total: '100'), [nil, SolrDocument.new]])
).and_return([nstance_double(Blacklight::Solr::Response, total: '100'), [nil, SolrDocument.new]])

controller.send(:setup_next_and_previous_documents_from_browse_category)
expect(controller.instance_variable_get(:@previous_document)).to be_nil
Expand Down
2 changes: 1 addition & 1 deletion spec/views/spotlight/translations/_page.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
edit_exhibit_feature_page_path: '/',
edit_exhibit_home_page_path: '/',
exhibit_feature_page_path: '/',
f: instance_double('form', fields_for: {}), # mockform builder
f: double('form', fields_for: {}), # mockform builder
page:
)
assign(:language, 'es')
Expand Down

0 comments on commit 332d2cd

Please sign in to comment.