Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rubocop: Fix style cops #468

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 1 addition & 62 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-06-09 12:47:09 UTC using RuboCop version 1.63.5.
# on 2024-06-28 12:36:37 UTC using RuboCop version 1.64.1.
# 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 @@ -18,14 +18,6 @@ Lint/MixedRegexpCaptureTypes:
Exclude:
- 'Gemfile'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: strict, consistent
Lint/SymbolConversion:
Exclude:
- 'lib/puppetlabs_spec_helper/puppetlabs_spec/puppet_internals.rb'

# Offense count: 7
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
Expand Down Expand Up @@ -99,12 +91,6 @@ Security/Eval:
Exclude:
- 'lib/puppetlabs_spec_helper/tasks/fixtures.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/CombinableLoops:
Exclude:
- 'lib/puppetlabs_spec_helper/tasks/fixtures.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowedVars.
Expand All @@ -125,14 +111,6 @@ Style/GlobalVars:
Exclude:
- 'lib/puppetlabs_spec_helper/puppetlabs_spec/files.rb'

# Offense count: 4
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedReceivers.
# AllowedReceivers: Thread.current
Style/HashEachMethods:
Exclude:
- 'lib/puppetlabs_spec_helper/tasks/fixtures.rb'

# Offense count: 1
Style/MixinUsage:
Exclude:
Expand All @@ -152,42 +130,3 @@ Style/RegexpLiteral:
Exclude:
- 'Gemfile'
- 'spec/unit/puppetlabs_spec_helper/tasks/fixtures_spec.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Exclude:
- 'Rakefile'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, AllowSafeAssignment.
# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex
Style/TernaryParentheses:
Exclude:
- 'lib/puppetlabs_spec_helper/tasks/fixtures.rb'
- 'spec/watchr.rb'

# Offense count: 12
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInArrayLiteral:
Exclude:
- 'lib/puppetlabs_spec_helper/module_spec_helper.rb'
- 'lib/puppetlabs_spec_helper/tasks/check_symlinks.rb'
- 'spec/spec_helper.rb'
- 'spec/unit/puppetlabs_spec_helper/tasks/check_symlinks_spec.rb'
- 'spec/unit/puppetlabs_spec_helper/tasks/check_test_file_spec.rb'

# Offense count: 26
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInHashLiteral:
Exclude:
- 'lib/puppetlabs_spec_helper/rake_tasks.rb'
- 'spec/unit/puppetlabs_spec_helper/tasks/check_symlinks_spec.rb'
- 'spec/unit/puppetlabs_spec_helper/tasks/fixture_helpers_spec.rb'
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require 'bundler/gem_tasks'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec) do |t|
t.exclude_pattern = "spec/acceptance/**/*.rb"
t.exclude_pattern = 'spec/acceptance/**/*.rb'
end

namespace :spec do
Expand All @@ -16,7 +16,7 @@ namespace :spec do
end

RSpec::Core::RakeTask.new(:acceptance) do |t|
t.pattern = "spec/acceptance/**/*.rb"
t.pattern = 'spec/acceptance/**/*.rb'
end

require 'yard'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppetlabs_spec_helper/module_spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def verify_contents(subject, title, expected_lines)

SimpleCov.formatters = [
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::Console
SimpleCov::Formatter::Console,
]

begin
Expand Down
8 changes: 4 additions & 4 deletions lib/puppetlabs_spec_helper/rake_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -381,16 +381,16 @@ def changelog_future_release
config.configure_sections = {
'Changed' => {
'prefix' => '### Changed',
'labels' => ['backwards-incompatible']
'labels' => ['backwards-incompatible'],
},
'Added' => {
'prefix' => '### Added',
'labels' => %w[feature enhancement]
'labels' => %w[feature enhancement],
},
'Fixed' => {
'prefix' => '### Fixed',
'labels' => ['bugfix']
}
'labels' => ['bugfix'],
},
}
end
else
Expand Down
4 changes: 2 additions & 2 deletions lib/puppetlabs_spec_helper/tasks/check_symlinks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ class CheckSymlinks
DEFAULT_IGNORED = [
'/.git/',
'/.bundle/',
'/vendor/'
'/vendor/',
].freeze

IGNORE_LIST_FILES = [
'.pdkignore',
'.gitignore'
'.gitignore',
].freeze

def check(dir = Dir.pwd)
Expand Down
2 changes: 1 addition & 1 deletion lib/puppetlabs_spec_helper/tasks/fixtures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def fixtures(category)
end

fixtures = fixtures['fixtures']
fixtures['symlinks'] = fixtures['symlinks'].nil? || fixtures['symlinks'].empty? ? auto_symlink : auto_symlink.merge!(fixtures['symlinks'])
fixtures['symlinks'] = (fixtures['symlinks'].nil? || fixtures['symlinks'].empty?) ? auto_symlink : auto_symlink.merge!(fixtures['symlinks'])

result = {}
if fixtures.include?(category) && !fixtures[category].nil?
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

SimpleCov.formatters = [
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::Console
SimpleCov::Formatter::Console,
]

SimpleCov.start do
Expand Down
26 changes: 13 additions & 13 deletions spec/unit/puppetlabs_spec_helper/tasks/check_symlinks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
let(:test_files) do
[
File.join(Dir.pwd, 'files', 'a_file.pp'),
File.join(Dir.pwd, 'files', 'another_file.pp')
File.join(Dir.pwd, 'files', 'another_file.pp'),
]
end

Expand All @@ -43,13 +43,13 @@
context 'when there is a symlink present' do
let(:test_files) do
[
File.join(Dir.pwd, 'files', 'a_file.pp')
File.join(Dir.pwd, 'files', 'a_file.pp'),
]
end

let(:symlinks) do
{
File.join(Dir.pwd, 'files', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp')
File.join(Dir.pwd, 'files', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp'),
}
end

Expand All @@ -63,13 +63,13 @@
context 'when there are symlinks under .git/' do
let(:test_files) do
[
File.join(Dir.pwd, 'files', 'a_file.pp')
File.join(Dir.pwd, 'files', 'a_file.pp'),
]
end

let(:symlinks) do
{
File.join(Dir.pwd, '.git', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp')
File.join(Dir.pwd, '.git', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp'),
}
end

Expand All @@ -81,13 +81,13 @@
context 'when there are symlinks under .bundle/' do
let(:test_files) do
[
File.join(Dir.pwd, 'files', 'a_file.pp')
File.join(Dir.pwd, 'files', 'a_file.pp'),
]
end

let(:symlinks) do
{
File.join(Dir.pwd, '.bundle', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp')
File.join(Dir.pwd, '.bundle', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp'),
}
end

Expand All @@ -99,13 +99,13 @@
context 'when there are symlinks under vendor/' do
let(:test_files) do
[
File.join(Dir.pwd, 'files', 'a_file.pp')
File.join(Dir.pwd, 'files', 'a_file.pp'),
]
end

let(:symlinks) do
{
File.join(Dir.pwd, 'vendor', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp')
File.join(Dir.pwd, 'vendor', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp'),
}
end

Expand All @@ -121,13 +121,13 @@

let(:test_files) do
[
File.join(Dir.pwd, 'files', 'a_file.pp')
File.join(Dir.pwd, 'files', 'a_file.pp'),
]
end

let(:symlinks) do
{
File.join(Dir.pwd, 'a_directory', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp')
File.join(Dir.pwd, 'a_directory', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp'),
}
end

Expand All @@ -145,13 +145,13 @@

let(:test_files) do
[
File.join(Dir.pwd, 'files', 'a_file.pp')
File.join(Dir.pwd, 'files', 'a_file.pp'),
]
end

let(:symlinks) do
{
File.join(Dir.pwd, 'another_directory', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp')
File.join(Dir.pwd, 'another_directory', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp'),
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
let(:test_files) do
[
File.join(Dir.pwd, 'tests', 'an_example.pp'),
File.join(Dir.pwd, 'tests', 'deep', 'directory', 'structure', 'another_example.pp')
File.join(Dir.pwd, 'tests', 'deep', 'directory', 'structure', 'another_example.pp'),
]
end

Expand Down
32 changes: 16 additions & 16 deletions spec/unit/puppetlabs_spec_helper/tasks/fixture_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
'branch' => nil,
'scm' => nil,
'flags' => nil,
'subdir' => nil
'subdir' => nil,
},
)
end
Expand All @@ -159,7 +159,7 @@
'branch' => nil,
'scm' => nil,
'flags' => '--module_repository=https://myforge.example.com/',
'subdir' => nil
'subdir' => nil,
},
)
end
Expand All @@ -170,7 +170,7 @@
allow(File).to receive(:exist?).with('.fixtures.yml').and_return true
allow(YAML).to receive(:load_file).with('.fixtures.yml').and_return(
'fixtures' => {
'repositories' => { 'stdlib' => 'https://github.com/puppetlabs/puppetlabs-stdlib.git' }
'repositories' => { 'stdlib' => 'https://github.com/puppetlabs/puppetlabs-stdlib.git' },
},
)
end
Expand All @@ -183,7 +183,7 @@
'branch' => nil,
'scm' => nil,
'flags' => nil,
'subdir' => nil
'subdir' => nil,
},
)
end
Expand All @@ -198,9 +198,9 @@
'stdlib' => {
'scm' => 'git',
'repo' => 'https://github.com/puppetlabs/puppetlabs-stdlib.git',
'ref' => 'this/is/a/branch'
}
}
'ref' => 'this/is/a/branch',
},
},
},
)
end
Expand All @@ -222,9 +222,9 @@ def stub_fixtures(data)
'forge_modules' => {
'stdlib' => {
'repo' => 'puppetlabs-stdlib',
'puppet_version' => Puppet::PUPPETVERSION
}
}
'puppet_version' => Puppet::PUPPETVERSION,
},
},
},
)
expect(helper.fixtures('forge_modules')).to include('puppetlabs-stdlib')
Expand All @@ -236,9 +236,9 @@ def stub_fixtures(data)
'forge_modules' => {
'stdlib' => {
'repo' => 'puppetlabs-stdlib',
'puppet_version' => '>= 999.9.9'
}
}
'puppet_version' => '>= 999.9.9',
},
},
},
)
expect(helper.fixtures('forge_modules')).to eq({})
Expand All @@ -250,9 +250,9 @@ def stub_fixtures(data)
'forge_modules' => {
'stdlib' => {
'repo' => 'puppetlabs-stdlib',
'puppet_version' => Puppet::PUPPETVERSION
}
}
'puppet_version' => Puppet::PUPPETVERSION,
},
},
},
)
expect(helper.fixtures('forge_modules')).to include('puppetlabs-stdlib')
Expand Down
2 changes: 1 addition & 1 deletion spec/watchr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def growl(message)
title = 'Watchr Test Results'
image = case message
when /(\d+)\s+?(failure|error)/i
Regexp.last_match(1).to_i == 0 ? '~/.watchr_images/passed.png' : '~/.watchr_images/failed.png'
(Regexp.last_match(1).to_i == 0) ? '~/.watchr_images/passed.png' : '~/.watchr_images/failed.png'
else
'~/.watchr_images/unknown.png'
end
Expand Down
Loading