Skip to content

Commit 8b51d94

Browse files
Merge pull request #335 from puppetlabs/CAT-1644-rubocop_upgrade
(CAT-1644) - Rubocop upgrade to 1.48.1
2 parents 69cb6b3 + 751309e commit 8b51d94

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1196
-1351
lines changed

.rubocop.yml

Lines changed: 7 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -14,65 +14,7 @@ AllCops:
1414
- pkg/**/*
1515
- spec/fixtures/**/*
1616
- vendor/**/*
17-
Layout/LineLength:
18-
Description: People have wide screens, use them.
19-
Max: 200
20-
RSpec/BeforeAfterAll:
21-
Description: Beware of using after(:all) as it may cause state to leak between tests.
22-
A necessary evil in acceptance testing.
23-
Exclude:
24-
- spec/acceptance/**/*.rb
25-
RSpec/HookArgument:
26-
Description: Prefer explicit :each argument, matching existing module's style
27-
EnforcedStyle: each
28-
RSpec/SubjectStub:
29-
Exclude:
30-
- 'spec/puppet/resource_api/base_context_spec.rb'
31-
Style/BlockDelimiters:
32-
Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to
33-
be consistent then.
34-
EnforcedStyle: braces_for_chaining
35-
Style/ClassAndModuleChildren:
36-
Description: Compact style reduces the required amount of indentation.
37-
EnforcedStyle: compact
38-
# this needs to be easily usable in the gemspec
39-
Enabled: false
40-
Style/EmptyElse:
41-
Description: Enforce against empty else clauses, but allow `nil` for clarity.
42-
EnforcedStyle: empty
43-
Style/FormatString:
44-
Description: Following the main puppet project's style, prefer the % format format.
45-
EnforcedStyle: percent
46-
Style/FormatStringToken:
47-
Description: Following the main puppet project's style, prefer the simpler template
48-
tokens over annotated ones.
49-
EnforcedStyle: template
50-
Style/Lambda:
51-
Description: Prefer the keyword for easier discoverability.
52-
EnforcedStyle: literal
53-
Style/RegexpLiteral:
54-
Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168
55-
EnforcedStyle: percent_r
56-
Style/TernaryParentheses:
57-
Description: Checks for use of parentheses around ternary conditions. Enforce parentheses
58-
on complex expressions for better readability, but seriously consider breaking
59-
it up.
60-
EnforcedStyle: require_parentheses_when_complex
61-
Style/TrailingCommaInArguments:
62-
Description: Prefer always trailing comma on multiline argument lists. This makes
63-
diffs, and re-ordering nicer.
64-
EnforcedStyleForMultiline: comma
65-
Style/SymbolArray:
66-
Description: Using percent style obscures symbolic intent of array's contents.
67-
EnforcedStyle: brackets
68-
Layout/EndOfLine:
69-
Enabled: false
70-
Style/CollectionMethods:
71-
Enabled: true
72-
Style/MethodCalledOnDoEndBlock:
73-
Enabled: true
74-
Style/StringMethods:
75-
Enabled: true
17+
7618
Metrics/AbcSize:
7719
Enabled: false
7820
Metrics/BlockLength:
@@ -85,71 +27,17 @@ Metrics/MethodLength:
8527
Enabled: false
8628
Metrics/ModuleLength:
8729
Enabled: false
88-
Metrics/ParameterLists:
89-
Enabled: false
9030
Metrics/PerceivedComplexity:
9131
Enabled: false
92-
RSpec/DescribeClass:
93-
Enabled: false
94-
RSpec/ExampleLength:
95-
Enabled: false
96-
RSpec/MessageExpectation:
97-
Enabled: false
98-
RSpec/MultipleExpectations:
99-
Enabled: false
100-
RSpec/NestedGroups:
101-
Enabled: false
102-
Style/AsciiComments:
103-
Enabled: false
104-
Style/IfUnlessModifier:
105-
Enabled: false
106-
Style/SymbolProc:
32+
Style/ClassAndModuleChildren:
10733
Enabled: false
108-
109-
# local overrides
110-
111-
# overridden for local conventions
112-
Naming/FileName:
113-
Exclude:
114-
- 'puppet-resource_api.gemspec'
115-
116-
# metaprogramming makes everything "fun"
34+
Naming/MethodParameterName:
35+
AllowedNames:
36+
- is
11737
Lint/NestedMethodDefinition:
11838
Exclude:
11939
- 'lib/puppet/resource_api.rb'
120-
121-
# Interacting with external API makes message spies pretty useless
40+
Layout/LineLength:
41+
Max: 200
12242
RSpec/MessageSpies:
12343
Enabled: false
124-
125-
# requires 2.3's squiggly HEREDOC support, which we can't use, yet
126-
# see http://www.virtuouscode.com/2016/01/06/about-the-ruby-squiggly-heredoc-syntax/
127-
Layout/HeredocIndentation:
128-
Enabled: false
129-
130-
# Updated in 0.53 (or thereabouts)
131-
Style/TrailingCommaInArrayLiteral:
132-
Description: Prefer always trailing comma on multiline literals. This makes diffs,
133-
and re-ordering nicer.
134-
EnforcedStyleForMultiline: comma
135-
Style/TrailingCommaInHashLiteral:
136-
Description: Prefer always trailing comma on multiline literals. This makes diffs,
137-
and re-ordering nicer.
138-
EnforcedStyleForMultiline: comma
139-
140-
# Add allowing "is", as it is a technical term in puppet
141-
Naming/MethodParameterName:
142-
Description: Checks for method parameter names that contain capital letters, end in
143-
numbers, or do not meet a minimal length.
144-
Enabled: true
145-
MinNameLength: 3
146-
AllowNamesEndingInNumbers: true
147-
AllowedNames:
148-
- io
149-
- id
150-
- is
151-
ForbiddenNames: []
152-
153-
# This cop breaks syntax highlighting in VSCode
154-
Layout/ClosingHeredocIndentation:
155-
Enabled: false

.rubocop_todo.yml

Lines changed: 21 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,20 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2023-12-13 15:50:43 UTC using RuboCop version 1.48.1.
3+
# on 2023-12-19 10:44:38 UTC using RuboCop version 1.48.1.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

9-
# Offense count: 6
10-
# Configuration parameters: AllowedMethods.
11-
# AllowedMethods: enums
12-
Lint/ConstantDefinitionInBlock:
13-
Exclude:
14-
- 'spec/puppet/resource_api/base_context_spec.rb'
15-
- 'spec/puppet/resource_api/transport/wrapper_spec.rb'
16-
- 'spec/puppet/resource_api/transport_spec.rb'
17-
- 'spec/puppet/resource_api_spec.rb'
18-
19-
# Offense count: 1
20-
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
21-
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
22-
Naming/MemoizedInstanceVariableName:
23-
Exclude:
24-
- 'lib/puppet/resource_api/type_definition.rb'
25-
26-
# Offense count: 1
27-
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
28-
# SupportedStyles: snake_case, normalcase, non_integer
29-
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
30-
Naming/VariableNumber:
31-
Exclude:
32-
- 'spec/puppet/resource_api_spec.rb'
9+
# Offense count: 25
10+
# Configuration parameters: IgnoredMetadata.
11+
RSpec/DescribeClass:
12+
Enabled: false
3313

34-
# Offense count: 1
35-
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
36-
# Include: **/*_spec*rb*, **/spec/**/*
37-
RSpec/FilePath:
38-
Exclude:
39-
- 'spec/acceptance/custom_insync_spec_hidden_property.rb'
14+
# Offense count: 33
15+
# Configuration parameters: CountAsOne.
16+
RSpec/ExampleLength:
17+
Max: 16
4018

4119
# Offense count: 18
4220
# Configuration parameters: AssignmentOnly.
@@ -45,35 +23,29 @@ RSpec/InstanceVariable:
4523
- 'spec/acceptance/namevar_spec.rb'
4624
- 'spec/puppet/resource_api/data_type_handling_spec.rb'
4725

48-
# Offense count: 15
26+
# # Offense count: 15
4927
RSpec/LeakyConstantDeclaration:
5028
Exclude:
5129
- 'spec/puppet/resource_api/base_context_spec.rb'
5230
- 'spec/puppet/resource_api/transport/wrapper_spec.rb'
5331
- 'spec/puppet/resource_api/transport_spec.rb'
5432
- 'spec/puppet/resource_api_spec.rb'
5533

34+
# Offense count: 163
35+
RSpec/MultipleExpectations:
36+
Max: 11
37+
5638
# Offense count: 126
5739
# Configuration parameters: AllowSubject.
5840
RSpec/MultipleMemoizedHelpers:
5941
Max: 14
6042

61-
# Offense count: 2
62-
RSpec/RepeatedExampleGroupDescription:
63-
Exclude:
64-
- 'spec/puppet/resource_api_spec.rb'
43+
# Offense count: 213
44+
# Configuration parameters: AllowedGroups.
45+
RSpec/NestedGroups:
46+
Max: 7
6547

66-
# Offense count: 25
67-
RSpec/StubbedMock:
48+
# Offense count: 47
49+
RSpec/SubjectStub:
6850
Exclude:
69-
- 'spec/puppet/resource_api/property_spec.rb'
70-
- 'spec/puppet/resource_api/transport/wrapper_spec.rb'
71-
- 'spec/puppet/resource_api/transport_spec.rb'
72-
- 'spec/puppet/resource_api_spec.rb'
73-
74-
# Offense count: 2
75-
# Configuration parameters: AllowedMethods.
76-
# AllowedMethods: respond_to_missing?
77-
Style/OptionalBooleanParameter:
78-
Exclude:
79-
- 'lib/puppet/resource_api/data_type_handling.rb'
51+
- 'spec/puppet/resource_api/base_context_spec.rb'

contrib/pre-commit

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
# Code modified from: https://gist.github.com/hanloong/9849098
55
require 'English'
66

7-
changed_files = `git diff --name-only --cached --diff-filter=ACM`.split(%r{\n})
8-
changed_files = changed_files.select { |file_name|
7+
changed_files = `git diff --name-only --cached --diff-filter=ACM`.split(/\n/)
8+
changed_files = changed_files.select do |file_name|
99
File.extname(file_name) == '.rb'
10-
}.join(' ')
10+
end.join(' ')
1111

1212
system("bundle exec rubocop -a #{changed_files}") unless changed_files.empty?
1313

14-
if $CHILD_STATUS.to_s[-1].to_i.zero? && !changed_files.empty?
15-
system("git add #{changed_files}")
16-
end
14+
system("git add #{changed_files}") if $CHILD_STATUS.to_s[-1].to_i.zero? && !changed_files.empty?
1715

1816
exit $CHILD_STATUS.to_s[-1].to_i

0 commit comments

Comments
 (0)