Skip to content

Commit

Permalink
Update cops and reformat with rubocop
Browse files Browse the repository at this point in the history
Also activates available rubocop plugins.
  • Loading branch information
thatbudakguy committed Jun 4, 2024
1 parent 4ab2fd3 commit bbdacb3
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 34 deletions.
185 changes: 166 additions & 19 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,33 @@ require:
- rubocop-rspec
- rubocop-performance
- rubocop-rails
- rubocop-capybara
- rubocop-factory_bot
- rubocop-rspec_rails

AllCops:
TargetRubyVersion: 3.0
DisplayCopNames: true
Exclude:
- 'Gemfile'
- 'bin/**/*'
- 'db/**/*'
- 'tmp/**/*'
- 'storage/**/*'
- 'node_modules/**/*'
- 'vendor/**/*'
- "Gemfile"
- "bin/**/*"
- "db/**/*"
- "tmp/**/*"
- "storage/**/*"
- "node_modules/**/*"
- "vendor/**/*"

Rails:
Enabled: true

RSpec/DescribeClass:
Exclude:
- 'spec/features/**/*'
- 'spec/integration/**/*'
- "spec/features/**/*"
- "spec/integration/**/*"

RSpec/MultipleMemoizedHelpers:
Exclude:
- 'spec/lib/earthworks/harvester_spec.rb'
- "spec/lib/earthworks/harvester_spec.rb"

Gemspec/DeprecatedAttributeAssignment: # new in 1.30
Enabled: true
Expand Down Expand Up @@ -189,23 +192,23 @@ RSpec/SubjectDeclaration: # new in 2.5
Enabled: true
RSpec/VerifiedDoubleReference: # new in 2.10.0
Enabled: true
RSpec/Capybara/NegationMatcher: # new in 2.14
Capybara/NegationMatcher: # new in 2.14
Enabled: true
RSpec/Capybara/SpecificActions: # new in 2.14
Capybara/SpecificActions: # new in 2.14
Enabled: true
RSpec/Capybara/SpecificFinders: # new in 2.13
Capybara/SpecificFinders: # new in 2.13
Enabled: true
RSpec/Capybara/SpecificMatcher: # new in 2.12
Capybara/SpecificMatcher: # new in 2.12
Enabled: true
RSpec/FactoryBot/ConsistentParenthesesStyle: # new in 2.14
FactoryBot/ConsistentParenthesesStyle: # new in 2.14
Enabled: true
RSpec/FactoryBot/SyntaxMethods: # new in 2.7
FactoryBot/SyntaxMethods: # new in 2.7
Enabled: true
RSpec/Rails/AvoidSetupHook: # new in 2.4
RSpecRails/AvoidSetupHook: # new in 2.4
Enabled: true
RSpec/Rails/HaveHttpStatus: # new in 2.12
RSpecRails/HaveHttpStatus: # new in 2.12
Enabled: true
RSpec/Rails/InferredSpecType: # new in 2.14
RSpecRails/InferredSpecType: # new in 2.14
Enabled: true
Performance/AncestorsInclude: # new in 1.7
Enabled: true
Expand Down Expand Up @@ -343,3 +346,147 @@ Rails/WhereNot: # new in 2.8
Enabled: true
Rails/WhereNotWithMultipleConditions: # new in 2.17
Enabled: true
Gemspec/DevelopmentDependencies: # new in 1.44
Enabled: true
Lint/DuplicateMatchPattern: # new in 1.50
Enabled: true
Lint/ItWithoutArgumentsInBlock: # new in 1.59
Enabled: true
Lint/LiteralAssignmentInCondition: # new in 1.58
Enabled: true
Lint/MixedCaseRange: # new in 1.53
Enabled: true
Lint/RedundantRegexpQuantifiers: # new in 1.53
Enabled: true
Lint/UselessRescue: # new in 1.43
Enabled: true
Metrics/CollectionLiteralLength: # new in 1.47
Enabled: true
Style/ArrayIntersect: # new in 1.40
Enabled: true
Style/ComparableClamp: # new in 1.44
Enabled: true
Style/ConcatArrayLiterals: # new in 1.41
Enabled: true
Style/DataInheritance: # new in 1.49
Enabled: true
Style/DirEmpty: # new in 1.48
Enabled: true
Style/ExactRegexpMatch: # new in 1.51
Enabled: true
Style/FileEmpty: # new in 1.48
Enabled: true
Style/MapIntoArray: # new in 1.63
Enabled: true
Style/MapToSet: # new in 1.42
Enabled: true
Style/MinMaxComparison: # new in 1.42
Enabled: true
Style/RedundantArrayConstructor: # new in 1.52
Enabled: true
Style/RedundantConstantBase: # new in 1.40
Enabled: true
Style/RedundantCurrentDirectoryInPath: # new in 1.53
Enabled: true
Style/RedundantDoubleSplatHashBraces: # new in 1.41
Enabled: true
Style/RedundantFilterChain: # new in 1.52
Enabled: true
Style/RedundantHeredocDelimiterQuotes: # new in 1.45
Enabled: true
Style/RedundantLineContinuation: # new in 1.49
Enabled: true
Style/RedundantRegexpArgument: # new in 1.53
Enabled: true
Style/RedundantRegexpConstructor: # new in 1.52
Enabled: true
Style/ReturnNilInPredicateMethodDefinition: # new in 1.53
Enabled: true
Style/SingleLineDoEndBlock: # new in 1.57
Enabled: true
Style/SuperWithArgsParentheses: # new in 1.58
Enabled: true
Style/YAMLFileRead: # new in 1.53
Enabled: true
Capybara/ClickLinkOrButtonStyle: # new in 2.19
Enabled: true
Capybara/MatchStyle: # new in 2.17
Enabled: true
Capybara/RedundantWithinFind: # new in 2.20
Enabled: true
Capybara/RSpec/HaveSelector: # new in 2.19
Enabled: true
Capybara/RSpec/PredicateMatcher: # new in 2.19
Enabled: true
FactoryBot/AssociationStyle: # new in 2.23
Enabled: true
FactoryBot/ExcessiveCreateList: # new in 2.25
Enabled: true
FactoryBot/FactoryAssociationWithStrategy: # new in 2.23
Enabled: true
FactoryBot/FactoryNameStyle: # new in 2.16
Enabled: true
FactoryBot/IdSequence: # new in 2.24
Enabled: true
FactoryBot/RedundantFactoryOption: # new in 2.23
Enabled: true
RSpecRails/MinitestAssertions: # new in 2.17
Enabled: true
RSpecRails/NegationBeValid: # new in 2.23
Enabled: true
RSpecRails/TravelAround: # new in 2.19
Enabled: true
RSpec/BeEmpty: # new in 2.20
Enabled: true
RSpec/ContainExactly: # new in 2.19
Enabled: true
RSpec/DuplicatedMetadata: # new in 2.16
Enabled: true
RSpec/EmptyMetadata: # new in 2.24
Enabled: true
RSpec/EmptyOutput: # new in 2.29
Enabled: true
RSpec/Eq: # new in 2.24
Enabled: true
RSpec/IndexedLet: # new in 2.20
Enabled: true
RSpec/IsExpectedSpecify: # new in 2.27
Enabled: true
RSpec/MatchArray: # new in 2.19
Enabled: true
RSpec/MetadataStyle: # new in 2.24
Enabled: true
RSpec/PendingWithoutReason: # new in 2.16
Enabled: true
RSpec/ReceiveMessages: # new in 2.23
Enabled: true
RSpec/RedundantAround: # new in 2.19
Enabled: true
RSpec/RedundantPredicateMatcher: # new in 2.26
Enabled: true
RSpec/RemoveConst: # new in 2.26
Enabled: true
RSpec/RepeatedSubjectCall: # new in 2.27
Enabled: true
RSpec/SkipBlockInsideExample: # new in 2.19
Enabled: true
RSpec/SpecFilePathFormat: # new in 2.24
Enabled: true
RSpec/SpecFilePathSuffix: # new in 2.24
Enabled: true
RSpec/UndescriptiveLiteralsDescription: # new in 2.29
Enabled: true
Performance/MapMethodChain: # new in 1.19
Enabled: true
Rails/DangerousColumnNames: # new in 2.21
Enabled: true
Rails/EnvLocal: # new in 2.22
Enabled: true
Rails/RedundantActiveRecordAllMethod: # new in 2.21
Enabled: true
Rails/ResponseParsedBody: # new in 2.18
Enabled: true
Rails/ThreeStateBooleanColumn: # new in 2.19
Enabled: true
Rails/UnusedRenderContent: # new in 2.21
Enabled: true
4 changes: 2 additions & 2 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,10 @@ class CatalogController < ApplicationController
# Custom tools for GeoBlacklight
# rubocop:disable Layout/LineLength
config.add_show_tools_partial :web_services, if: proc { |_context, _config, options|
options[:document] && (Settings.WEBSERVICES_SHOWN & options[:document].references.refs.map(&:type).map(&:to_s)).any?
options[:document] && (Settings.WEBSERVICES_SHOWN & options[:document].references.refs.map { |r| r.type.to_s }).any?
}
config.add_show_tools_partial :metadata, if: proc { |_context, _config, options|
options[:document] && (Settings.METADATA_SHOWN & options[:document].references.refs.map(&:type).map(&:to_s)).any?
options[:document] && (Settings.METADATA_SHOWN & options[:document].references.refs.map { |r| r.type.to_s }).any?
}
config.add_show_tools_partial :arcgis, partial: 'arcgis', if: proc { |_context, _config, options|
options[:document] && options[:document].arcgis_urls.present?
Expand Down
2 changes: 1 addition & 1 deletion lib/legacy_id_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class LegacyIdMap
class << self
def map
@map ||= YAML.safe_load(File.read(path))
@map ||= YAML.safe_load_file(path)
end

private
Expand Down
2 changes: 1 addition & 1 deletion spec/features/bookmarks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
it 'index has created bookmarks' do
skip('Passes locally, not on Travis.') if ENV['CI']
visit solr_document_path 'columbia-columbia-landinfo-global-aet'
click_button 'Bookmark'
click_on 'Bookmark'
visit bookmarks_path
expect(page).to have_css '.document', count: 1
end
Expand Down
10 changes: 5 additions & 5 deletions spec/features/feedback_form_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

describe 'Feedback form (js)', js: true do
describe 'Feedback form (js)', :js do
before do
visit root_path
end
Expand All @@ -10,15 +10,15 @@
end

it 'feedback form should be shown filled out and submitted' do
click_link 'Feedback'
click_on 'Feedback'
skip('Passes locally, not on Travis.') if ENV['CI']
expect(page).to have_css('#feedback-form', visible: true)
expect(page).to have_button('Cancel')
within 'form.feedback-form' do
fill_in('message', with: 'This is only a test')
fill_in('name', with: 'Ronald McDonald')
fill_in('to', with: '[email protected]')
click_button 'Send'
click_on 'Send'
end
expect(page).to have_css('div.alert-success', text: 'Thank you! Your feedback has been sent.')
end
Expand All @@ -30,14 +30,14 @@
end

it 'feedback form should be shown filled out and submitted' do
click_link 'Feedback'
click_on 'Feedback'
expect(page).to have_css('#feedback-form', visible: true)
expect(page).to have_link('Cancel')
within 'form.feedback-form' do
fill_in('message', with: 'This is only a test')
fill_in('name', with: 'Ronald McDonald')
fill_in('to', with: '[email protected]')
click_button 'Send'
click_on 'Send'
end
expect(page).to have_css('div.alert-success', text: 'Thank you! Your feedback has been sent.')
end
Expand Down
2 changes: 1 addition & 1 deletion spec/features/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
it 'are turned on' do
visit root_path
fill_in 'q', with: 'standford'
click_button 'search'
click_on 'search'
expect(page).to have_content 'Did you mean to type:'
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/external-data/author_search_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require 'rails_helper'

describe 'Author search', 'data-integration': true, feature: true do
describe 'Author search', :'data-integration', :feature do
it 'returns 1 result for pinsky' do
visit root_path
fill_in 'q', with: 'pinsky'
click_button 'search'
click_on 'search'
expect(page).to have_css '.document', count: 1
within '.document' do
expect(page).to have_link 'Abundance Estimates of the Pacific Salmon Conservation Assessment Database, 1978-2008'
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/external-data/geo_search_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

describe 'Spatial search', 'data-integration': true, feature: true do
describe 'Spatial search', :'data-integration', :feature do
it 'isWithin should be more relevant' do
visit search_catalog_path(q: 'road', bbox: '61.34 2.11 92 40.45')
expect(page).to have_css 'h3.index_title', text: '1. Roads: Badakhshān Pr' \
Expand Down
3 changes: 1 addition & 2 deletions spec/lib/earthworks/harvester_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
end

# stub git commands
allow(Git).to receive(:open).and_return(stub_repo)
allow(Git).to receive(:clone).and_return(stub_repo)
allow(Git).to receive_messages(open: stub_repo, clone: stub_repo)
allow(stub_repo).to receive(:pull).and_return(stub_repo)
end

Expand Down

0 comments on commit bbdacb3

Please sign in to comment.