diff --git a/.github/workflows/ruby_tests.yml b/.github/workflows/ruby_tests.yml index 98b48f72..da5886e9 100644 --- a/.github/workflows/ruby_tests.yml +++ b/.github/workflows/ruby_tests.yml @@ -16,6 +16,8 @@ jobs: rubocop: name: Rubocop uses: theforeman/actions/.github/workflows/rubocop.yml@v0 + with: + command: bundle exec rubocop --parallel --format github test_ruby: name: Ruby diff --git a/.rubocop.yml b/.rubocop.yml index 86c6e923..2ca64ed1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,10 +1,9 @@ inherit_from: - .rubocop_todo.yml -require: - - rubocop-performance - - rubocop-rails - - rubocop-minitest +inherit_gem: + theforeman-rubocop: + - default.yml AllCops: TargetRubyVersion: 2.7 @@ -17,7 +16,7 @@ AllCops: # Just so it looks like core Foreman Layout/DotPosition: - EnforcedStyle: 'trailing' + EnforcedStyle: "trailing" Layout/EmptyLineAfterGuardClause: Enabled: false @@ -31,12 +30,6 @@ Metrics: Performance/RegexpMatch: Enabled: false -Rails: - Enabled: true - -Rails/ActionFilter: - EnforcedStyle: action - Rails/SkipsModelValidations: Enabled: false @@ -51,6 +44,3 @@ Style/RaiseArgs: Style/SymbolArray: EnforcedStyle: brackets - -Style/Documentation: - Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 79b4382f..c03a7ad2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,85 +1,100 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2020-08-03 20:17:14 UTC using RuboCop version 0.87.1. +# on 2024-07-23 18:25:51 UTC using RuboCop version 1.64.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: 1 -# Cop supports --auto-correct. -Layout/ClosingHeredocIndentation: +# Configuration parameters: Severity, Include. +# Include: **/*.gemspec +Gemspec/RequiredRubyVersion: Exclude: - - 'test/unit/helpers/ansible_reports_helper_test.rb' + - 'foreman_ansible.gemspec' -# Offense count: 6 -# Cop supports --auto-correct. +# Offense count: 311 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_braces -Layout/FirstHashElementIndentation: - Exclude: - - 'test/functional/ansible_variables_controller_test.rb' +# SupportedStyles: with_first_argument, with_fixed_indentation +Layout/ArgumentAlignment: + Enabled: false -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: AllowInHeredoc. -Layout/TrailingWhitespace: +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +Layout/ClosingHeredocIndentation: Exclude: - - 'db/migrate/20200421201839_update_ansible_inv_template_name.rb' + - 'test/unit/helpers/ansible_reports_helper_test.rb' # Offense count: 2 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_brackets +Layout/FirstArrayElementIndentation: + EnforcedStyle: consistent + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). Lint/BooleanSymbol: Exclude: - 'app/models/ansible_variable.rb' -# Offense count: 3 -# Cop supports --auto-correct. +# Offense count: 2 +# Configuration parameters: AllowedParentClasses. +Lint/MissingSuper: + Exclude: + - 'app/services/foreman_ansible/import_playbooks_error_notification.rb' + - 'app/services/foreman_ansible/import_roles_and_variables_error_notification.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). Minitest/AssertEmpty: Exclude: - 'test/functional/hosts_controller_test.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Minitest/AssertEqual: +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +Minitest/AssertEmptyLiteral: Exclude: - - 'test/unit/lib/foreman_ansible_core/command_creator_test.rb' + - 'test/unit/concerns/host_managed_extensions_test.rb' + - 'test/unit/concerns/hostgroup_extensions_test.rb' + - 'test/unit/services/inventory_creator_test.rb' -# Offense count: 3 -# Cop supports --auto-correct. +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). Minitest/AssertIncludes: Exclude: - 'test/functional/api/v2/ansible_inventories_controller_test.rb' - - 'test/unit/lib/foreman_ansible_core/command_creator_test.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). Minitest/AssertTruthy: Exclude: - 'test/unit/services/inventory_creator_test.rb' -# Offense count: 10 -# Cop supports --auto-correct. -Minitest/GlobalExpectations: - Exclude: - - 'test/unit/concerns/host_managed_extensions_test.rb' - - 'test/unit/concerns/hostgroup_extensions_test.rb' - # Offense count: 1 # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. -# AllowedNames: io, id, to, by, on, in, at, ip, db, os, pp +# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to Naming/MethodParameterName: Exclude: - 'app/helpers/foreman_ansible/ansible_roles_helper.rb' # Offense count: 1 # Configuration parameters: Include. -# Include: db/migrate/*.rb +# Include: db/**/*.rb Rails/CreateTableWithTimestamps: Exclude: - 'db/migrate/20160705082036_create_ansible_role.rb' +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedMethods, AllowedPatterns. +# AllowedMethods: order, limit, select, lock +Rails/FindEach: + Exclude: + - 'app/graphql/mutations/hosts/assign_ansible_roles.rb' + - 'db/migrate/20221003153000_add_ansible_callback_enabled_to_templates.rb' + # Offense count: 4 # Configuration parameters: Include. # Include: app/models/**/*.rb @@ -90,15 +105,24 @@ Rails/HasManyOrHasOneDependent: - 'app/models/concerns/foreman_ansible/hostgroup_extensions.rb' # Offense count: 2 -# Configuration parameters: Include. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: numeric, symbolic +Rails/HttpStatus: + Exclude: + - 'test/functional/api/v2/hostgroups_controller_test.rb' + - 'test/functional/api/v2/hosts_controller_test.rb' + +# Offense count: 2 +# Configuration parameters: IgnoreScopes, Include. # Include: app/models/**/*.rb Rails/InverseOf: Exclude: - 'app/models/concerns/foreman_ansible/host_managed_extensions.rb' - 'app/models/concerns/foreman_ansible/hostgroup_extensions.rb' -# Offense count: 19 -# Cop supports --auto-correct. +# Offense count: 17 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, Include. # SupportedStyles: assert_not, refute # Include: **/test/**/* @@ -112,57 +136,55 @@ Rails/RefuteMethods: - 'test/unit/services/inventory_creator_test.rb' - 'test/unit/services/ui_roles_importer_test.rb' -# Offense count: 13 -Style/Documentation: - Exclude: - - 'spec/**/*' - - 'test/**/*' - - 'app/controllers/api/v2/ansible_inventories_controller.rb' - - 'app/controllers/ui_ansible_roles_controller.rb' - - 'app/helpers/foreman_ansible/hosts_helper_extensions.rb' - - 'app/models/concerns/foreman_ansible/host_managed_extensions.rb' - - 'app/services/foreman_ansible/ansible_info.rb' - - 'db/migrate/20190318094437_add_imported_attr_to_ansible_variables.rb' - - 'db/migrate/20190328114657_remove_top_level_ansible_variables_setting.rb' - - 'db/migrate/20191010074208_remove_ansible_implementation_setting.rb' - - 'db/migrate/20200421201839_update_ansible_inv_template_name.rb' - - 'lib/foreman_ansible_core/runner/ansible_runner.rb' - - 'lib/foreman_ansible_core/task_launcher/ansible_runner.rb' - - 'lib/foreman_ansible_core/task_launcher/playbook.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -Style/ExpandPathArguments: +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: MinBranchesCount. +Style/CaseLikeIf: Exclude: - - 'foreman_ansible.gemspec' - - 'foreman_ansible_core.gemspec' + - 'app/helpers/foreman_ansible/ansible_roles_data_preparations.rb' -# Offense count: 2 -# Configuration parameters: EnforcedStyle. -# SupportedStyles: annotated, template, unannotated -Style/FormatStringToken: +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect, EnforcedStyle. +# SupportedStyles: compact, expanded +Style/EmptyMethod: Exclude: - - 'lib/foreman_ansible_core/exception.rb' + - 'app/controllers/ansible_variables_controller.rb' + - 'app/controllers/api/v2/ansible_roles_controller.rb' + - 'app/controllers/api/v2/ansible_variables_controller.rb' -# Offense count: 22 -# Cop supports --auto-correct. +# Offense count: 49 +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never Style/FrozenStringLiteralComment: Enabled: false -# Offense count: 13 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/GlobalStdStream: + Exclude: + - 'db/migrate/20180410125416_rename_ansible_job_categories.rb' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. +# AllowedReceivers: Thread.current +Style/HashEachMethods: + Exclude: + - 'db/migrate/20210120150019_add_position_to_ansible_role.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +# SupportedShorthandSyntax: always, never, either, consistent, either_consistent Style/HashSyntax: Exclude: - - 'app/models/ansible_role.rb' - 'app/models/concerns/foreman_ansible/host_managed_extensions.rb' - - 'app/services/foreman_ansible/renderer_methods.rb' # Offense count: 3 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/IfUnlessModifier: Exclude: - 'app/services/foreman_ansible/proxy_api.rb' @@ -170,13 +192,40 @@ Style/IfUnlessModifier: - 'db/seeds.d/62_ansible_proxy_feature.rb' # Offense count: 1 -# Cop supports --auto-correct. +# Configuration parameters: AllowedMethods. +# AllowedMethods: respond_to_missing? +Style/OptionalBooleanParameter: + Exclude: + - 'app/helpers/foreman_ansible/ansible_roles_data_preparations.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantAssignment: + Exclude: + - 'app/services/foreman_ansible/api_roles_importer.rb' + - 'app/services/foreman_ansible/inventory_creator.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). Style/RedundantBegin: Exclude: - 'lib/tasks/foreman_ansible_tasks.rake' -# Offense count: 43 -# Cop supports --auto-correct. +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantRegexpEscape: + Exclude: + - 'config/routes.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Mode. +Style/StringConcatenation: + Exclude: + - 'app/lib/proxy_api/ansible.rb' + +# Offense count: 29 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes Style/StringLiterals: @@ -190,7 +239,34 @@ Style/StringLiterals: - 'app/views/ui_ansible_roles/index.json.rabl' - 'app/views/ui_ansible_roles/main.json.rabl' - 'app/views/ui_ansible_roles/show.json.rabl' - - 'lib/foreman_ansible_core/runner/ansible_runner.rb' - 'test/functional/api/v2/ansible_inventories_controller_test.rb' - - 'test/unit/services/fact_parser_test.rb' - 'test/unit/services/inventory_creator_test.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, AllowSafeAssignment. +# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex +Style/TernaryParentheses: + Exclude: + - 'app/helpers/foreman_ansible/ansible_roles_data_preparations.rb' + +# Offense count: 10 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArrayLiteral: + Exclude: + - 'app/helpers/foreman_ansible/ansible_roles_data_preparations.rb' + - 'app/lib/proxy_api/ansible.rb' + - 'app/models/foreman_ansible/ansible_provider.rb' + - 'db/seeds.d/100_common_parameters.rb' + - 'db/seeds.d/90_notification_blueprints.rb' + - 'lib/foreman_ansible/register.rb' + - 'test/unit/helpers/ansible_reports_helper_test.rb' + +# Offense count: 65 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInHashLiteral: + Enabled: false diff --git a/Gemfile b/Gemfile index 6df201af..263643cd 100644 --- a/Gemfile +++ b/Gemfile @@ -2,9 +2,6 @@ source 'http://rubygems.org' -gemspec :name => 'foreman_ansible' +gemspec -gem 'rubocop', '~> 0.87.0' -gem 'rubocop-minitest', '~> 0.9.0' -gem 'rubocop-performance', '~> 1.5.2' -gem 'rubocop-rails', '~> 2.7.1' +gem 'theforeman-rubocop', '~> 0.1.0'