Skip to content

Commit

Permalink
Add new rubocops and autocorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Dec 20, 2023
1 parent 2d7da9b commit dbaef7c
Show file tree
Hide file tree
Showing 33 changed files with 739 additions and 332 deletions.
400 changes: 400 additions & 0 deletions .rubocop.yml

Large diffs are not rendered by default.

43 changes: 29 additions & 14 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-12-11 17:46:51 UTC using RuboCop version 1.58.0.
# on 2023-12-20 21:18:36 UTC using RuboCop version 1.59.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
Expand All @@ -15,7 +15,12 @@ Layout/MultilineMethodCallBraceLayout:
- 'spec/routing/file_routing_spec.rb'
- 'spec/routing/media_routing_spec.rb'

# Offense count: 8
# Offense count: 1
Lint/NoReturnInBeginEndBlocks:
Exclude:
- 'app/models/stacks_file.rb'

# Offense count: 9
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 22
Expand All @@ -25,7 +30,7 @@ Metrics/AbcSize:
Metrics/CyclomaticComplexity:
Max: 10

# Offense count: 15
# Offense count: 14
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 25
Expand All @@ -45,7 +50,7 @@ RSpec/AnyInstance:
- 'spec/requests/iiif_spec.rb'
- 'spec/requests/media_auth_request_spec.rb'

# Offense count: 65
# Offense count: 66
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Expand Down Expand Up @@ -79,7 +84,7 @@ RSpec/EmptyLineAfterExampleGroup:
- 'spec/abilities/ability_spec.rb'
- 'spec/requests/file_auth_request_spec.rb'

# Offense count: 34
# Offense count: 38
# This cop supports safe autocorrection (--autocorrect).
RSpec/EmptyLineAfterFinalLet:
Exclude:
Expand Down Expand Up @@ -113,7 +118,7 @@ RSpec/EmptyLineAfterSubject:
- 'spec/models/stacks_image_spec.rb'
- 'spec/services/iiif_metadata_service_spec.rb'

# Offense count: 32
# Offense count: 35
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 16
Expand All @@ -138,7 +143,13 @@ RSpec/HookArgument:
- 'spec/requests/file_auth_request_spec.rb'
- 'spec/requests/iiif_auth_request_spec.rb'

# Offense count: 6
# Offense count: 2
# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns.
RSpec/IndexedLet:
Exclude:
- 'spec/models/stacks_media_token_spec.rb'

# Offense count: 7
# This cop supports safe autocorrection (--autocorrect).
RSpec/LeadingSubject:
Exclude:
Expand All @@ -155,11 +166,11 @@ RSpec/MessageSpies:
- 'spec/controllers/file_controller_spec.rb'
- 'spec/controllers/media_controller_spec.rb'

# Offense count: 75
# Offense count: 81
RSpec/MultipleExpectations:
Max: 12

# Offense count: 63
# Offense count: 64
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
# SupportedStyles: always, named_only
RSpec/NamedSubject:
Expand All @@ -177,7 +188,7 @@ RSpec/NamedSubject:
- 'spec/services/iiif_metadata_service_spec.rb'
- 'spec/services/media_authentication_json_spec.rb'

# Offense count: 46
# Offense count: 47
# Configuration parameters: AllowedGroups.
RSpec/NestedGroups:
Max: 5
Expand All @@ -199,7 +210,7 @@ RSpec/SubjectStub:
Exclude:
- 'spec/models/stacks_media_token_spec.rb'

# Offense count: 13
# Offense count: 14
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Exclude:
Expand All @@ -209,14 +220,18 @@ RSpec/VerifiedDoubles:
- 'spec/models/stacks_media_token_spec.rb'
- 'spec/services/iiif_info_service_spec.rb'

# Offense count: 2
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: slashes, arguments
Rails/FilePath:
Exclude:
- 'app/controllers/application_controller.rb'
- 'spec/controllers/file_controller_spec.rb'

# Offense count: 1
Rails/I18nLocaleTexts:
Exclude:
- 'app/controllers/webauth_controller.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Expand Down Expand Up @@ -260,7 +275,7 @@ Style/StringConcatenation:
- 'spec/controllers/object_controller_spec.rb'
- 'spec/models/stacks_media_token_spec.rb'

# Offense count: 3
# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MinSize.
# SupportedStyles: percent, brackets
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def set_cors_headers
end

def rescue_can_can(exception)
Rails.logger.debug "Access denied on #{exception.action} #{exception.subject.inspect}"
Rails.logger.debug { "Access denied on #{exception.action} #{exception.subject.inspect}" }

render file: "#{Rails.root}/public/403.html", status: :forbidden, layout: false
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/cdl_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def show
render json: {
payload: existing_payload&.except(:token),
availability_url: ("#{Settings.cdl.url}/availability/#{barcode}" if barcode)
}.reject { |_k, v| v.blank? }
}.compact_blank
end

def show_options
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/iiif/auth/v2/probe_service_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def show # rubocop:disable Metrics:AbcSize

if !file.valid?
json[:status] = 400
json[:note] = { "en": file.errors.full_messages }
json[:note] = { en: file.errors.full_messages }
elsif !file.readable?
json[:status] = 404
elsif can? :access, file
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/webauth_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class WebauthController < ApplicationController
before_action :write_auth_session_info, except: [:logout]

def login
flash[:success] = 'You have been successfully logged in.'
flash.now[:success] = 'You have been successfully logged in.'

respond_to do |format|
format.html { render html: '<html><script>window.close();</script></html>'.html_safe }
Expand Down
6 changes: 3 additions & 3 deletions app/models/purl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ def public_json(druid)
end
end

def files(druid, &block)
return to_enum(:files, druid) unless block_given?
def files(druid, &)
return to_enum(:files, druid) unless block

Settings.features.cocina ? files_from_json(druid, &block) : files_from_xml(druid, &block)
Settings.features.cocina ? files_from_json(druid, &) : files_from_xml(druid, &)
end

def files_from_json(druid)
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def anonymous_locatable_user?
end

def stanford?
ldap_groups.present? && (ldap_groups & Settings.user.stanford_groups).any?
ldap_groups.present? && ldap_groups.intersect?(Settings.user.stanford_groups)
end

def token_user?
Expand Down
4 changes: 2 additions & 2 deletions app/services/iiif/v1/auth_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def to_iiif
'profile' => 'http://iiif.io/api/auth/1/login',
'label' => 'Stanford users: log in to access all available features.',
'header' => 'Stanford-affiliated? Log in to view',
'description' => 'Stanford users can click Log in below to access all fea'\
'tures.',
'description' => 'Stanford users can click Log in below to access all fea' \
'tures.',
'confirmLabel' => 'Log in',
'failureHeader' => 'Unable to authenticate',
'failureDescription' => 'The authentication service cannot be reached.',
Expand Down
Loading

0 comments on commit dbaef7c

Please sign in to comment.