Skip to content

Commit

Permalink
Use theforeman-rubocop gem
Browse files Browse the repository at this point in the history
Inherited strictest.yml here, because this closely matches with what
rules we already have in our rubocop.yml config. Also dropped Rails,
Style/HashSyntax, Style/Documentation and Style/SymbolArray from here
because that was included in the inherited file.
  • Loading branch information
archanaserver authored and nofaralfasi committed Jul 27, 2024
1 parent 88ed856 commit afd7faa
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 99 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ruby_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 4 additions & 14 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,7 +16,7 @@ AllCops:

# Just so it looks like core Foreman
Layout/DotPosition:
EnforcedStyle: 'trailing'
EnforcedStyle: "trailing"

Layout/EmptyLineAfterGuardClause:
Enabled: false
Expand All @@ -31,12 +30,6 @@ Metrics:
Performance/RegexpMatch:
Enabled: false

Rails:
Enabled: true

Rails/ActionFilter:
EnforcedStyle: action

Rails/SkipsModelValidations:
Enabled: false

Expand All @@ -51,6 +44,3 @@ Style/RaiseArgs:

Style/SymbolArray:
EnforcedStyle: brackets

Style/Documentation:
Enabled: false
236 changes: 156 additions & 80 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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/**/*
Expand All @@ -112,71 +136,96 @@ 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'
- 'app/services/foreman_ansible/variables_importer.rb'
- '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:
Expand All @@ -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
Loading

0 comments on commit afd7faa

Please sign in to comment.