Skip to content

Commit 2a55e94

Browse files
committed
rubocop: safe autofix
1 parent 88fd184 commit 2a55e94

Some content is hidden

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

41 files changed

+233
-231
lines changed

.rubocop_todo.yml

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2024-01-22 15:56:59 UTC using RuboCop version 1.50.2.
3+
# on 2024-07-05 20:35:14 UTC using RuboCop version 1.64.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
@@ -26,11 +26,17 @@ Lint/EmptyBlock:
2626
- 'spec/unit/adapters_spec.rb'
2727

2828
# Offense count: 3
29+
# Configuration parameters: AllowedParentClasses.
2930
Lint/MissingSuper:
3031
Exclude:
3132
- 'lib/rspec-puppet/errors.rb'
3233
- 'lib/rspec-puppet/sensitive.rb'
3334

35+
# Offense count: 1
36+
Lint/MixedRegexpCaptureTypes:
37+
Exclude:
38+
- 'Gemfile'
39+
3440
# Offense count: 1
3541
Lint/RescueException:
3642
Exclude:
@@ -50,64 +56,20 @@ Lint/SuppressedException:
5056

5157
# Offense count: 2
5258
# This cop supports safe autocorrection (--autocorrect).
53-
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
59+
# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
5460
Lint/UnusedMethodArgument:
5561
Exclude:
5662
- 'lib/rspec-puppet/support.rb'
5763

5864
# Offense count: 5
65+
# This cop supports unsafe autocorrection (--autocorrect-all).
66+
# Configuration parameters: AutoCorrect.
5967
Lint/UselessAssignment:
6068
Exclude:
6169
- 'lib/rspec-puppet/example/function_example_group.rb'
6270
- 'lib/rspec-puppet/matchers/create_generic.rb'
6371
- 'lib/rspec-puppet/monkey_patches.rb'
6472

65-
# Offense count: 27
66-
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
67-
Metrics/AbcSize:
68-
Max: 59
69-
70-
# Offense count: 7
71-
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
72-
# AllowedMethods: refine
73-
Metrics/BlockLength:
74-
Max: 111
75-
76-
# Offense count: 1
77-
# Configuration parameters: CountBlocks.
78-
Metrics/BlockNesting:
79-
Max: 4
80-
81-
# Offense count: 6
82-
# Configuration parameters: CountComments, CountAsOne.
83-
Metrics/ClassLength:
84-
Max: 297
85-
86-
# Offense count: 18
87-
# Configuration parameters: AllowedMethods, AllowedPatterns.
88-
Metrics/CyclomaticComplexity:
89-
Max: 18
90-
91-
# Offense count: 47
92-
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
93-
Metrics/MethodLength:
94-
Max: 53
95-
96-
# Offense count: 2
97-
# Configuration parameters: CountComments, CountAsOne.
98-
Metrics/ModuleLength:
99-
Max: 383
100-
101-
# Offense count: 2
102-
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
103-
Metrics/ParameterLists:
104-
Max: 9
105-
106-
# Offense count: 13
107-
# Configuration parameters: AllowedMethods, AllowedPatterns.
108-
Metrics/PerceivedComplexity:
109-
Max: 20
110-
11173
# Offense count: 2
11274
Naming/AccessorMethodName:
11375
Exclude:
@@ -125,6 +87,7 @@ Naming/ConstantName:
12587
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
12688
Naming/FileName:
12789
Exclude:
90+
- 'Rakefile.rb'
12891
- 'lib/rspec-puppet.rb'
12992
- 'spec/functions/camelCaseFunction_spec.rb'
13093

@@ -138,6 +101,7 @@ Naming/HeredocDelimiterNaming:
138101
- 'spec/unit/matchers/compile_spec.rb'
139102

140103
# Offense count: 1
104+
# This cop supports unsafe autocorrection (--autocorrect-all).
141105
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
142106
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
143107
Naming/MemoizedInstanceVariableName:
@@ -199,6 +163,12 @@ RSpec/DescribeClass:
199163
RSpec/ExampleLength:
200164
Max: 12
201165

166+
# Offense count: 16
167+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
168+
# Include: **/*_spec*rb*, **/spec/**/*
169+
RSpec/FilePath:
170+
Enabled: false
171+
202172
# Offense count: 2
203173
RSpec/ImplicitBlockExpectation:
204174
Exclude:
@@ -232,7 +202,7 @@ RSpec/MultipleDescribes:
232202
- 'spec/unit/example/function_example_group_spec.rb'
233203
- 'spec/unit/monkey_patches_spec.rb'
234204

235-
# Offense count: 45
205+
# Offense count: 49
236206
RSpec/MultipleExpectations:
237207
Max: 8
238208

@@ -241,7 +211,7 @@ RSpec/MultipleExpectations:
241211
RSpec/MultipleMemoizedHelpers:
242212
Max: 7
243213

244-
# Offense count: 263
214+
# Offense count: 274
245215
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
246216
# SupportedStyles: always, named_only
247217
RSpec/NamedSubject:
@@ -323,6 +293,12 @@ RSpec/VerifiedDoubles:
323293
- 'spec/unit/matchers/allow_value_spec.rb'
324294
- 'spec/unit/sensitive_spec.rb'
325295

296+
# Offense count: 5
297+
# This cop supports safe autocorrection (--autocorrect).
298+
Rake/Desc:
299+
Exclude:
300+
- 'Rakefile'
301+
326302
# Offense count: 1
327303
# This cop supports safe autocorrection (--autocorrect).
328304
# Configuration parameters: AllowOnConstant, AllowOnSelfClass.
@@ -336,6 +312,7 @@ Style/ClassVars:
336312
- 'lib/rspec-puppet/support.rb'
337313

338314
# Offense count: 1
315+
# This cop supports unsafe autocorrection (--autocorrect-all).
339316
Style/CombinableLoops:
340317
Exclude:
341318
- 'spec/classes/catalogue_cache_spec.rb'
@@ -353,6 +330,23 @@ Style/FormatString:
353330
Exclude:
354331
- 'lib/rspec-puppet/coverage.rb'
355332

333+
# Offense count: 2
334+
# This cop supports unsafe autocorrection (--autocorrect-all).
335+
# Configuration parameters: EnforcedStyle.
336+
# SupportedStyles: always, always_true, never
337+
Style/FrozenStringLiteralComment:
338+
Exclude:
339+
- 'Gemfile'
340+
- 'Rakefile'
341+
342+
# Offense count: 1
343+
# This cop supports unsafe autocorrection (--autocorrect-all).
344+
# Configuration parameters: AllowedReceivers.
345+
# AllowedReceivers: Thread.current
346+
Style/HashEachMethods:
347+
Exclude:
348+
- 'Rakefile'
349+
356350
# Offense count: 14
357351
# This cop supports safe autocorrection (--autocorrect).
358352
Style/IfUnlessModifier:
@@ -390,6 +384,14 @@ Style/SlicingWithRange:
390384
Exclude:
391385
- 'lib/rspec-puppet/monkey_patches.rb'
392386

387+
# Offense count: 2
388+
# This cop supports unsafe autocorrection (--autocorrect-all).
389+
# Configuration parameters: RequireEnglish, EnforcedStyle.
390+
# SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names
391+
Style/SpecialGlobalVars:
392+
Exclude:
393+
- 'Rakefile'
394+
393395
# Offense count: 2
394396
# This cop supports unsafe autocorrection (--autocorrect-all).
395397
# Configuration parameters: Mode.

Gemfile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
source ENV['GEM_SOURCE'] || "https://rubygems.org"
1+
# frozen_string_literal: true
2+
3+
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
24

35
gemspec
46

57
def location_for(place_or_version, fake_version = nil)
6-
git_url_regex = %r{\A(?<url>(https?|git)[:@][^#]*)(#(?<branch>.*))?}
7-
file_url_regex = %r{\Afile:\/\/(?<path>.*)}
8+
git_url_regex = /\A(?<url>(https?|git)[:@][^#]*)(#(?<branch>.*))?/
9+
file_url_regex = %r{\Afile://(?<path>.*)}
810

911
if place_or_version && (git_url = place_or_version.match(git_url_regex))
1012
[fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact
@@ -16,15 +18,14 @@ def location_for(place_or_version, fake_version = nil)
1618
end
1719

1820
group :development do
21+
gem 'fuubar'
1922
gem 'pry'
2023
gem 'pry-stack_explorer'
21-
gem 'fuubar'
2224
end
2325

2426
group :test do
25-
26-
gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'])
27-
gem 'facter', *location_for(ENV['FACTER_GEM_VERSION'])
27+
gem 'facter', *location_for(ENV.fetch('FACTER_GEM_VERSION', nil))
28+
gem 'puppet', *location_for(ENV.fetch('PUPPET_GEM_VERSION', nil))
2829

2930
gem 'json_pure'
3031
gem 'sync'
@@ -35,5 +36,5 @@ group :test do
3536
gem 'simplecov', require: false
3637
gem 'simplecov-console', require: false
3738

38-
gem 'win32-taskscheduler', :platforms => [:mingw, :x64_mingw, :mswin]
39+
gem 'win32-taskscheduler', platforms: %i[mingw x64_mingw mswin]
3940
end

Rakefile

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1+
# frozen_string_literal: true
2+
13
require 'rake'
24
require 'rspec/core/rake_task'
35
require 'rubocop/rake_task'
46
require 'bundler/gem_tasks'
57
require 'fileutils'
68
require 'puppet'
79

8-
task :default => :test
9-
task :spec => :test
10+
task default: :test
11+
task spec: :test
1012

1113
require 'rspec-puppet/tasks/release_test'
1214

1315
fixtures_dir = File.expand_path(File.join(__FILE__, '..', 'spec', 'fixtures', 'modules'))
1416
fixtures = {
1517
'augeas_core' => {
16-
:url => 'https://github.com/puppetlabs/puppetlabs-augeas_core',
17-
:requirement => Gem::Requirement.new('>= 6.0.0'),
18+
url: 'https://github.com/puppetlabs/puppetlabs-augeas_core',
19+
requirement: Gem::Requirement.new('>= 6.0.0'),
1820
},
19-
'stdlib' => {
20-
:url => 'https://github.com/puppetlabs/puppetlabs-stdlib',
21-
:requirement => Gem::Requirement.new('>= 0'),
22-
:ref => '4.2.0',
21+
'stdlib' => {
22+
url: 'https://github.com/puppetlabs/puppetlabs-stdlib',
23+
requirement: Gem::Requirement.new('>= 0'),
24+
ref: '4.2.0',
2325
},
24-
'registry' => {
25-
:url => 'https://github.com/puppetlabs/puppetlabs-registry',
26-
:requirement => Gem::Requirement.new('>= 0'),
26+
'registry' => {
27+
url: 'https://github.com/puppetlabs/puppetlabs-registry',
28+
requirement: Gem::Requirement.new('>= 0'),
2729
},
2830
}
2931

@@ -49,13 +51,13 @@ namespace :test do
4951
next unless fixture[:requirement].satisfied_by?(puppet_version)
5052

5153
system('git', 'clone', fixture[:url], name)
52-
fail unless $?.success?
54+
raise unless $?.success?
55+
56+
next unless fixture.key?(:ref)
5357

54-
if fixture.key?(:ref)
55-
Dir.chdir(name) do
56-
system('git', 'checkout', fixture[:ref])
57-
fail unless $?.success?
58-
end
58+
Dir.chdir(name) do
59+
system('git', 'checkout', fixture[:ref])
60+
raise unless $?.success?
5961
end
6062
end
6163
end
@@ -65,40 +67,37 @@ namespace :test do
6567
Dir.chdir(fixtures_dir) do
6668
fixtures.each do |name, _|
6769
next unless File.directory?(name)
70+
6871
FileUtils.rm_r(name)
6972
end
7073
end
7174
end
7275

7376
task :unit do
74-
begin
75-
Rake::Task['test:setup'].invoke
76-
ENV['COVERAGE'] = 'local'
77-
Rake::Task['test:spec_unit'].invoke
78-
ensure
79-
ENV.delete('COVERAGE')
80-
Rake::Task['test:teardown'].invoke
81-
end
82-
end
83-
end
84-
85-
task :test do
86-
begin
8777
Rake::Task['test:setup'].invoke
88-
Rake::Task['test:spec'].invoke
78+
ENV['COVERAGE'] = 'local'
79+
Rake::Task['test:spec_unit'].invoke
8980
ensure
81+
ENV.delete('COVERAGE')
9082
Rake::Task['test:teardown'].invoke
9183
end
9284
end
9385

86+
task :test do
87+
Rake::Task['test:setup'].invoke
88+
Rake::Task['test:spec'].invoke
89+
ensure
90+
Rake::Task['test:teardown'].invoke
91+
end
92+
9493
RuboCop::RakeTask.new(:rubocop) do |task|
9594
task.options = %w[-D -S -E]
9695
end
9796

9897
namespace :spec do
9998
desc 'Run RSpec code examples with coverage collection'
10099
task :coverage do
101-
ENV['COVERAGE'] = 'yes'
102-
Rake::Task['test'].invoke
100+
ENV['COVERAGE'] = 'yes'
101+
Rake::Task['test'].invoke
103102
end
104103
end

bin/rspec-puppet-init

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require 'rspec-puppet'
77
require 'optparse'
88

99
options = {
10-
module_name: nil
10+
module_name: nil,
1111
}
1212

1313
OptionParser.new do |opts|

0 commit comments

Comments
 (0)