Skip to content

Commit d67c968

Browse files
authored
Merge pull request #1541 from sul-dlss/rubocop-fixes
Update rubocop cops and autocorrect
2 parents 89ce5d1 + 5660b1b commit d67c968

15 files changed

+117
-6
lines changed

.rubocop.yml

Lines changed: 101 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
inherit_from: .rubocop_todo.yml
22

3-
require:
3+
plugins:
44
- rubocop-rspec
55
- rubocop-performance
66
- rubocop-rails
@@ -497,3 +497,103 @@ Rails/ThreeStateBooleanColumn: # new in 2.19
497497
Enabled: true
498498
Rails/UnusedRenderContent: # new in 2.21
499499
Enabled: true
500+
Gemspec/AddRuntimeDependency: # new in 1.65
501+
Enabled: true
502+
Gemspec/AttributeAssignment: # new in 1.77
503+
Enabled: true
504+
Layout/EmptyLinesAfterModuleInclusion: # new in 1.79
505+
Enabled: true
506+
Lint/ArrayLiteralInRegexp: # new in 1.71
507+
Enabled: true
508+
Lint/ConstantReassignment: # new in 1.70
509+
Enabled: true
510+
Lint/CopDirectiveSyntax: # new in 1.72
511+
Enabled: true
512+
Lint/DuplicateSetElement: # new in 1.67
513+
Enabled: true
514+
Lint/HashNewWithKeywordArgumentsAsDefault: # new in 1.69
515+
Enabled: true
516+
Lint/NumericOperationWithConstantResult: # new in 1.69
517+
Enabled: true
518+
Lint/RedundantTypeConversion: # new in 1.72
519+
Enabled: true
520+
Lint/SharedMutableDefault: # new in 1.70
521+
Enabled: true
522+
Lint/SuppressedExceptionInNumberConversion: # new in 1.72
523+
Enabled: true
524+
Lint/UnescapedBracketInRegexp: # new in 1.68
525+
Enabled: true
526+
Lint/UselessConstantScoping: # new in 1.72
527+
Enabled: true
528+
Lint/UselessDefaultValueArgument: # new in 1.76
529+
Enabled: true
530+
Lint/UselessDefined: # new in 1.69
531+
Enabled: true
532+
Lint/UselessNumericOperation: # new in 1.66
533+
Enabled: true
534+
Lint/UselessOr: # new in 1.76
535+
Enabled: true
536+
Naming/PredicateMethod: # new in 1.76
537+
Enabled: true
538+
Style/AmbiguousEndlessMethodDefinition: # new in 1.68
539+
Enabled: true
540+
Style/BitwisePredicate: # new in 1.68
541+
Enabled: true
542+
Style/CollectionQuerying: # new in 1.77
543+
Enabled: true
544+
Style/CombinableDefined: # new in 1.68
545+
Enabled: true
546+
Style/ComparableBetween: # new in 1.74
547+
Enabled: true
548+
Style/DigChain: # new in 1.69
549+
Enabled: true
550+
Style/EmptyStringInsideInterpolation: # new in 1.76
551+
Enabled: true
552+
Style/FileNull: # new in 1.69
553+
Enabled: true
554+
Style/FileTouch: # new in 1.69
555+
Enabled: true
556+
Style/HashFetchChain: # new in 1.75
557+
Enabled: true
558+
Style/HashSlice: # new in 1.71
559+
Enabled: true
560+
Style/ItAssignment: # new in 1.70
561+
Enabled: true
562+
Style/ItBlockParameter: # new in 1.75
563+
Enabled: true
564+
Style/KeywordArgumentsMerging: # new in 1.68
565+
Enabled: true
566+
Style/RedundantArrayFlatten: # new in 1.76
567+
Enabled: true
568+
Style/RedundantFormat: # new in 1.72
569+
Enabled: true
570+
Style/RedundantInterpolationUnfreeze: # new in 1.66
571+
Enabled: true
572+
Style/SafeNavigationChainLength: # new in 1.68
573+
Enabled: true
574+
Style/SendWithLiteralMethodName: # new in 1.64
575+
Enabled: true
576+
Style/SuperArguments: # new in 1.64
577+
Enabled: true
578+
RSpec/IncludeExamples: # new in 3.6
579+
Enabled: true
580+
Performance/StringBytesize: # new in 1.23
581+
Enabled: true
582+
Performance/ZipWithoutBlock: # new in 1.24
583+
Enabled: true
584+
Rails/EnumSyntax: # new in 2.26
585+
Enabled: true
586+
Rails/FindByOrAssignmentMemoization: # new in 2.33
587+
Enabled: true
588+
Rails/MultipleRoutePaths: # new in 2.29
589+
Enabled: true
590+
Rails/OrderArguments: # new in 2.33
591+
Enabled: true
592+
Rails/StrongParametersExpect: # new in 2.29
593+
Enabled: true
594+
Rails/WhereRange: # new in 2.25
595+
Enabled: true
596+
Capybara/FindAllFirst: # new in 2.22
597+
Enabled: true
598+
Capybara/NegationMatcherAfterVisit: # new in 2.22
599+
Enabled: true

.rubocop_todo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Naming/MethodParameterName:
6666
# ForbiddenPrefixes: is_, has_, have_
6767
# AllowedMethods: is_a?
6868
# MethodDefinitionMacros: define_method, define_singleton_method
69-
Naming/PredicateName:
69+
Naming/PredicatePrefix:
7070
Exclude:
7171
- 'app/controllers/catalog_controller.rb'
7272

app/controllers/application_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class ApplicationController < ActionController::Base
66

77
# Adds a few additional behaviors into the application controller
88
include Blacklight::Controller
9+
910
# Please be sure to impelement current_user and user_session. Blacklight depends on
1011
# these methods in order to perform user specific actions.
1112

app/controllers/feedback_forms_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ def new; end
33

44
def create
55
if request.post?
6-
if validate
6+
if valid?
77
FeedbackMailer.submit_feedback(params, request.remote_ip).deliver_now
88
flash[:success] = t 'earthworks.feedback_form.success'
99
end
@@ -24,7 +24,7 @@ def url_regex
2424
%r{/.*href=.*|.*url=.*|.*http://.*|.*https://.*/i}
2525
end
2626

27-
def validate
27+
def valid?
2828
errors = []
2929

3030
errors << 'You did not pass the reCaptcha challenge' if current_user.blank? && !verify_recaptcha

app/helpers/catalog_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module CatalogHelper
22
include Blacklight::CatalogHelperBehavior
3+
34
def get_specific_field_type(document:, field:, **)
45
field_value = document[field]
56
if field_value&.include?('Datasets') && document[Settings.FIELDS.RESOURCE_TYPE]

app/helpers/earthworks_blacklight_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module EarthworksBlacklightHelper
22
include Blacklight::LayoutHelperBehavior
3+
34
# Blacklight override for show main content
45
def show_content_classes
56
'col-lg-10 show-document'

app/models/concerns/status_extension.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module StatusExtension
22
extend ActiveSupport::Concern
3+
34
included do
45
after_commit :update_index
56
end

app/models/user.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ class User < ActiveRecord::Base
22
attr_accessible :email, :password, :password_confirmation if Rails::VERSION::MAJOR < 4
33
# Connects this user object to Blacklights Bookmarks.
44
include Blacklight::User
5+
56
# Include default devise modules. Others available are:
67
# :confirmable, :lockable, :timeoutable and :omniauthable
78
devise :remote_user_authenticatable, :database_authenticatable, :registerable,

lib/tasks/earthworks.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ namespace :earthworks do
173173
i = 0
174174
while i < total
175175
# might want to add a .where("user_id = NULL") when we have authentication hooked up.
176-
Search.destroy(Search.order('updated_at').limit(chunk).pluck(:id))
176+
Search.destroy(Search.order(:updated_at).limit(chunk).pluck(:id))
177177
i += chunk
178178
sleep(10)
179179
end

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)