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 committed Apr 12, 2024
1 parent e21fbc2 commit 104aeae
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 84 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
29 changes: 7 additions & 22 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
inherit_from:
- .rubocop_todo.yml

require:
- rubocop-performance
- rubocop-rails
- rubocop-minitest
inherit_gem:
theforeman-rubocop:
- strictest.yml

AllCops:
TargetRubyVersion: 2.7
TargetRailsVersion: 5.2
Exclude:
- 'extras/**/*'
- 'locale/**/*'
- 'node_modules/**/*'
- 'vendor/**/*'
- "extras/**/*"
- "locale/**/*"
- "node_modules/**/*"

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

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

Rails:
Enabled: true

Rails/ActionFilter:
EnforcedStyle: action

Expand All @@ -43,14 +37,5 @@ Rails/SkipsModelValidations:
Style/FormatStringToken:
EnforcedStyle: template

Style/HashSyntax:
EnforcedStyle: no_mixed_keys

Style/RaiseArgs:
EnforcedStyle: compact

Style/SymbolArray:
EnforcedStyle: brackets

Style/Documentation:
Enabled: false
228 changes: 171 additions & 57 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,78 +1,116 @@
# 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-03-29 19:24:18 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: 1
# Configuration parameters: Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'foreman_ansible.gemspec'

# Offense count: 210
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: with_first_argument, with_fixed_indentation
Layout/ArgumentAlignment:
Enabled: false

# Offense count: 5
# Cop supports --auto-correct.
Layout/ClosingHeredocIndentation:
Exclude:
- 'test/unit/helpers/ansible_reports_helper_test.rb'

# Offense count: 6
# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_braces
Layout/FirstHashElementIndentation:
# SupportedStyles: aligned, indented
Layout/LineEndStringConcatenationIndentation:
Exclude:
- 'test/functional/ansible_variables_controller_test.rb'
- 'lib/foreman_ansible/register.rb'

# Offense count: 1
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: AllowInHeredoc.
Layout/TrailingWhitespace:
Lint/BooleanSymbol:
Exclude:
- 'db/migrate/20200421201839_update_ansible_inv_template_name.rb'
- 'app/models/ansible_variable.rb'

# Offense count: 2
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: 6
# Cop supports --auto-correct.
Lint/BooleanSymbol:
# Configuration parameters: EnforcedStyle.
# SupportedStyles: strict, consistent
Lint/SymbolConversion:
Exclude:
- 'app/models/ansible_variable.rb'
- 'app/services/foreman_ansible/ansible_report_scanner.rb'

# Offense count: 3
# Offense count: 2
# Cop supports --auto-correct.
Minitest/AssertEmpty:
Exclude:
- 'test/functional/hosts_controller_test.rb'

# Offense count: 1
# Offense count: 3
# Cop supports --auto-correct.
Minitest/AssertEqual:
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
# Offense count: 1
# Cop supports --auto-correct.
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.
Minitest/AssertTruthy:
Exclude:
- 'test/unit/services/inventory_creator_test.rb'

# Offense count: 10
# Offense count: 2
Minitest/AssertWithExpectedArgument:
Exclude:
- 'test/functional/api/v2/hosts_controller_test.rb'
- 'test/functional/hosts_controller_test.rb'

# Offense count: 2
# Cop supports --auto-correct.
Minitest/GlobalExpectations:
Minitest/LiteralAsActualArgument:
Exclude:
- 'test/unit/concerns/host_managed_extensions_test.rb'
- 'test/unit/concerns/hostgroup_extensions_test.rb'
- 'test/unit/ansible_provider_test.rb'

# Offense count: 1
Minitest/MultipleAssertions:
Max: 13

# Offense count: 1
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: io, id, to, by, on, in, at, ip, db, os, pp
# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to
Naming/MethodParameterName:
Exclude:
- 'app/helpers/foreman_ansible/ansible_roles_helper.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect.
Performance/StringInclude:
Exclude:
- 'app/services/foreman_ansible/ansible_report_scanner.rb'
- 'app/services/foreman_ansible/insights_plan_runner.rb'

# Offense count: 1
# Configuration parameters: Include.
# Include: db/migrate/*.rb
Expand All @@ -97,7 +135,21 @@ Rails/InverseOf:
- 'app/models/concerns/foreman_ansible/host_managed_extensions.rb'
- 'app/models/concerns/foreman_ansible/hostgroup_extensions.rb'

# Offense count: 19
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: Include.
# Include: config/routes.rb, config/routes/**/*.rb
Rails/MatchRoute:
Exclude:
- 'config/routes.rb'

# Offense count: 4
# Cop supports --auto-correct.
Rails/Pluck:
Exclude:
- 'test/foreman_ansible/helpers/ansible_roles_helper_test.rb'

# Offense count: 17
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, Include.
# SupportedStyles: assert_not, refute
Expand All @@ -112,54 +164,56 @@ Rails/RefuteMethods:
- 'test/unit/services/inventory_creator_test.rb'
- 'test/unit/services/ui_roles_importer_test.rb'

# Offense count: 13
Style/Documentation:
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: exists, where
Rails/WhereExists:
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'
- 'app/models/ansible_variable.rb'

# Offense count: 2
# Offense count: 1
# Cop supports --auto-correct.
Style/ExpandPathArguments:
Style/CaseLikeIf:
Exclude:
- 'foreman_ansible.gemspec'
- 'foreman_ansible_core.gemspec'
- 'app/helpers/foreman_ansible/ansible_roles_data_preparations.rb'

# Offense count: 2
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: annotated, template, unannotated
Style/FormatStringToken:
# 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
# Offense count: 49
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Enabled: false

# Offense count: 13
# Offense count: 1
# Cop supports --auto-correct.
Style/GlobalStdStream:
Exclude:
- 'db/migrate/20180410125416_rename_ansible_job_categories.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowSplatArgument.
Style/HashConversion:
Exclude:
- 'app/services/foreman_ansible/inventory_creator.rb'

# Offense count: 947
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
Style/HashSyntax:
Exclude:
- 'app/models/ansible_role.rb'
- 'app/models/concerns/foreman_ansible/host_managed_extensions.rb'
- 'app/services/foreman_ansible/renderer_methods.rb'
Enabled: false

# Offense count: 3
# Cop supports --auto-correct.
Expand All @@ -169,13 +223,46 @@ Style/IfUnlessModifier:
- 'app/services/foreman_ansible/variables_importer.rb'
- 'db/seeds.d/62_ansible_proxy_feature.rb'

# Offense count: 3
Style/OpenStructUse:
Exclude:
- 'test/unit/services/insights_plan_runner_test.rb'
- 'test/unit/services/inventory_creator_test.rb'

# Offense count: 1
# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'app/helpers/foreman_ansible/ansible_roles_data_preparations.rb'

# Offense count: 2
# Cop supports --auto-correct.
Style/RedundantAssignment:
Exclude:
- 'app/services/foreman_ansible/api_roles_importer.rb'
- 'app/services/foreman_ansible/inventory_creator.rb'

# Offense count: 1
# Cop supports --auto-correct.
Style/RedundantBegin:
Exclude:
- 'lib/tasks/foreman_ansible_tasks.rake'

# Offense count: 43
# Offense count: 6
# Cop supports --auto-correct.
Style/RedundantRegexpEscape:
Exclude:
- 'config/routes.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: Mode.
Style/StringConcatenation:
Exclude:
- 'app/lib/proxy_api/ansible.rb'

# Offense count: 29
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Expand All @@ -190,7 +277,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: 41
# Cop supports --auto-correct.
# Configuration parameters: MinSize.
# SupportedStyles: percent, brackets
Style/SymbolArray:
EnforcedStyle: brackets

# Offense count: 12
# Cop supports --auto-correct.
# 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'
- 'app/services/foreman_ansible/insights_notification_builder.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: 70
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInHashLiteral:
Enabled: false
Loading

0 comments on commit 104aeae

Please sign in to comment.