diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index fcc38c87..d6a0d381 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -10,6 +10,8 @@ jobs: rubocop: name: Rubocop uses: theforeman/actions/.github/workflows/rubocop.yml@v0 + with: + command: bundle exec rubocop --parallel --format github test: name: Tests diff --git a/.rubocop.yml b/.rubocop.yml index 70f17dc9..1e0459ed 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,10 @@ # TODO: remove this inherit_from: .rubocop_todo.yml +inherit_gem: + theforeman-rubocop: + - lenient.yml + AllCops: TargetRubyVersion: 2.7 @@ -8,12 +12,6 @@ MethodLength: Description: 'Avoid methods longer than 30 lines of code.' Max: 30 # default is 10 -Documentation: - Enabled: false - -StringLiterals: - Enabled: false - HashSyntax: Enabled: false @@ -71,12 +69,6 @@ RedundantReturn: SingleLineBlockParams: Enabled: false -FormatString: - Enabled: false # we use % for i18n - -Style/Alias: - Enabled: false - Style/MultilineMethodCallBraceLayout: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 932613fc..0d01d46b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,62 +1,47 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-05-10 13:40:03 UTC using RuboCop version 1.63.5. +# on 2024-05-28 17:52:39 UTC using RuboCop version 1.23.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 # versions of RuboCop, may require this file to be generated again. -# Offense count: 75 -# This cop supports safe autocorrection (--autocorrect). +# Offense count: 346 +# Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: with_first_argument, with_fixed_indentation Layout/ArgumentAlignment: Enabled: false # Offense count: 29 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. Layout/ClosingParenthesisIndentation: Exclude: - 'lib/hammer_cli_katello.rb' - 'test/functional/repository/update_test.rb' - 'test/functional/repository/upload_test.rb' -# Offense count: 10 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLineAfterGuardClause: - Exclude: - - 'lib/hammer_cli_katello/command_extensions/kickstart_repository.rb' - - 'lib/hammer_cli_katello/content_export_helper.rb' - - 'lib/hammer_cli_katello/content_view_component.rb' - - 'lib/hammer_cli_katello/content_view_purge.rb' - - 'lib/hammer_cli_katello/id_resolver.rb' - - 'lib/hammer_cli_katello/local_helper.rb' - - 'test/functional/product/product_helpers.rb' - # Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. Layout/EmptyLineAfterMagicComment: Exclude: - 'hammer_cli_katello.gemspec' -# Offense count: 7 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. -Layout/ExtraSpacing: - Exclude: - - 'test/functional/acs/info_test.rb' - - 'test/functional/activation_key/info_test.rb' - - 'test/functional/host/extensions/info_test.rb' - - 'test/functional/hostgroup/info_test.rb' - - 'test/functional/repository/info_test.rb' - # Offense count: 13 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. # Configuration parameters: IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_brackets Layout/FirstArrayElementIndentation: EnforcedStyle: consistent +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_braces +Layout/FirstHashElementIndentation: + Exclude: + - 'test/functional/host/extensions/create_test.rb' + # Offense count: 17 # Cop supports --auto-correct. # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. @@ -69,7 +54,7 @@ Layout/HashAlignment: - 'test/functional/content_export/complete/version_test.rb' # Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. Layout/HeredocIndentation: Exclude: - 'test/functional/activation_key/product_content_test.rb' @@ -77,7 +62,7 @@ Layout/HeredocIndentation: - 'test/functional/product/list_test.rb' # Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. # Configuration parameters: IndentationWidth, EnforcedStyle. # SupportedStyles: spaces, tabs Layout/IndentationStyle: @@ -85,7 +70,7 @@ Layout/IndentationStyle: - 'lib/hammer_cli_katello/activation_key.rb' # Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. Layout/LeadingEmptyLines: Exclude: - 'lib/hammer_cli_katello/exception_handler.rb' @@ -100,12 +85,6 @@ Lint/ConstantDefinitionInBlock: - 'test/functional/capsule/content/cancel_synchronization_test.rb' - 'test/functional/local_helper_test.rb' -# Offense count: 1 -# Configuration parameters: DebuggerMethods, DebuggerRequires. -Lint/Debugger: - Exclude: - - 'test/functional/content_view/filter/create_test.rb' - # Offense count: 1 # Configuration parameters: AllowComments. Lint/EmptyFile: @@ -125,7 +104,6 @@ Lint/MissingCopEnableDirective: - 'test/functional/package/list_test.rb' # Offense count: 4 -# Configuration parameters: AllowedParentClasses. Lint/MissingSuper: Exclude: - 'lib/hammer_cli_katello/content_view.rb' @@ -134,7 +112,7 @@ Lint/MissingSuper: - 'lib/hammer_cli_katello/option_sources/lifecycle_environment_params.rb' # Offense count: 7 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. Lint/RedundantCopDisableDirective: Exclude: - 'lib/hammer_cli_katello/id_resolver.rb' @@ -144,35 +122,35 @@ Lint/RedundantCopDisableDirective: - 'test/functional/repository/info_test.rb' # Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. Lint/RedundantCopEnableDirective: Exclude: - 'lib/hammer_cli_katello/id_resolver.rb' - 'test/functional/repository/update_test.rb' # Offense count: 29 -# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. +# Configuration parameters: IgnoredMethods, CountRepeatedAttributes. Metrics/AbcSize: Max: 37 # Offense count: 182 -# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. -# AllowedMethods: refine +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. +# IgnoredMethods: refine Metrics/BlockLength: Max: 264 # Offense count: 5 -# Configuration parameters: AllowedMethods, AllowedPatterns. +# Configuration parameters: IgnoredMethods. Metrics/CyclomaticComplexity: Max: 10 # Offense count: 2 -# Configuration parameters: AllowedMethods, AllowedPatterns. +# Configuration parameters: IgnoredMethods. Metrics/PerceivedComplexity: Max: 11 # Offense count: 51 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. Migration/DepartmentName: Exclude: - 'lib/hammer_cli_katello.rb' @@ -189,8 +167,37 @@ Migration/DepartmentName: - 'test/functional/repository/update_test.rb' - 'test/functional/repository/upload_test.rb' +# Offense count: 22 +# Cop supports --auto-correct. +Minitest/AssertIncludes: + Exclude: + - 'test/functional/content_units/info_test.rb' + - 'test/functional/content_units/list_test.rb' + - 'test/functional/content_view/purge_test.rb' + - 'test/functional/erratum/list_test.rb' + - 'test/functional/package/list_test.rb' + - 'test/functional/repository/upload_test.rb' + - 'test/functional/srpm/list_test.rb' + - 'test/functional/subscription/list_test.rb' + +# Offense count: 13 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, Include. +# Include: **/test/**/*, **/*_test.rb, **/spec/**/*, **/*_spec.rb +# SupportedStyles: _, any, expect, value +Minitest/GlobalExpectations: + Exclude: + - 'test/unit/id_resolver_test.rb' + - 'test/unit/search_options_creators_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Minitest/RefuteFalse: + Exclude: + - 'test/functional/test_helper.rb' + # Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: lowercase, uppercase Naming/HeredocDelimiterCase: @@ -201,7 +208,7 @@ Naming/HeredocDelimiterCase: # Offense count: 7 # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. -# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to +# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to Naming/MethodParameterName: Exclude: - 'lib/hammer_cli_katello/content_view_component.rb' @@ -209,34 +216,99 @@ Naming/MethodParameterName: - 'lib/hammer_cli_katello/exception_handler.rb' # Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. # Configuration parameters: PreferredName. Naming/RescuedExceptionsVariableName: Exclude: - 'Rakefile' +# Offense count: 2 +# Configuration parameters: MinSize. +Performance/CollectionLiteralInLoop: + Exclude: + - 'lib/hammer_cli_katello/search_options_creators.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Performance/RegexpMatch: + Exclude: + - 'lib/hammer_cli_katello/unsupported_katello_agent_command_helper.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Rails/ArelStar: + Exclude: + - 'lib/hammer_cli_katello/content_export_helper.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: Include. +# Include: **/test/**/* +Rails/AssertNot: + Exclude: + - 'test/functional/test_helper.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: Whitelist, AllowedMethods, AllowedReceivers. +# Whitelist: find_by_sql +# AllowedMethods: find_by_sql +# AllowedReceivers: Gem::Specification +Rails/DynamicFindBy: + Exclude: + - 'lib/hammer_cli_katello/command_extensions/lifecycle_environment.rb' + - 'lib/hammer_cli_katello/command_extensions/lifecycle_environments.rb' + - 'lib/hammer_cli_katello/content_view.rb' + - 'lib/hammer_cli_katello/content_view_name_resolvable.rb' + - 'lib/hammer_cli_katello/content_view_purge.rb' + +# Offense count: 1 +# Configuration parameters: Include. +# Include: app/**/*.rb, config/**/*.rb, lib/**/*.rb +Rails/Exit: + Exclude: + - 'lib/hammer_cli_katello/content_export_helper.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: Include. +# Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb +Rails/Output: + Exclude: + - 'lib/hammer_cli_katello/host_collection.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, Include. +# SupportedStyles: assert_not, refute +# Include: **/test/**/* +Rails/RefuteMethods: + Exclude: + - 'test/functional/erratum/erratum_helpers.rb' + - 'test/functional/product/create_test.rb' + - 'test/functional/sync_plan/create_test.rb' + # Offense count: 3 Security/Open: Exclude: - 'lib/hammer_cli_katello/content_import.rb' -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). +# Offense count: 2 # Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols. # SupportedStyles: inline, group Style/AccessModifierDeclarations: Exclude: - 'lib/hammer_cli_katello/content_view_purge.rb' -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: MinBranchesCount. +# Offense count: 2 +# Cop supports --auto-correct. Style/CaseLikeIf: Exclude: - 'lib/hammer_cli_katello/content_export_helper.rb' + - 'lib/hammer_cli_katello/id_name_options_validator.rb' # Offense count: 9 -# This cop supports unsafe autocorrection (--autocorrect-all). +# Cop supports --auto-correct. Style/CommentedKeyword: Exclude: - 'lib/hammer_cli_katello/ping.rb' @@ -244,7 +316,7 @@ Style/CommentedKeyword: - 'test/unit/search_options_creators_test.rb' # Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. # SupportedStyles: assign_to_condition, assign_inside_condition Style/ConditionalAssignment: @@ -252,28 +324,19 @@ Style/ConditionalAssignment: - 'test/functional/erratum/erratum_helpers.rb' # Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. Style/EmptyLiteral: Exclude: - 'test/unit/search_options_creators_test.rb' -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect, EnforcedStyle. -# SupportedStyles: compact, expanded -Style/EmptyMethod: - Exclude: - - 'test/unit/search_options_creators_test.rb' - # Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. Style/ExpandPathArguments: Exclude: - 'hammer_cli_katello.gemspec' # Offense count: 46 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns. +# Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, IgnoredMethods. # SupportedStyles: annotated, template, unannotated Style/FormatStringToken: Exclude: @@ -293,21 +356,20 @@ Style/FormatStringToken: - 'lib/hammer_cli_katello/subscription.rb' # Offense count: 258 -# This cop supports unsafe autocorrection (--autocorrect-all). +# Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never Style/FrozenStringLiteralComment: Enabled: false # Offense count: 2 -# This cop supports unsafe autocorrection (--autocorrect-all). +# Cop supports --auto-correct. Style/GlobalStdStream: Exclude: - 'hammer_cli_katello.gemspec' -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. +# Offense count: 7 +# Configuration parameters: MinBodyLength. Style/GuardClause: Exclude: - 'lib/hammer_cli_katello/content_export_helper.rb' @@ -315,18 +377,8 @@ Style/GuardClause: - 'lib/hammer_cli_katello/option_sources/lifecycle_environment_params.rb' - 'test/functional/test_helper.rb' -# Offense count: 3 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AllowedReceivers. -# AllowedReceivers: Thread.current -Style/HashEachMethods: - Exclude: - - 'lib/hammer_cli_katello/capsule.rb' - - 'lib/hammer_cli_katello/command_extensions/ping.rb' - - 'lib/hammer_cli_katello/ping.rb' - # Offense count: 2 -# This cop supports unsafe autocorrection (--autocorrect-all). +# Cop supports --auto-correct. # Configuration parameters: InverseMethods, InverseBlocks. Style/InverseMethods: Exclude: @@ -339,7 +391,7 @@ Style/MixinUsage: - 'test/unit/messages_test.rb' # Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. Style/MultilineIfModifier: Exclude: - 'lib/hammer_cli_katello/content_export_helper.rb' @@ -353,31 +405,31 @@ Style/OptionalBooleanParameter: - 'test/functional/erratum/erratum_helpers.rb' # Offense count: 496 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. # Configuration parameters: PreferredDelimiters. Style/PercentLiteralDelimiters: Enabled: false # Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. Style/RedundantAssignment: Exclude: - 'lib/hammer_cli_katello/repository.rb' # Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. Style/RedundantBegin: Exclude: - 'lib/hammer_cli_katello/command_extensions/content_source.rb' # Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. Style/RedundantCondition: Exclude: - 'lib/hammer_cli_katello/repository.rb' # Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. Style/RedundantFileExtensionInRequire: Exclude: - 'test/functional/content_units/info_test.rb' @@ -386,19 +438,13 @@ Style/RedundantFileExtensionInRequire: - 'test/functional/file/list_test.rb' # Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantParentheses: - Exclude: - - 'lib/hammer_cli_katello/content_view_component.rb' - -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). +# Cop supports --auto-correct. Style/RedundantSort: Exclude: - 'lib/hammer_cli_katello/id_resolver.rb' # Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: implicit, explicit Style/RescueStandardError: @@ -408,60 +454,43 @@ Style/RescueStandardError: - 'lib/hammer_cli_katello/repository.rb' # Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. +# Cop supports --auto-correct. +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods. # AllowedMethods: present?, blank?, presence, try, try! Style/SafeNavigation: Exclude: - 'lib/hammer_cli_katello/content_view.rb' # Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). +# Cop supports --auto-correct. Style/SingleArgumentDig: Exclude: - 'lib/hammer_cli_katello/capsule.rb' # Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). +# Cop supports --auto-correct. Style/StderrPuts: Exclude: - 'hammer_cli_katello.gemspec' -# Offense count: 20 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: Mode. -Style/StringConcatenation: - Exclude: - - 'lib/hammer_cli_katello/content_export.rb' - - 'lib/hammer_cli_katello/content_export_helper.rb' - - 'test/functional/content_export/complete/library_test.rb' - - 'test/functional/content_export/complete/repository_test.rb' - - 'test/functional/content_export/complete/version_test.rb' - - 'test/functional/content_export/generate_listing_test.rb' - - 'test/functional/content_export/generate_metadata_test.rb' - - 'test/functional/content_export/incremental/library_test.rb' - - 'test/functional/content_export/incremental/repository_test.rb' - - 'test/functional/content_export/incremental/version_test.rb' - - 'test/test_helper.rb' - -# Offense count: 42 -# This cop supports safe autocorrection (--autocorrect). +# Offense count: 1 +# Cop supports --auto-correct. # Configuration parameters: . # SupportedStyles: percent, brackets Style/SymbolArray: EnforcedStyle: percent MinSize: 6 -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: WordRegex. -# SupportedStyles: percent, brackets -Style/WordArray: - EnforcedStyle: percent - MinSize: 4 +# Offense count: 59 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArrayLiteral: + Enabled: false -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/ZeroLengthPredicate: - Exclude: - - 'lib/hammer_cli_katello/repository.rb' +# Offense count: 133 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInHashLiteral: + Enabled: false diff --git a/hammer_cli_katello.gemspec b/hammer_cli_katello.gemspec index d87494f5..aad6c647 100644 --- a/hammer_cli_katello.gemspec +++ b/hammer_cli_katello.gemspec @@ -65,6 +65,8 @@ Gem::Specification.new do |gem| gem.version = HammerCLIKatello.version gem.required_ruby_version = '>= 2.7', '< 3.2' + gem.add_dependency 'theforeman-rubocop', '~> 0.1.0' + gem.add_dependency 'hammer_cli_foreman', '~> 3.9' gem.add_dependency 'hammer_cli_foreman_tasks', '~> 0.0.20' end