Skip to content

Commit

Permalink
rubocop: safe autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Oct 25, 2024
1 parent 6d42350 commit e640cfe
Show file tree
Hide file tree
Showing 43 changed files with 234 additions and 297 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/Gemfile.local
/.bundle/
/vendor/
/.vendor/
.ruby-version
/tmp/
/spec/fixtures/modules/augeas_core/
Expand Down
98 changes: 33 additions & 65 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-01-22 15:56:59 UTC using RuboCop version 1.50.2.
# on 2024-10-25 12:07:22 UTC using RuboCop version 1.67.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -26,11 +26,17 @@ Lint/EmptyBlock:
- 'spec/unit/adapters_spec.rb'

# Offense count: 3
# Configuration parameters: AllowedParentClasses.
Lint/MissingSuper:
Exclude:
- 'lib/rspec-puppet/errors.rb'
- 'lib/rspec-puppet/sensitive.rb'

# Offense count: 1
Lint/MixedRegexpCaptureTypes:
Exclude:
- 'Gemfile'

# Offense count: 1
Lint/RescueException:
Exclude:
Expand All @@ -50,64 +56,11 @@ Lint/SuppressedException:

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
Lint/UnusedMethodArgument:
Exclude:
- 'lib/rspec-puppet/support.rb'

# Offense count: 5
Lint/UselessAssignment:
Exclude:
- 'lib/rspec-puppet/example/function_example_group.rb'
- 'lib/rspec-puppet/matchers/create_generic.rb'
- 'lib/rspec-puppet/monkey_patches.rb'

# Offense count: 27
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 59

# Offense count: 7
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 111

# Offense count: 1
# Configuration parameters: CountBlocks.
Metrics/BlockNesting:
Max: 4

# Offense count: 6
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 297

# Offense count: 18
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity:
Max: 18

# Offense count: 47
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 53

# Offense count: 2
# Configuration parameters: CountComments, CountAsOne.
Metrics/ModuleLength:
Max: 383

# Offense count: 2
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
Metrics/ParameterLists:
Max: 9

# Offense count: 13
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/PerceivedComplexity:
Max: 20

# Offense count: 2
Naming/AccessorMethodName:
Exclude:
Expand All @@ -125,6 +78,7 @@ Naming/ConstantName:
# 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
Naming/FileName:
Exclude:
- 'Rakefile.rb'
- 'lib/rspec-puppet.rb'
- 'spec/functions/camelCaseFunction_spec.rb'

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

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
Naming/MemoizedInstanceVariableName:
Expand Down Expand Up @@ -232,7 +187,7 @@ RSpec/MultipleDescribes:
- 'spec/unit/example/function_example_group_spec.rb'
- 'spec/unit/monkey_patches_spec.rb'

# Offense count: 45
# Offense count: 49
RSpec/MultipleExpectations:
Max: 8

Expand All @@ -241,7 +196,7 @@ RSpec/MultipleExpectations:
RSpec/MultipleMemoizedHelpers:
Max: 7

# Offense count: 263
# Offense count: 274
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
# SupportedStyles: always, named_only
RSpec/NamedSubject:
Expand Down Expand Up @@ -323,6 +278,12 @@ RSpec/VerifiedDoubles:
- 'spec/unit/matchers/allow_value_spec.rb'
- 'spec/unit/sensitive_spec.rb'

# Offense count: 5
# This cop supports safe autocorrection (--autocorrect).
Rake/Desc:
Exclude:
- 'Rakefile'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowOnConstant, AllowOnSelfClass.
Expand All @@ -336,6 +297,7 @@ Style/ClassVars:
- 'lib/rspec-puppet/support.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/CombinableLoops:
Exclude:
- 'spec/classes/catalogue_cache_spec.rb'
Expand All @@ -353,15 +315,13 @@ Style/FormatString:
Exclude:
- 'lib/rspec-puppet/coverage.rb'

# Offense count: 14
# This cop supports safe autocorrection (--autocorrect).
Style/IfUnlessModifier:
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedReceivers.
# AllowedReceivers: Thread.current
Style/HashEachMethods:
Exclude:
- 'lib/rspec-puppet/adapters.rb'
- 'lib/rspec-puppet/coverage.rb'
- 'lib/rspec-puppet/example/function_example_group.rb'
- 'lib/rspec-puppet/matchers/create_generic.rb'
- 'lib/rspec-puppet/support.rb'
- 'Rakefile'

# Offense count: 5
Style/MissingRespondToMissing:
Expand Down Expand Up @@ -390,6 +350,14 @@ Style/SlicingWithRange:
Exclude:
- 'lib/rspec-puppet/monkey_patches.rb'

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: RequireEnglish, EnforcedStyle.
# SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names
Style/SpecialGlobalVars:
Exclude:
- 'Rakefile'

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Mode.
Expand Down
17 changes: 9 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"
# frozen_string_literal: true

source ENV['GEM_SOURCE'] || 'https://rubygems.org'

gemspec

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

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

group :development do
gem 'fuubar'
gem 'pry'
gem 'pry-stack_explorer'
gem 'fuubar'
end

group :test do

gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'])
gem 'facter', *location_for(ENV['FACTER_GEM_VERSION'])
gem 'facter', *location_for(ENV.fetch('FACTER_GEM_VERSION', nil))
gem 'puppet', *location_for(ENV.fetch('PUPPET_GEM_VERSION', nil))

gem 'json_pure'
gem 'sync'
Expand All @@ -35,5 +36,5 @@ group :test do
gem 'simplecov', require: false
gem 'simplecov-console', require: false

gem 'win32-taskscheduler', :platforms => [:mingw, :x64_mingw, :mswin]
gem 'win32-taskscheduler', platforms: %i[mingw x64_mingw mswin]
end
65 changes: 32 additions & 33 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
# frozen_string_literal: true

require 'rake'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'bundler/gem_tasks'
require 'fileutils'
require 'puppet'

task :default => :test
task :spec => :test
task default: :test
task spec: :test

require 'rspec-puppet/tasks/release_test'

fixtures_dir = File.expand_path(File.join(__FILE__, '..', 'spec', 'fixtures', 'modules'))
fixtures = {
'augeas_core' => {
:url => 'https://github.com/puppetlabs/puppetlabs-augeas_core',
:requirement => Gem::Requirement.new('>= 6.0.0'),
url: 'https://github.com/puppetlabs/puppetlabs-augeas_core',
requirement: Gem::Requirement.new('>= 6.0.0'),
},
'stdlib' => {
:url => 'https://github.com/puppetlabs/puppetlabs-stdlib',
:requirement => Gem::Requirement.new('>= 0'),
:ref => '4.2.0',
'stdlib' => {
url: 'https://github.com/puppetlabs/puppetlabs-stdlib',
requirement: Gem::Requirement.new('>= 0'),
ref: '4.2.0',
},
'registry' => {
:url => 'https://github.com/puppetlabs/puppetlabs-registry',
:requirement => Gem::Requirement.new('>= 0'),
'registry' => {
url: 'https://github.com/puppetlabs/puppetlabs-registry',
requirement: Gem::Requirement.new('>= 0'),
},
}

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

system('git', 'clone', fixture[:url], name)
fail unless $?.success?
raise unless $?.success?

next unless fixture.key?(:ref)

if fixture.key?(:ref)
Dir.chdir(name) do
system('git', 'checkout', fixture[:ref])
fail unless $?.success?
end
Dir.chdir(name) do
system('git', 'checkout', fixture[:ref])
raise unless $?.success?
end
end
end
Expand All @@ -65,40 +67,37 @@ namespace :test do
Dir.chdir(fixtures_dir) do
fixtures.each do |name, _|
next unless File.directory?(name)

FileUtils.rm_r(name)
end
end
end

task :unit do
begin
Rake::Task['test:setup'].invoke
ENV['COVERAGE'] = 'local'
Rake::Task['test:spec_unit'].invoke
ensure
ENV.delete('COVERAGE')
Rake::Task['test:teardown'].invoke
end
end
end

task :test do
begin
Rake::Task['test:setup'].invoke
Rake::Task['test:spec'].invoke
ENV['COVERAGE'] = 'local'
Rake::Task['test:spec_unit'].invoke
ensure
ENV.delete('COVERAGE')
Rake::Task['test:teardown'].invoke
end
end

task :test do
Rake::Task['test:setup'].invoke
Rake::Task['test:spec'].invoke
ensure
Rake::Task['test:teardown'].invoke
end

RuboCop::RakeTask.new(:rubocop) do |task|
task.options = %w[-D -S -E]
end

namespace :spec do
desc 'Run RSpec code examples with coverage collection'
task :coverage do
ENV['COVERAGE'] = 'yes'
Rake::Task['test'].invoke
ENV['COVERAGE'] = 'yes'
Rake::Task['test'].invoke
end
end
2 changes: 1 addition & 1 deletion bin/rspec-puppet-init
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require 'rspec-puppet'
require 'optparse'

options = {
module_name: nil
module_name: nil,
}

OptionParser.new do |opts|
Expand Down
Loading

0 comments on commit e640cfe

Please sign in to comment.