diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4fdf2cd350..bc3e03acb3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,13 +1,13 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2020-09-24 02:12:21 UTC using RuboCop version 0.91.1. +# on 2024-01-18 01:26:47 UTC using RuboCop version 1.60.1. # 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 # versions of RuboCop, may require this file to be generated again. # Offense count: 4 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Capybara/CurrentPathExpectation: Exclude: - 'spec/features/alternate_controller_spec.rb' @@ -21,7 +21,7 @@ Capybara/VisibilityMatcher: - 'spec/helpers/blacklight_helper_spec.rb' # Offense count: 8 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth. # SupportedStyles: case, end Layout/CaseIndentation: @@ -31,18 +31,18 @@ Layout/CaseIndentation: - 'lib/blacklight/configuration/fields.rb' # Offense count: 2 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Layout/ClosingParenthesisIndentation: Exclude: - 'app/views/catalog/index.atom.builder' -# Offense count: 111 -# Cop supports --auto-correct. +# Offense count: 114 +# This cop supports safe autocorrection (--autocorrect). Layout/EmptyLineAfterMagicComment: Enabled: false # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowAliasSyntax, AllowedMethods. # AllowedMethods: alias_method, public, protected, private Layout/EmptyLinesAroundAttributeAccessor: @@ -50,7 +50,7 @@ Layout/EmptyLinesAroundAttributeAccessor: - 'app/presenters/blacklight/field_presenter.rb' # Offense count: 7 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. Layout/ExtraSpacing: Exclude: @@ -59,16 +59,8 @@ Layout/ExtraSpacing: - 'app/views/catalog/index.atom.builder' - 'config/routes.rb' -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_braces -Layout/FirstHashElementIndentation: - Exclude: - - 'lib/blacklight/configuration.rb' - # Offense count: 6 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. Layout/LeadingCommentSpace: Exclude: @@ -78,13 +70,13 @@ Layout/LeadingCommentSpace: - 'app/views/catalog/_document.atom.builder' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Layout/MultilineBlockLayout: Exclude: - 'lib/generators/blacklight/test_support_generator.rb' # Offense count: 2 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: symmetrical, new_line, same_line Layout/MultilineMethodCallBraceLayout: @@ -92,7 +84,7 @@ Layout/MultilineMethodCallBraceLayout: - 'app/views/catalog/index.atom.builder' # Offense count: 9 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: aligned, indented, indented_relative_to_receiver Layout/MultilineMethodCallIndentation: @@ -100,7 +92,7 @@ Layout/MultilineMethodCallIndentation: - 'lib/blacklight/search_builder.rb' # Offense count: 9 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: aligned, indented Layout/MultilineOperationIndentation: @@ -111,42 +103,44 @@ Layout/MultilineOperationIndentation: - 'lib/blacklight/solr/search_builder_behavior.rb' # Offense count: 2 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Layout/SpaceAfterComma: Exclude: - 'app/views/catalog/index.atom.builder' - 'app/views/catalog/opensearch.xml.builder' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowForAlignment. Layout/SpaceBeforeFirstArg: Exclude: - 'app/views/catalog/index.atom.builder' # Offense count: 7 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. -# SupportedStyles: space, no_space +# SupportedStyles: space, compact, no_space Layout/SpaceInsideParens: Exclude: - 'app/views/catalog/_document.rss.builder' - 'app/views/catalog/index.atom.builder' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowInHeredoc. Layout/TrailingWhitespace: Exclude: - 'lib/blacklight/configuration.rb' # Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowedMethods, AllowedPatterns. Lint/AmbiguousBlockAssociation: Exclude: - 'lib/blacklight/solr/search_builder_behavior.rb' -# Offense count: 8 -# Cop supports --auto-correct. +# Offense count: 9 +# This cop supports safe autocorrection (--autocorrect). Lint/AmbiguousOperator: Exclude: - 'spec/helpers/blacklight/facets_helper_behavior_spec.rb' @@ -158,7 +152,7 @@ Lint/AmbiguousOperator: - 'spec/services/blacklight/search_service_spec.rb' # Offense count: 55 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Lint/AmbiguousRegexpLiteral: Exclude: - 'spec/controllers/catalog_controller_spec.rb' @@ -173,8 +167,39 @@ Lint/AmbiguousRegexpLiteral: - 'spec/views/catalog/index.html.erb_spec.rb' - 'spec/views/catalog/show.html.erb_spec.rb' -# Offense count: 29 -# Cop supports --auto-correct. +# Offense count: 1 +Lint/BinaryOperatorWithIdenticalOperands: + Exclude: + - 'spec/models/blacklight/document/active_model_shim_spec.rb' + +# Offense count: 16 +# Configuration parameters: AllowedMethods. +# AllowedMethods: enums +Lint/ConstantDefinitionInBlock: + Exclude: + - 'lib/blacklight/engine.rb' + - 'spec/controllers/blacklight/search_fields_spec.rb' + - 'spec/controllers/bookmarks_controller_spec.rb' + - 'spec/controllers/catalog_controller_spec.rb' + - 'spec/models/blacklight/configurable_spec.rb' + - 'spec/models/blacklight/document/active_model_shim_spec.rb' + - 'spec/models/blacklight/document_spec.rb' + - 'spec/models/blacklight/solr/document_spec.rb' + - 'spec/presenters/blacklight/show_presenter_spec.rb' + +# Offense count: 1 +# Configuration parameters: AllowComments. +Lint/EmptyFile: + Exclude: + - 'spec/components/blacklight/document_metadata_component_spec.rb' + +# Offense count: 44 +# Configuration parameters: AllowedParentClasses. +Lint/MissingSuper: + Enabled: false + +# Offense count: 30 +# This cop supports safe autocorrection (--autocorrect). Lint/ParenthesesAsGroupedExpression: Exclude: - 'spec/features/did_you_mean_spec.rb' @@ -184,58 +209,63 @@ Lint/ParenthesesAsGroupedExpression: - 'spec/lib/blacklight/search_state_spec.rb' - 'spec/models/blacklight/solr/repository_spec.rb' +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedMethods. +# AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal?, presence, present? +Lint/RedundantSafeNavigation: + Exclude: + - 'app/helpers/blacklight/blacklight_helper_behavior.rb' + - 'lib/blacklight/solr/response/params.rb' + # Offense count: 2 Lint/ShadowingOuterLocalVariable: Exclude: - 'spec/models/blacklight/configuration_spec.rb' -# Offense count: 57 -# Configuration parameters: IgnoredMethods. +# Offense count: 85 +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: - Max: 59 + Max: 46 # Offense count: 2 -# Configuration parameters: CountComments, CountAsOne, ExcludedMethods. -# ExcludedMethods: refine +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. +# AllowedMethods: refine Metrics/BlockLength: - Max: 30 + Max: 29 # Offense count: 1 # Configuration parameters: CountBlocks. Metrics/BlockNesting: Max: 4 -# Offense count: 2 -# Configuration parameters: CountComments, CountAsOne. -Metrics/ClassLength: - Max: 169 - -# Offense count: 26 -# Configuration parameters: IgnoredMethods. +# Offense count: 47 +# Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: Max: 14 -# Offense count: 61 -# Configuration parameters: CountComments, CountAsOne, ExcludedMethods. +# Offense count: 93 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: - Max: 30 + Max: 29 -# Offense count: 8 +# Offense count: 9 # Configuration parameters: CountComments, CountAsOne. Metrics/ModuleLength: - Max: 213 + Max: 203 -# Offense count: 3 -# Configuration parameters: CountKeywordArgs. +# Offense count: 8 +# Configuration parameters: CountKeywordArgs, MaxOptionalParameters. Metrics/ParameterLists: Max: 6 -# Offense count: 22 -# Configuration parameters: IgnoredMethods. +# Offense count: 39 +# Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/PerceivedComplexity: Max: 16 # Offense count: 4 +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyleForLeadingUnderscores. # SupportedStylesForLeadingUnderscores: disallowed, required, optional Naming/MemoizedInstanceVariableName: @@ -245,34 +275,32 @@ Naming/MemoizedInstanceVariableName: - 'app/models/concerns/blacklight/document/semantic_fields.rb' - 'lib/blacklight/solr/response.rb' -# Offense count: 13 +# Offense count: 10 # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. -# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to +# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to Naming/MethodParameterName: Exclude: - 'app/models/concerns/blacklight/document.rb' - 'app/presenters/blacklight/rendering/link_to_facet.rb' - 'lib/blacklight/nested_open_struct_with_hash_access.rb' - - 'lib/blacklight/search_state.rb' - 'lib/blacklight/solr/document.rb' - 'lib/blacklight/solr/search_builder_behavior.rb' - - 'spec/features/search_context_spec.rb' - - 'spec/features/search_results_spec.rb' -# Offense count: 14 -# Configuration parameters: EnforcedStyle. +# Offense count: 25 +# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns. # SupportedStyles: snake_case, normalcase, non_integer +# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64 Naming/VariableNumber: Exclude: + - 'spec/lib/blacklight/search_state_spec.rb' + - 'spec/models/blacklight/search_builder_spec.rb' + - 'spec/views/catalog/_facet_group.html.erb_spec.rb' - 'spec/views/catalog/_index.html.erb_spec.rb' - 'spec/views/catalog/_show.html.erb_spec.rb' # Offense count: 9 RSpec/BeforeAfterAll: Exclude: - - 'spec/spec_helper.rb' - - 'spec/rails_helper.rb' - - 'spec/support/**/*.rb' - 'spec/controllers/blacklight/search_fields_spec.rb' - 'spec/controllers/search_history_controller_spec.rb' - 'spec/helpers/blacklight/search_history_constraints_helper_behavior_spec.rb' @@ -282,39 +310,49 @@ RSpec/BeforeAfterAll: - 'spec/models/blacklight/document/sms_spec.rb' - 'spec/models/blacklight/solr/document_spec.rb' -# Offense count: 81 -# Configuration parameters: Prefixes. +# Offense count: 109 +# Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: Enabled: false -# Offense count: 42 +# Offense count: 1 +# Configuration parameters: IgnoredMetadata. RSpec/DescribeClass: - Enabled: false + Exclude: + - 'spec/lib/tasks/blacklight_task_spec.rb' -# Offense count: 2 -# Configuration parameters: CustomIncludeMethods. +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). RSpec/EmptyExampleGroup: Exclude: - - 'spec/helpers/blacklight_helper_spec.rb' - 'spec/models/blacklight/solr/search_builder_spec.rb' -# Offense count: 134 -# Configuration parameters: Max. +# Offense count: 152 +# Configuration parameters: CountAsOne. RSpec/ExampleLength: - Enabled: false + Max: 33 -# Offense count: 15 +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples. +# DisallowedExamples: works +RSpec/ExampleWording: + Exclude: + - 'spec/helpers/blacklight/url_helper_behavior_spec.rb' + - 'spec/presenters/blacklight/facet_item_presenter_spec.rb' + +# Offense count: 11 RSpec/ExpectInHook: Exclude: - 'spec/controllers/catalog_controller_spec.rb' - 'spec/helpers/blacklight/configuration_helper_behavior_spec.rb' - 'spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb' - 'spec/helpers/blacklight/suggest_helper_behavior_spec.rb' - - 'spec/helpers/catalog_helper_spec.rb' # Offense count: 5 -# Configuration parameters: CustomTransform, IgnoreMethods, SpecSuffixOnly. +# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. +# Include: **/*_spec*rb*, **/spec/**/* RSpec/FilePath: Exclude: - 'spec/controllers/blacklight/catalog/component_configuration_spec.rb' @@ -323,7 +361,7 @@ RSpec/FilePath: - 'spec/presenters/pipeline_spec.rb' - 'spec/presenters/thumbnail_presenter_spec.rb' -# Offense count: 191 +# Offense count: 188 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: Enabled: false @@ -347,14 +385,14 @@ RSpec/LeakyConstantDeclaration: - 'spec/models/blacklight/solr/document_spec.rb' - 'spec/presenters/blacklight/show_presenter_spec.rb' -# Offense count: 8 +# Offense count: 9 RSpec/MessageChain: Exclude: - 'spec/controllers/bookmarks_controller_spec.rb' - 'spec/presenters/blacklight/field_presenter_spec.rb' - 'spec/views/shared/_user_util_links.html.erb_spec.rb' -# Offense count: 61 +# Offense count: 57 # Configuration parameters: EnforcedStyle. # SupportedStyles: have_received, receive RSpec/MessageSpies: @@ -373,21 +411,23 @@ RSpec/MessageSpies: - 'spec/presenters/blacklight/field_presenter_spec.rb' - 'spec/presenters/thumbnail_presenter_spec.rb' -# Offense count: 363 +# Offense count: 433 RSpec/MultipleExpectations: Max: 16 -# Offense count: 160 +# Offense count: 270 # Configuration parameters: AllowSubject. RSpec/MultipleMemoizedHelpers: Max: 14 -# Offense count: 337 -# Configuration parameters: IgnoreSharedExamples. +# Offense count: 412 +# Configuration parameters: EnforcedStyle, IgnoreSharedExamples. +# SupportedStyles: always, named_only RSpec/NamedSubject: Enabled: false -# Offense count: 40 +# Offense count: 56 +# Configuration parameters: AllowedGroups. RSpec/NestedGroups: Max: 5 @@ -411,23 +451,38 @@ RSpec/RepeatedExampleGroupDescription: - 'spec/services/blacklight/search_service_spec.rb' # Offense count: 4 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). RSpec/ScatteredLet: Exclude: - 'spec/helpers/catalog_helper_spec.rb' - 'spec/models/blacklight/solr/search_builder_spec.rb' - 'spec/views/catalog/index.atom.builder_spec.rb' -# Offense count: 13 +# Offense count: 24 +RSpec/StubbedMock: + Exclude: + - 'spec/controllers/catalog_controller_spec.rb' + - 'spec/helpers/blacklight/configuration_helper_behavior_spec.rb' + - 'spec/helpers/blacklight/facets_helper_behavior_spec.rb' + - 'spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb' + - 'spec/helpers/blacklight/url_helper_behavior_spec.rb' + - 'spec/helpers/blacklight_helper_spec.rb' + - 'spec/helpers/catalog_helper_spec.rb' + - 'spec/models/blacklight/suggest_search_spec.rb' + - 'spec/presenters/blacklight/field_presenter_spec.rb' + - 'spec/presenters/thumbnail_presenter_spec.rb' + +# Offense count: 12 RSpec/SubjectStub: Exclude: - 'spec/controllers/catalog_controller_spec.rb' - - 'spec/lib/blacklight/search_state_spec.rb' - 'spec/models/blacklight/document/cache_key_spec.rb' - 'spec/models/blacklight/search_builder_spec.rb' + - 'spec/presenters/blacklight/document_presenter_spec.rb' + - 'spec/presenters/blacklight/field_presenter_spec.rb' - 'spec/services/blacklight/search_service_spec.rb' -# Offense count: 121 +# Offense count: 132 # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. RSpec/VerifiedDoubles: Enabled: false @@ -437,15 +492,9 @@ RSpec/VoidExpect: Exclude: - 'spec/lib/blacklight/configuration/facet_field_spec.rb' -# Offense count: 8 -# Cop supports --auto-correct. -Rails/ContentTag: - Exclude: - - 'app/components/blacklight/document_component.rb' - - 'app/components/blacklight/facet_item_pivot_component.rb' - # Offense count: 4 -# Configuration parameters: EnforcedStyle. +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, AllowToTime. # SupportedStyles: strict, flexible Rails/Date: Exclude: @@ -462,22 +511,19 @@ Rails/HelperInstanceVariable: - 'app/helpers/blacklight/facets_helper_behavior.rb' - 'app/helpers/blacklight/render_partials_helper_behavior.rb' -# Offense count: 11 +# Offense count: 2 Rails/OutputSafety: Exclude: - - 'app/helpers/blacklight/catalog_helper_behavior.rb' - - 'app/helpers/blacklight/configuration_helper_behavior.rb' - 'app/helpers/blacklight/icon_helper_behavior.rb' - - 'app/helpers/blacklight/url_helper_behavior.rb' - 'app/presenters/blacklight/rendering/join.rb' -# Offense count: 13 +# Offense count: 14 Security/Eval: Exclude: - 'spec/models/blacklight/solr/response_spec.rb' # Offense count: 9 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: prefer_alias, prefer_alias_method Style/Alias: @@ -490,44 +536,46 @@ Style/Alias: - 'lib/blacklight/solr/response/group_response.rb' # Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object # FunctionalMethods: let, let!, subject, watch -# IgnoredMethods: lambda, proc, it +# AllowedMethods: lambda, proc, it Style/BlockDelimiters: Exclude: - 'app/views/catalog/index.rss.builder' - 'app/views/catalog/opensearch.xml.builder' -# Offense count: 51 -# Cop supports --auto-correct. +# Offense count: 56 +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: nested, compact Style/ClassAndModuleChildren: Enabled: false # Offense count: 6 +# This cop supports unsafe autocorrection (--autocorrect-all). Style/CommentedKeyword: Exclude: - 'spec/controllers/catalog_controller_spec.rb' - 'spec/services/blacklight/search_service_spec.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. # SupportedStyles: assign_to_condition, assign_inside_condition Style/ConditionalAssignment: Exclude: - 'lib/blacklight/solr/response/spelling.rb' -# Offense count: 105 +# Offense count: 124 +# Configuration parameters: AllowedConstants. Style/Documentation: Enabled: false # Offense count: 10 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/ExpandPathArguments: Exclude: - 'Gemfile' @@ -542,14 +590,16 @@ Style/ExpandPathArguments: - 'lib/generators/blacklight/user_generator.rb' # Offense count: 16 -# Configuration parameters: EnforcedStyle. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns. # SupportedStyles: annotated, template, unannotated +# AllowedMethods: redirect Style/FormatStringToken: - Exclude: - - 'app/helpers/blacklight/render_partials_helper_behavior.rb' + EnforcedStyle: template -# Offense count: 8 -# Configuration parameters: MinBodyLength. +# Offense count: 7 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. Style/GuardClause: Exclude: - 'app/controllers/concerns/blacklight/bookmarks.rb' @@ -558,13 +608,23 @@ Style/GuardClause: - 'app/helpers/blacklight/catalog_helper_behavior.rb' - 'lib/blacklight/solr/search_builder_behavior.rb' +# Offense count: 4 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. +# AllowedReceivers: Thread.current +Style/HashEachMethods: + Exclude: + - 'app/components/blacklight/advanced_search_form_component.rb' + - 'spec/controllers/catalog_controller_spec.rb' + - 'spec/models/blacklight/solr/response_spec.rb' + # Offense count: 39 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/IfUnlessModifier: Enabled: false -# Offense count: 5 -# Cop supports --auto-correct. +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). Style/MultilineIfModifier: Exclude: - 'app/views/catalog/index.atom.builder' @@ -572,12 +632,14 @@ Style/MultilineIfModifier: - 'lib/blacklight/solr/search_builder_behavior.rb' # Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowMethodComparison, ComparisonsThreshold. Style/MultipleComparison: Exclude: - 'lib/blacklight/configuration/context.rb' # Offense count: 2 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: literals, strict Style/MutableConstant: @@ -585,12 +647,11 @@ Style/MutableConstant: - 'lib/blacklight/solr/request.rb' # Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IgnoredMethods. +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: - - 'spec/**/*' - 'app/helpers/blacklight/catalog_helper_behavior.rb' - 'app/services/blacklight/search_service.rb' - 'lib/blacklight/search_builder.rb' @@ -599,23 +660,29 @@ Style/NumericPredicate: - 'lib/blacklight/solr/search_builder_behavior.rb' - 'lib/railties/blacklight.rake' -# Offense count: 3 -# Cop supports --auto-correct. +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions. Style/ParenthesesAroundCondition: Exclude: - 'app/views/catalog/_document.atom.builder' # Offense count: 3 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: PreferredDelimiters. Style/PercentLiteralDelimiters: Exclude: - 'lib/blacklight/engine.rb' - 'lib/blacklight/solr/request.rb' +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/RedundantInterpolation: + Exclude: + - 'lib/blacklight/component.rb' + # Offense count: 7 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: implicit, explicit Style/RescueStandardError: @@ -625,9 +692,9 @@ Style/RescueStandardError: - 'lib/blacklight/configuration/fields.rb' - 'lib/railties/blacklight.rake' -# Offense count: 12 -# Cop supports --auto-correct. -# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods. +# Offense count: 11 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. # AllowedMethods: present?, blank?, presence, try, try! Style/SafeNavigation: Exclude: @@ -637,19 +704,33 @@ Style/SafeNavigation: - 'lib/blacklight.rb' - 'lib/blacklight/configuration/facet_field.rb' - 'lib/blacklight/configuration/search_field.rb' - - 'lib/blacklight/search_state.rb' - 'lib/blacklight/solr/search_builder_behavior.rb' -# Offense count: 3 -# Cop supports --auto-correct. +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowAsExpressionSeparator. Style/Semicolon: Exclude: - 'spec/models/blacklight/solr/repository_spec.rb' - 'spec/views/catalog/_paginate_compact.html.erb_spec.rb' -# Offense count: 31 -# Cop supports --auto-correct. +# Offense count: 12 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Mode. +Style/StringConcatenation: + Exclude: + - 'app/helpers/blacklight/blacklight_helper_behavior.rb' + - 'app/helpers/blacklight/render_constraints_helper_behavior.rb' + - 'lib/blacklight/configuration/fields.rb' + - 'lib/blacklight/solr/search_builder_behavior.rb' + - 'lib/railties/blacklight.rake' + - 'spec/features/search_results_spec.rb' + - 'spec/helpers/blacklight/url_helper_behavior_spec.rb' + - 'spec/models/blacklight/solr/response_spec.rb' + - 'spec/routing/catalog_routing_spec.rb' + +# Offense count: 42 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MinSize. # SupportedStyles: percent, brackets Style/SymbolArray: diff --git a/app/components/blacklight/document/thumbnail_component.rb b/app/components/blacklight/document/thumbnail_component.rb index 8809cb59b8..ab8f5de25a 100644 --- a/app/components/blacklight/document/thumbnail_component.rb +++ b/app/components/blacklight/document/thumbnail_component.rb @@ -9,7 +9,7 @@ class ThumbnailComponent < Blacklight::Component # @param [Blacklight::DocumentPresenter] presenter # @param [Integer] counter # @param [Hash] image_options options for the thumbnail presenter's image tag - def initialize(presenter: nil, document: nil, counter:, image_options: {}) + def initialize(counter:, presenter: nil, document: nil, image_options: {}) @presenter = presenter @document = presenter&.document || document @counter = counter diff --git a/app/components/blacklight/response/sort_component.rb b/app/components/blacklight/response/sort_component.rb index 9fb867a08a..ff1d0e20c4 100644 --- a/app/components/blacklight/response/sort_component.rb +++ b/app/components/blacklight/response/sort_component.rb @@ -3,7 +3,7 @@ module Blacklight module Response class SortComponent < ViewComponent::Base - def initialize(param: 'sort', choices: {}, search_state:, id: 'sort-dropdown', classes: [], selected: nil) + def initialize(search_state:, param: 'sort', choices: {}, id: 'sort-dropdown', classes: [], selected: nil) @param = param @choices = choices @search_state = search_state diff --git a/app/components/blacklight/response/view_type_component.rb b/app/components/blacklight/response/view_type_component.rb index 9e4ad84a95..4dbaf592d5 100644 --- a/app/components/blacklight/response/view_type_component.rb +++ b/app/components/blacklight/response/view_type_component.rb @@ -7,7 +7,7 @@ class ViewTypeComponent < ViewComponent::Base renders_many :views, 'Blacklight::Response::ViewTypeButtonComponent' # @param [Blacklight::Response] response - def initialize(response:, views: {}, search_state:, selected: nil) + def initialize(response:, search_state:, views: {}, selected: nil) @response = response @views = views @search_state = search_state diff --git a/app/components/blacklight/system/flash_message_component.rb b/app/components/blacklight/system/flash_message_component.rb index ffa93efb2f..b16ea750bc 100644 --- a/app/components/blacklight/system/flash_message_component.rb +++ b/app/components/blacklight/system/flash_message_component.rb @@ -7,7 +7,7 @@ class FlashMessageComponent < ViewComponent::Base with_collection_parameter :message - def initialize(message: nil, type:) + def initialize(type:, message: nil) @message = message @classes = alert_class(type) end diff --git a/app/controllers/concerns/blacklight/bookmarks.rb b/app/controllers/concerns/blacklight/bookmarks.rb index 12750666a6..c8d55956fd 100644 --- a/app/controllers/concerns/blacklight/bookmarks.rb +++ b/app/controllers/concerns/blacklight/bookmarks.rb @@ -85,7 +85,7 @@ def create end if request.xhr? - success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } }) : render(json: current_or_guest_user.errors.full_messages, status: "500") + success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } }) : render(json: current_or_guest_user.errors.full_messages, status: :internal_server_error) else if @bookmarks.any? && success flash[:notice] = I18n.t('blacklight.bookmarks.add.success', count: @bookmarks.length) @@ -119,7 +119,7 @@ def destroy redirect_back fallback_location: bookmarks_path, notice: I18n.t('blacklight.bookmarks.remove.success') end elsif request.xhr? - head 500 # ajaxy request needs no redirect and should not have flash set + head :internal_server_error # ajaxy request needs no redirect and should not have flash set else redirect_back fallback_location: bookmarks_path, flash: { error: I18n.t('blacklight.bookmarks.remove.failure') } end diff --git a/app/controllers/concerns/blacklight/controller.rb b/app/controllers/concerns/blacklight/controller.rb index 84f7b1cda9..c103fdb25b 100644 --- a/app/controllers/concerns/blacklight/controller.rb +++ b/app/controllers/concerns/blacklight/controller.rb @@ -80,8 +80,8 @@ def search_action_url options = {} end def search_action_path *args - if args.first.is_a? Hash - args.first[:only_path] = true if args.first[:only_path].nil? + if args.first.is_a?(Hash) && args.first[:only_path].nil? + args.first[:only_path] = true end search_action_url(*args) diff --git a/app/models/concerns/blacklight/document/email.rb b/app/models/concerns/blacklight/document/email.rb index cceae39787..e676276e25 100644 --- a/app/models/concerns/blacklight/document/email.rb +++ b/app/models/concerns/blacklight/document/email.rb @@ -21,6 +21,6 @@ def to_email_text(config = nil) body << I18n.t('blacklight.email.text.language', value: semantics[:language].join(" ")) if semantics[:language].present? end - return body.join("\n") unless body.empty? + body.join("\n") unless body.empty? end end diff --git a/app/models/concerns/blacklight/document/sms.rb b/app/models/concerns/blacklight/document/sms.rb index 041226ae3f..982ce791b7 100644 --- a/app/models/concerns/blacklight/document/sms.rb +++ b/app/models/concerns/blacklight/document/sms.rb @@ -19,6 +19,6 @@ def to_sms_text(config = nil) body << I18n.t('blacklight.sms.text.author', value: semantics[:author].first) if semantics[:author].present? end - return body.join unless body.empty? + body.join unless body.empty? end end diff --git a/app/models/record_mailer.rb b/app/models/record_mailer.rb index a6d80d5cf4..2e01608189 100644 --- a/app/models/record_mailer.rb +++ b/app/models/record_mailer.rb @@ -3,15 +3,15 @@ class RecordMailer < ActionMailer::Base def email_record(documents, details, url_gen_params) title = begin - title_field = details[:config].email.title_field - if title_field - [documents.first[title_field]].flatten.first - else - documents.first.to_semantic_values[:title] - end - rescue - I18n.t('blacklight.email.text.default_title') - end + title_field = details[:config].email.title_field + if title_field + [documents.first[title_field]].flatten.first + else + documents.first.to_semantic_values[:title] + end + rescue + I18n.t('blacklight.email.text.default_title') + end subject = I18n.t('blacklight.email.text.subject', count: documents.length, diff --git a/app/views/catalog/_document.atom.builder b/app/views/catalog/_document.atom.builder index fad2ca1b2e..990bea8740 100644 --- a/app/views/catalog/_document.atom.builder +++ b/app/views/catalog/_document.atom.builder @@ -29,8 +29,8 @@ xml.entry do end #If they asked for a format, give it to them. - if (params["content_format"] && - document.export_formats[params["content_format"].to_sym]) + if params["content_format"] && + document.export_formats[params["content_format"].to_sym] type = document.export_formats[params["content_format"].to_sym][:content_type] diff --git a/lib/blacklight.rb b/lib/blacklight.rb index aee37da93a..926bff9027 100644 --- a/lib/blacklight.rb +++ b/lib/blacklight.rb @@ -114,9 +114,7 @@ def self.blacklight_yml? end def self.logger - @logger ||= begin - ::Rails.logger if defined? Rails && Rails.respond_to?(:logger) - end + @logger ||= (::Rails.logger if defined? Rails && Rails.respond_to?(:logger)) end def self.logger= logger diff --git a/lib/blacklight/component.rb b/lib/blacklight/component.rb index f9db2466f3..24dd5449be 100644 --- a/lib/blacklight/component.rb +++ b/lib/blacklight/component.rb @@ -47,7 +47,7 @@ def templates component_class.sidecar_files(extensions).each_with_object([]) do |path, memo| pieces = File.basename(path).split(".") - app_path = "#{Rails.root}/#{path.slice(path.index(component_class.view_component_path)..-1)}" + app_path = "#{Rails.root.join("#{path.slice(path.index(component_class.view_component_path)..-1)}")}" memo << { path: File.exist?(app_path) ? app_path : path, diff --git a/lib/blacklight/configuration.rb b/lib/blacklight/configuration.rb index 75e2237074..c7a7a73b48 100644 --- a/lib/blacklight/configuration.rb +++ b/lib/blacklight/configuration.rb @@ -529,14 +529,13 @@ def view_config(view_type = nil, action_name: :index) view_type = nil end - @view_config[[view_type, action_name]] ||= begin - if view_type.nil? - action_config(action_name) - else - base_config = action_config(action_name) - base_config.merge(view.fetch(view_type, {})) - end - end + @view_config[[view_type, action_name]] ||= if view_type.nil? + action_config(action_name) + else + base_config = action_config(action_name) + base_config.merge(view.fetch(view_type, {})) + end + end # YARD will include inline disabling as docs, cannot do multiline inside @!macro. AND this must be separate from doc block. diff --git a/lib/blacklight/search_state.rb b/lib/blacklight/search_state.rb index 7e2343fb6b..41e673908e 100644 --- a/lib/blacklight/search_state.rb +++ b/lib/blacklight/search_state.rb @@ -10,8 +10,7 @@ class SearchState extend Deprecation include Blacklight::Deprecations::SearchStateNormalization - attr_reader :blacklight_config # Must be called blacklight_config, because Blacklight::Facet calls blacklight_config. - attr_reader :params + attr_reader :blacklight_config, :params # Must be called blacklight_config, because Blacklight::Facet calls blacklight_config. # This method is never accessed in this class, but may be used by subclasses that need # to access the url_helpers diff --git a/lib/blacklight/solr/response/pagination_methods.rb b/lib/blacklight/solr/response/pagination_methods.rb index a193c07d5b..880e83513e 100644 --- a/lib/blacklight/solr/response/pagination_methods.rb +++ b/lib/blacklight/solr/response/pagination_methods.rb @@ -3,15 +3,15 @@ module Blacklight::Solr::Response::PaginationMethods include Kaminari::PageScopeMethods include Kaminari::ConfigurationMethods::ClassMethods - def limit_value #:nodoc: + def limit_value # :nodoc: rows end - def offset_value #:nodoc: + def offset_value # :nodoc: start end - def total_count #:nodoc: + def total_count # :nodoc: total end diff --git a/spec/features/search_results_spec.rb b/spec/features/search_results_spec.rb index dd2686e52e..f47d58877d 100644 --- a/spec/features/search_results_spec.rb +++ b/spec/features/search_results_spec.rb @@ -84,10 +84,10 @@ def number_of_results_from_page(page) tmp_value = Capybara.ignore_hidden_elements Capybara.ignore_hidden_elements = false val = begin - page.find("meta[name=totalResults]")['content'].to_i - rescue StandardError - 0 - end + page.find("meta[name=totalResults]")['content'].to_i + rescue StandardError + 0 + end Capybara.ignore_hidden_elements = tmp_value val end diff --git a/spec/models/blacklight/configurable_spec.rb b/spec/models/blacklight/configurable_spec.rb index 6f5b79d2cb..d7e9312aa1 100644 --- a/spec/models/blacklight/configurable_spec.rb +++ b/spec/models/blacklight/configurable_spec.rb @@ -93,7 +93,7 @@ class Child < Parent instance.blacklight_config.bar << "123" expect(instance.blacklight_config).not_to eq klass.blacklight_config expect(klass.blacklight_config.foo).to eq "bar" - expect(instance.blacklight_config.foo).to eq "bar" + expect(instance.blacklight_config.foo).to eq "bar" expect(klass.blacklight_config.bar).not_to include("123") expect(instance.blacklight_config.bar).to include("asd", "123") end diff --git a/spec/models/blacklight/solr/search_builder_spec.rb b/spec/models/blacklight/solr/search_builder_spec.rb index c972f1b9be..46411692fa 100644 --- a/spec/models/blacklight/solr/search_builder_spec.rb +++ b/spec/models/blacklight/solr/search_builder_spec.rb @@ -508,7 +508,7 @@ describe 'the search field query_builder config' do let(:blacklight_config) do Blacklight::Configuration.new do |config| - config.add_search_field('built_query', query_builder: ->(builder, *_args) { [builder.blacklight_params[:q].reverse, qq1: 'xyz'] }) + config.add_search_field('built_query', query_builder: ->(builder, *_args) { [builder.blacklight_params[:q].reverse, { qq1: 'xyz' }] }) end end diff --git a/tasks/blacklight.rake b/tasks/blacklight.rake index eaef9f9b37..7e1b39bacb 100644 --- a/tasks/blacklight.rake +++ b/tasks/blacklight.rake @@ -20,7 +20,7 @@ def system_with_error_handling(*args) end end -def with_solr +def with_solr(&block) # We're being invoked by the app entrypoint script and solr is already up via docker-compose if ENV['SOLR_ENV'] == 'docker-compose' yield @@ -36,9 +36,7 @@ def with_solr end else SolrWrapper.wrap do |solr| - solr.with_collection do - yield - end + solr.with_collection(&block) end end end