Skip to content

Commit e640cfe

Browse files
committed
rubocop: safe autofix
1 parent 6d42350 commit e640cfe

Some content is hidden

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

43 files changed

+234
-297
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/Gemfile.local
44
/.bundle/
55
/vendor/
6+
/.vendor/
67
.ruby-version
78
/tmp/
89
/spec/fixtures/modules/augeas_core/

.rubocop_todo.yml

+33-65
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-10-25 12:07:22 UTC using RuboCop version 1.67.0.
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,11 @@ 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

58-
# Offense count: 5
59-
Lint/UselessAssignment:
60-
Exclude:
61-
- 'lib/rspec-puppet/example/function_example_group.rb'
62-
- 'lib/rspec-puppet/matchers/create_generic.rb'
63-
- 'lib/rspec-puppet/monkey_patches.rb'
64-
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-
11164
# Offense count: 2
11265
Naming/AccessorMethodName:
11366
Exclude:
@@ -125,6 +78,7 @@ Naming/ConstantName:
12578
# 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
12679
Naming/FileName:
12780
Exclude:
81+
- 'Rakefile.rb'
12882
- 'lib/rspec-puppet.rb'
12983
- 'spec/functions/camelCaseFunction_spec.rb'
13084

@@ -138,6 +92,7 @@ Naming/HeredocDelimiterNaming:
13892
- 'spec/unit/matchers/compile_spec.rb'
13993

14094
# Offense count: 1
95+
# This cop supports unsafe autocorrection (--autocorrect-all).
14196
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
14297
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
14398
Naming/MemoizedInstanceVariableName:
@@ -232,7 +187,7 @@ RSpec/MultipleDescribes:
232187
- 'spec/unit/example/function_example_group_spec.rb'
233188
- 'spec/unit/monkey_patches_spec.rb'
234189

235-
# Offense count: 45
190+
# Offense count: 49
236191
RSpec/MultipleExpectations:
237192
Max: 8
238193

@@ -241,7 +196,7 @@ RSpec/MultipleExpectations:
241196
RSpec/MultipleMemoizedHelpers:
242197
Max: 7
243198

244-
# Offense count: 263
199+
# Offense count: 274
245200
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
246201
# SupportedStyles: always, named_only
247202
RSpec/NamedSubject:
@@ -323,6 +278,12 @@ RSpec/VerifiedDoubles:
323278
- 'spec/unit/matchers/allow_value_spec.rb'
324279
- 'spec/unit/sensitive_spec.rb'
325280

281+
# Offense count: 5
282+
# This cop supports safe autocorrection (--autocorrect).
283+
Rake/Desc:
284+
Exclude:
285+
- 'Rakefile'
286+
326287
# Offense count: 1
327288
# This cop supports safe autocorrection (--autocorrect).
328289
# Configuration parameters: AllowOnConstant, AllowOnSelfClass.
@@ -336,6 +297,7 @@ Style/ClassVars:
336297
- 'lib/rspec-puppet/support.rb'
337298

338299
# Offense count: 1
300+
# This cop supports unsafe autocorrection (--autocorrect-all).
339301
Style/CombinableLoops:
340302
Exclude:
341303
- 'spec/classes/catalogue_cache_spec.rb'
@@ -353,15 +315,13 @@ Style/FormatString:
353315
Exclude:
354316
- 'lib/rspec-puppet/coverage.rb'
355317

356-
# Offense count: 14
357-
# This cop supports safe autocorrection (--autocorrect).
358-
Style/IfUnlessModifier:
318+
# Offense count: 1
319+
# This cop supports unsafe autocorrection (--autocorrect-all).
320+
# Configuration parameters: AllowedReceivers.
321+
# AllowedReceivers: Thread.current
322+
Style/HashEachMethods:
359323
Exclude:
360-
- 'lib/rspec-puppet/adapters.rb'
361-
- 'lib/rspec-puppet/coverage.rb'
362-
- 'lib/rspec-puppet/example/function_example_group.rb'
363-
- 'lib/rspec-puppet/matchers/create_generic.rb'
364-
- 'lib/rspec-puppet/support.rb'
324+
- 'Rakefile'
365325

366326
# Offense count: 5
367327
Style/MissingRespondToMissing:
@@ -390,6 +350,14 @@ Style/SlicingWithRange:
390350
Exclude:
391351
- 'lib/rspec-puppet/monkey_patches.rb'
392352

353+
# Offense count: 2
354+
# This cop supports unsafe autocorrection (--autocorrect-all).
355+
# Configuration parameters: RequireEnglish, EnforcedStyle.
356+
# SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names
357+
Style/SpecialGlobalVars:
358+
Exclude:
359+
- 'Rakefile'
360+
393361
# Offense count: 2
394362
# This cop supports unsafe autocorrection (--autocorrect-all).
395363
# Configuration parameters: Mode.

Gemfile

+9-8
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

+32-33
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

+1-1
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)