Skip to content

Commit

Permalink
Add new Rubocops and correct them
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Dec 4, 2024
1 parent d2f7ffa commit f428729
Show file tree
Hide file tree
Showing 23 changed files with 208 additions and 59 deletions.
154 changes: 154 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,157 @@ RSpecRails/MinitestAssertions: # new in 2.17
Enabled: true
Rails/ResponseParsedBody: # new in 2.18
Enabled: true
Gemspec/AddRuntimeDependency: # new in 1.65
Enabled: true
Lint/DuplicateMatchPattern: # new in 1.50
Enabled: true
Lint/DuplicateSetElement: # new in 1.67
Enabled: true
Lint/HashNewWithKeywordArgumentsAsDefault: # new in 1.69
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/NumericOperationWithConstantResult: # new in 1.69
Enabled: true
Lint/RedundantRegexpQuantifiers: # new in 1.53
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
Metrics/CollectionLiteralLength: # new in 1.47
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/DataInheritance: # new in 1.49
Enabled: true
Style/DigChain: # new in 1.69
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/FileNull: # new in 1.69
Enabled: true
Style/FileTouch: # new in 1.69
Enabled: true
Style/KeywordArgumentsMerging: # new in 1.68
Enabled: true
Style/MapIntoArray: # new in 1.63
Enabled: true
Style/RedundantArrayConstructor: # new in 1.52
Enabled: true
Style/RedundantCurrentDirectoryInPath: # new in 1.53
Enabled: true
Style/RedundantFilterChain: # new in 1.52
Enabled: true
Style/RedundantInterpolationUnfreeze: # new in 1.66
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/SafeNavigationChainLength: # new in 1.68
Enabled: true
Style/SendWithLiteralMethodName: # new in 1.64
Enabled: true
Style/SingleLineDoEndBlock: # new in 1.57
Enabled: true
Style/SuperArguments: # new in 1.64
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/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/IdSequence: # new in 2.24
Enabled: true
FactoryBot/RedundantFactoryOption: # new in 2.23
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/EmptyMetadata: # new in 2.24
Enabled: true
RSpec/EmptyOutput: # new in 2.29
Enabled: true
RSpec/Eq: # new in 2.24
Enabled: true
RSpec/ExpectInLet: # new in 2.30
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/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
Rails/DangerousColumnNames: # new in 2.21
Enabled: true
Rails/EnumSyntax: # new in 2.26
Enabled: true
Rails/EnvLocal: # new in 2.22
Enabled: true
Rails/RedundantActiveRecordAllMethod: # new in 2.21
Enabled: true
Rails/SelectMap: # new in 2.21
Enabled: true
Rails/ThreeStateBooleanColumn: # new in 2.19
Enabled: true
Rails/UnusedRenderContent: # new in 2.21
Enabled: true
Rails/WhereRange: # new in 2.25
Enabled: true
2 changes: 1 addition & 1 deletion app/models/arclight/document_downloads.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def files
class << self
def config
@config ||= begin
YAML.safe_load(::File.read(config_filename))
YAML.safe_load_file(config_filename)
rescue Errno::ENOENT
{}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/arclight/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def available_request_types
# @return [Hash<Slug,Repository>]
def self.from_yaml(file)
repos = {}
data = YAML.safe_load(File.read(file))
data = YAML.safe_load_file(file)
data.each_key do |slug|
repos[slug] = new(data[slug].merge(slug: slug))
end
Expand Down
2 changes: 1 addition & 1 deletion lib/arclight/traject/ead2_component_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
record['id'] = hexdigest
hexdigest
else
record.attribute('id')&.value&.strip&.gsub('.', '-')
record.attribute('id')&.value&.strip&.gsub('.', '-') # rubocop:disable Style/SafeNavigationChainLength
end
end
to_field 'ref_ssm' do |_record, accumulator, context|
Expand Down
4 changes: 2 additions & 2 deletions spec/components/arclight/breadcrumb_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
let(:attr) { { count: 2 } }

it 'renders only that many breadcrumb links' do
expect(rendered).to have_selector 'li', text: 'my repository'
expect(rendered).to have_css 'li', text: 'my repository'
expect(rendered).to have_link 'ABC123', href: '/catalog/abc123'
expect(rendered).to have_no_link 'DEF', href: '/catalog/abc123_def'
expect(rendered).to have_no_link 'GHI', href: '/catalog/abc123_ghi'
Expand All @@ -52,7 +52,7 @@
end

it 'renders breadcrumb links' do
expect(rendered).to have_selector 'li', text: 'my repository'
expect(rendered).to have_css 'li', text: 'my repository'
expect(rendered).to have_link 'DEF', href: '/catalog/abc123_def'
expect(rendered).to have_link 'GHI', href: '/catalog/abc123_ghi'
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

RSpec.describe Arclight::RepositoryLocationComponent, type: :component do
let(:field) do
instance_double(Blacklight::FieldPresenter, key: 'blah', document: nil, label: 'blah', values: [Arclight::Repository.all.first], render_field?: true)
instance_double(Blacklight::FieldPresenter, key: 'blah', document: nil, label: 'blah', values: [Arclight::Repository.first], render_field?: true)
end
let(:render) do
component.render_in(vc_test_controller.view_context)
Expand Down
4 changes: 2 additions & 2 deletions spec/features/aeon_web_ead_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

require 'spec_helper'

describe 'Aeon Web EAD Request', js: true do
describe 'Aeon Web EAD Request', :js do
context 'when EAD URL template is provided' do
it 'creates a request link' do
visit solr_document_path 'm0198-xml'

within '#m0198-xml_aspace_ref11_d0s-hierarchy-item' do
click_link 'Pages 1-78'
click_on 'Pages 1-78'
end
expect(page).to have_css(
'a[href*="https://sample.request.com?Action=10&Form=31&Value=http%3A%2F%2Fexample.com%2FM0198.xml',
Expand Down
2 changes: 1 addition & 1 deletion spec/features/autocomplete_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'spec_helper'

RSpec.describe 'Autocomplete', js: true do
RSpec.describe 'Autocomplete', :js do
context 'site-wide search form' do
it 'is configured properly to allow non-prefix autocomplete' do
visit '/catalog'
Expand Down
4 changes: 2 additions & 2 deletions spec/features/bookmarks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
require 'spec_helper'

RSpec.describe 'Bookmarks' do
it 'shows bookmarks as checkboxes', js: true do
it 'shows bookmarks as checkboxes', :js do
visit solr_document_path('aoa271_aspace_a951375d104030369a993ff943f61a77')
check 'Bookmark'
click_link 'Bookmarks'
click_on 'Bookmarks'

visit solr_document_path('aoa271_aspace_a951375d104030369a993ff943f61a77')
expect(page).to have_css('input[type="checkbox"][checked]')
Expand Down
2 changes: 1 addition & 1 deletion spec/features/collection_context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'spec_helper'

RSpec.describe 'Collection context', js: true do
RSpec.describe 'Collection context', :js do
let(:doc_id) { 'aoa271_aspace_6ea193f778e553ca9ea0d00a3e5a1891' }

before do
Expand Down
6 changes: 3 additions & 3 deletions spec/features/collection_filtering_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

select 'all collections', from: 'Search within'

click_button 'Search'
click_on 'Search'

expect(page).to have_css('.al-document-listings .document', count: 10) # has results
expect(page).to have_no_css('.constraint-value .filter-value', text: 'Alpha Omega Alpha Archives, 1894-1992')
Expand Down Expand Up @@ -49,7 +49,7 @@
visit solr_document_path('aoa271_aspace_dba76dab6f750f31aa5fc73e5402e71d')

fill_in 'q', with: 'File'
click_button 'Search'
click_on 'Search'

expect(page).to have_css('.constraint-value .filter-value', text: 'Alpha Omega Alpha Archives, 1894-1992')
expect(page).to have_css('.al-document-listings .document', count: 2) # has results
Expand All @@ -60,7 +60,7 @@

select 'all collections', from: 'Search within'
fill_in 'q', with: 'File'
click_button 'Search'
click_on 'Search'

expect(page).to have_no_css('.constraint-value .filter-value', text: 'Alpha Omega Alpha Archives, 1894-1992')
expect(page).to have_css('.al-document-listings .document', count: 10) # has results
Expand Down
18 changes: 9 additions & 9 deletions spec/features/collection_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
it 'indexed name terms link to the appropriate name facet' do
name = 'Root, William Webster, 1867-1932'
within '#indexed-terms' do
click_link name
click_on name
end

within '.blacklight-names.facet-limit-active' do
Expand Down Expand Up @@ -195,31 +195,31 @@
end

describe 'context and contents' do
describe 'interactions', js: true do
describe 'interactions', :js do
it 'contents contain linked level 1 components' do
within '#collection-context' do
click_link 'Series I: Administrative Records, 1902-1976'
click_on 'Series I: Administrative Records, 1902-1976'
end
expect(page).to have_css '.show-document', text: /Series I: Administrative Records/
end

it 'sub components are viewable and expandable' do
within '#collection-context' do
within '#aoa271_aspace_563a320bb37d24a9e1e6f7bf95b52671-hierarchy-item' do
click_link 'View'
click_on 'View'
within '#aoa271_aspace_dc2aaf83625280ae2e193beb3f4aea78-hierarchy-item.al-collection-context' do
expect(page).to have_link 'Constitution and by-laws'
end
click_link 'Expand'
click_on 'Expand'
expect(page).to have_link 'Reports'
el = find_by_id('aoa271_aspace_238a0567431f36f49acea49ef576d408-hierarchy-item')
evaluate_script "window.scrollTo(0,#{el.rect.y - 100})"
sleep 1
within '#aoa271_aspace_238a0567431f36f49acea49ef576d408-hierarchy-item' do
click_link 'View'
click_on 'View'
expect(page).to have_link 'Expansion Plan'
within '#aoa271_aspace_f934f1add34289f28bd0feb478e68275-hierarchy-item' do
click_link 'View'
click_on 'View'
expect(page).to have_link 'Initial Phase'
expect(page).to have_link 'Phase II: Expansion'
end
Expand Down Expand Up @@ -256,12 +256,12 @@
end
end

context 'content with file downloads', js: true do
context 'content with file downloads', :js do
let(:doc_id) { 'a0011-xml_aspace_ref6_lx4' }

it 'renders links to the files for download' do
within '.al-show-actions-box-downloads-container' do
click_button 'Download'
click_on 'Download'
expect(page).to have_link 'Finding aid'
expect(page).to have_link 'EAD'
end
Expand Down
6 changes: 3 additions & 3 deletions spec/features/compact_search_results_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
RSpec.describe 'Compact Search Results' do
it 'As a user I should be able to view results in a compact display' do
visit root_path
click_button 'Search'
click_on 'Search'

expect(page).to have_css('.documents-list')
expect(page).to have_css('h3.index_title', text: 'Alpha Omega Alpha Archives, 1894-1992')

click_link 'Compact'
click_on 'Compact'

expect(page).to have_no_css('.documents-list')
expect(page).to have_css('.documents-compact')
Expand All @@ -29,7 +29,7 @@

it 'Shows highlights in compact view' do
visit search_catalog_path q: 'william root', search_field: 'name'
click_link 'Compact'
click_on 'Compact'
within '.document-position-1' do
within '.al-document-highlight' do
expect(page).to have_css 'em', text: 'William'
Expand Down
Loading

0 comments on commit f428729

Please sign in to comment.