Skip to content

Commit 8b8773b

Browse files
bastelfreakekohl
authored andcommitted
Introduce rubocop
1 parent 791203c commit 8b8773b

File tree

7 files changed

+155
-5
lines changed

7 files changed

+155
-5
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
version: 2
22
updates:
3+
# raise PRs for gem updates
34
- package-ecosystem: bundler
45
directory: "/"
56
schedule:
67
interval: daily
7-
time: "04:00"
8+
time: "13:00"
9+
open-pull-requests-limit: 10
10+
11+
# Maintain dependencies for GitHub Actions
12+
- package-ecosystem: github-actions
13+
directory: "/"
14+
schedule:
15+
interval: daily
16+
time: "13:00"
817
open-pull-requests-limit: 10

.github/workflows/test.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
name: Test
22

33
on:
4-
- pull_request
5-
- push
4+
pull_request: {}
5+
push:
6+
branches:
7+
- master
68

79
env:
810
BUNDLE_WITHOUT: release
911

1012
jobs:
13+
rubocop:
14+
env:
15+
BUNDLE_WITHOUT: release
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
- name: Install Ruby ${{ matrix.ruby }}
20+
uses: ruby/setup-ruby@v1
21+
with:
22+
ruby-version: "3.0"
23+
bundler-cache: true
24+
- name: Run Rubocop
25+
run: bundle exec rake rubocop
1126
test:
1227
runs-on: ubuntu-latest
1328
strategy:

.rubocop.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
inherit_from: .rubocop_todo.yml
3+
4+
require:
5+
- rubocop-performance
6+
- rubocop-rake
7+
- rubocop-rspec
8+
9+
AllCops:
10+
NewCops: enable
11+
TargetRubyVersion: '2.4'
12+
13+
Style/TrailingCommaInHashLiteral:
14+
Enabled: True
15+
EnforcedStyleForMultiline: consistent_comma
16+
17+
Style/TrailingCommaInArrayLiteral:
18+
Enabled: True
19+
EnforcedStyleForMultiline: consistent_comma
20+
21+
Style/TrailingCommaInArguments:
22+
Enabled: True
23+
EnforcedStyleForMultiline: comma
24+
25+
Metrics:
26+
Enabled: false
27+
28+
Style:
29+
Enabled: false
30+
31+
Layout:
32+
Enabled: false
33+
34+
# To match the gem name
35+
Naming/FileName:
36+
Exclude:
37+
- 'lib/rspec-puppet-facts.rb'

.rubocop_todo.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config`
3+
# on 2023-03-17 10:58:25 UTC using RuboCop version 1.12.1.
4+
# The point is for the user to remove these configuration records
5+
# one by one as the offenses are removed from the code base.
6+
# Note that changes in the inspected code, or installation of new
7+
# versions of RuboCop, may require this file to be generated again.
8+
9+
# Offense count: 32
10+
# Configuration parameters: Prefixes.
11+
# Prefixes: when, with, without
12+
RSpec/ContextWording:
13+
Exclude:
14+
- 'spec/rspec_puppet_facts_spec.rb'
15+
16+
# Offense count: 7
17+
# Configuration parameters: CountAsOne.
18+
RSpec/ExampleLength:
19+
Max: 13
20+
21+
# Offense count: 1
22+
RSpec/ExpectInHook:
23+
Exclude:
24+
- 'spec/rspec_puppet_facts_spec.rb'
25+
26+
# Offense count: 20
27+
# Cop supports --auto-correct.
28+
# Configuration parameters: EnforcedStyle.
29+
# SupportedStyles: single_line_only, single_statement_only, disallow
30+
RSpec/ImplicitSubject:
31+
Exclude:
32+
- 'spec/rspec_puppet_facts_spec.rb'
33+
34+
# Offense count: 4
35+
RSpec/LeakyConstantDeclaration:
36+
Exclude:
37+
- 'spec/rspec_puppet_facts_spec.rb'
38+
39+
# Offense count: 7
40+
# Configuration parameters: .
41+
# SupportedStyles: have_received, receive
42+
RSpec/MessageSpies:
43+
EnforcedStyle: receive
44+
45+
# Offense count: 4
46+
RSpec/MultipleExpectations:
47+
Max: 2
48+
49+
# Offense count: 46
50+
# Configuration parameters: IgnoreSharedExamples.
51+
RSpec/NamedSubject:
52+
Exclude:
53+
- 'spec/rspec_puppet_facts_spec.rb'
54+
55+
# Offense count: 14
56+
RSpec/NestedGroups:
57+
Max: 6
58+
59+
# Offense count: 1
60+
RSpec/StubbedMock:
61+
Exclude:
62+
- 'spec/rspec_puppet_facts_spec.rb'
63+
64+
# Offense count: 2
65+
# Cop supports --auto-correct.
66+
Rake/Desc:
67+
Exclude:
68+
- 'Rakefile'

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ group :release do
99
end
1010

1111
group :coverage, optional: ENV['COVERAGE']!='yes' do
12-
gem 'simplecov-console', :require => false
1312
gem 'codecov', :require => false
13+
gem 'simplecov-console', :require => false
1414
end

Rakefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,18 @@ begin
6363
rescue LoadError
6464
# Changelog generator is optional
6565
end
66+
67+
begin
68+
require 'rubocop/rake_task'
69+
rescue LoadError
70+
# RuboCop is an optional group
71+
else
72+
RuboCop::RakeTask.new(:rubocop) do |task|
73+
# These make the rubocop experience maybe slightly less terrible
74+
task.options = ['--display-cop-names', '--display-style-guide', '--extra-details']
75+
# Use Rubocop's Github Actions formatter if possible
76+
if ENV['GITHUB_ACTIONS'] == 'true'
77+
task.formatters << 'github'
78+
end
79+
end
80+
end

rspec-puppet-facts.gemspec

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ Gem::Specification.new do |s|
2424
s.add_development_dependency 'rake'
2525
s.add_development_dependency 'rspec'
2626
s.add_development_dependency 'yard'
27-
s.add_runtime_dependency 'puppet'
27+
28+
s.add_development_dependency 'rubocop', '~> 1.12.0'
29+
s.add_development_dependency 'rubocop-performance'
30+
s.add_development_dependency 'rubocop-rake'
31+
s.add_development_dependency 'rubocop-rspec'
32+
2833
s.add_runtime_dependency 'facter'
2934
s.add_runtime_dependency 'facterdb', '>= 0.5.0'
35+
s.add_runtime_dependency 'puppet'
3036
end

0 commit comments

Comments
 (0)