Skip to content

Commit

Permalink
Add rubocop config
Browse files Browse the repository at this point in the history
previously this gem only contained a rubocop config that's used in our
modules. We didn't run rubocop for the ruby code in this exact gem. This
is changed with this commit.
  • Loading branch information
bastelfreak committed Jun 21, 2024
1 parent 0369193 commit cf3bc7d
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ env:
BUNDLE_WITHOUT: release

jobs:
rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler-cache: true
- name: Run Rubocop
run: bundle exec rake rubocop
test:
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -45,6 +56,7 @@ jobs:
run: bundle exec rake spec
tests:
needs:
- rubocop
- test
runs-on: ubuntu-latest
name: Test suite
Expand Down
38 changes: 38 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
require:
- rubocop-rake
- rubocop-rspec

# this alligns with our settings in voxpupuli-rubocop
# but we cannot depend on that because it pulls in newer rubocop versions,
# which would break our modules on legacy puppetserver
AllCops:
NewCops: enable
DisplayCopNames: true
ExtraDetails: true
DisplayStyleGuide: true

# this currently doesn't work with the way we handle our secrets
Gemspec/RequireMFA:
Enabled: false

# Vox Pupuli default is to use `add_development_dependency` in the gemspec
Gemspec/DevelopmentDependencies:
Enabled: false

Style/TernaryParentheses:
EnforcedStyle: require_parentheses_when_complex

Style/TrailingCommaInHashLiteral:
Enabled: true
EnforcedStyleForMultiline: consistent_comma

Style/TrailingCommaInArrayLiteral:
Enabled: true
EnforcedStyleForMultiline: consistent_comma

Style/TrailingCommaInArguments:
Enabled: true
EnforcedStyleForMultiline: comma

inherit_from: .rubocop_todo.yml
10 changes: 10 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@ begin
rescue LoadError
# Optional gem, release group is probably disabled
end

# this is identical to our config in voxpupuli-rubocop, but that gem targets Ruby 2.7
# and voxupuli-test depends on an older rubocop version because we provide it for our modules
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop) do |task|
# These make the rubocop experience maybe slightly less terrible
task.options = ['--display-cop-names', '--display-style-guide', '--extra-details']
# Use Rubocop's Github Actions formatter if possible
task.formatters << 'github' if ENV['GITHUB_ACTIONS'] == 'true'
end

0 comments on commit cf3bc7d

Please sign in to comment.