Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use theforeman-rubocop gem #157

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Rubocop
uses: theforeman/actions/.github/workflows/rubocop.yml@v0
with:
command: bundle exec rubocop
command: bundle exec rubocop --parallel --format github

test:
name: Ruby
Expand Down
67 changes: 3 additions & 64 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,14 @@
require:
- rubocop-performance
- rubocop-rails
- rubocop-minitest

# TODO: remove this file by either moving cops here or fixing code
inherit_from:
- .rubocop_todo.yml

AllCops:
TargetRubyVersion: 2.5
TargetRailsVersion: 5.2
Exclude:
- 'db/schema.rb'
- 'node_modules/**/*'
- 'vendor/**/*'

Rails:
Enabled: true

# Don't prefer is_a? over kind_of?
Style/ClassCheck:
Enabled: false
inherit_gem:
theforeman-rubocop:
- lenient.yml

# Don't enforce certain methods, e.g. detect over find
Style/CollectionMethods:
Enabled: false

# Don't enforce documentation
Style/Documentation:
Enabled: false

# Support both ruby19 and hash_rockets
Style/HashSyntax:
Enabled: false

# Both double and single quotes are OK
Style/StringLiterals:
Enabled: false

# Don't enforce frozen string literals
Style/FrozenStringLiteralComment:
Enabled: false
Expand All @@ -63,37 +34,12 @@ Layout/LineLength:
Performance/Casecmp:
Enabled: false

Performance/RedundantMatch:
Enabled: true

Performance/RedundantMerge:
Enabled: true

Rails/Blank:
UnlessPresent: false

#Allow both ['a', 'b'], %w[a b] and %w(a b) style arrays
Style/WordArray:
Enabled: false

Style/AndOr:
EnforcedStyle: conditionals

Style/TernaryParentheses:
EnforcedStyle: require_parentheses_when_complex

Style/InverseMethods:
Enabled: false

Layout/FirstArgumentIndentation:
EnforcedStyle: consistent

Bundler/OrderedGems:
Enabled: false

Style/Alias:
EnforcedStyle: prefer_alias_method

Layout/DotPosition:
Enabled: false

Expand All @@ -103,9 +49,6 @@ Style/IfUnlessModifier:
Style/ConditionalAssignment:
Enabled: false

Style/EmptyMethod:
EnforcedStyle: expanded

Style/ParenthesesAroundCondition:
Enabled: false

Expand All @@ -115,10 +58,6 @@ Layout/HashAlignment:
Layout/ParameterAlignment:
Enabled: false

# disabled until we can configure "+" as concat sign
Style/LineEndConcatenation:
Enabled: false

Style/ParallelAssignment:
Enabled: false

Expand Down
104 changes: 82 additions & 22 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,102 @@
Layout/ArgumentAlignment:
Enabled: false

Layout/EmptyLinesAroundExceptionHandlingKeywords:
Enabled: false
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-03-29 20:21:11 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.

Layout/EmptyLineAfterGuardClause:
Enabled: false
# Offense count: 12
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: with_first_argument, with_fixed_indentation
Layout/ArgumentAlignment:
Exclude:
- 'app/models/foreman_kubevirt/kubevirt.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
# SupportedStyles: space, no_space, compact
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceInsideHashLiteralBraces:
Enabled: false
Exclude:
- 'app/models/foreman_kubevirt/kubevirt.rb'

# Offense count: 1
Lint/RescueException:
Enabled: false
Exclude:
- 'app/models/foreman_kubevirt/kubevirt.rb'

# Offense count: 6
# Cop supports --auto-correct.
Lint/SendWithMixinArgument:
Enabled: false
Exclude:
- 'lib/foreman_kubevirt/engine.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
Lint/UnusedMethodArgument:
Enabled: false
Exclude:
- 'app/models/foreman_kubevirt/kubevirt.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: PreferredName.
Naming/RescuedExceptionsVariableName:
Enabled: false
Exclude:
- 'Rakefile'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: Include.
# Include: **/Rakefile, **/*.rake
Rails/RakeEnvironment:
Exclude:
- 'lib/tasks/foreman_kubevirt_tasks.rake'

# Offense count: 1
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Enabled: false
Exclude:
- 'app/validators/volume_validator.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowedReceivers.
Style/HashEachMethods:
Enabled: false
Exclude:
- 'app/models/foreman_kubevirt/kubevirt.rb'

Style/HashTransformKeys:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, MinBodyLength.
# SupportedStyles: skip_modifier_ifs, always
Style/Next:
Exclude:
- 'app/validators/volume_validator.rb'

Style/HashTransformValues:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowModifier.
Style/SoleNestedConditional:
Exclude:
- 'app/validators/volume_validator.rb'

Style/Next:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: .
# SupportedStyles: percent, brackets
Style/SymbolArray:
EnforcedStyle: percent
MinSize: 2

Rails/RakeEnvironment:
# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInHashLiteral:
Exclude:
- 'lib/tasks/foreman_kubevirt_tasks.rake'
- 'app/models/foreman_kubevirt/kubevirt.rb'
- 'test/unit/foreman_kubevirt_test.rb'
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
source 'https://rubygems.org'

gemspec

gem 'theforeman-rubocop', '~> 0.1.0'
2 changes: 0 additions & 2 deletions foreman_kubevirt.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,5 @@ Gem::Specification.new do |s|

s.required_ruby_version = '>= 2.5', '< 4.0'

s.add_development_dependency('theforeman-rubocop', '~> 0.0.6')

s.add_dependency('fog-kubevirt', '~>1.3.3')
end