Skip to content

Commit

Permalink
rubocop: Fix style cops
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Jun 28, 2024
1 parent 3b85b2f commit 0b42f0f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 65 deletions.
51 changes: 1 addition & 50 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-28 11:45:55 UTC using RuboCop version 1.64.1.
# on 2024-06-28 12:03:58 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 Down Expand Up @@ -63,55 +63,6 @@ Style/FetchEnvVar:
Exclude:
- 'Gemfile'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
# SupportedShorthandSyntax: always, never, either, consistent, either_consistent
Style/HashSyntax:
Exclude:
- 'Gemfile'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantRegexpEscape:
Exclude:
- 'Gemfile'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
# SupportedStyles: slashes, percent_r, mixed
Style/RegexpLiteral:
Exclude:
- 'Gemfile'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MinSize.
# SupportedStyles: percent, brackets
Style/SymbolArray:
EnforcedStyle: brackets

# Offense count: 7
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInArrayLiteral:
Exclude:
- 'lib/puppet/modulebuilder/builder.rb'
- 'spec/spec_helper.rb'
- 'spec/unit/puppet/modulebuilder/builder_spec.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInHashLiteral:
Exclude:
- 'lib/puppet/modulebuilder/builder.rb'
- 'spec/unit/puppet/modulebuilder/builder_spec.rb'

# Offense count: 9
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ 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 @@ -28,5 +28,5 @@ group :development do
gem 'simplecov-console'

# Required for testing on Windows
gem 'ffi', :platforms => [:x64_mingw]
gem 'ffi', platforms: [:x64_mingw]
end
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ namespace :spec do
desc 'Run RSpec code examples with coverage collection'
task :coverage do
ENV['COVERAGE'] = 'yes'
Rake::Task['spec'].execute
Rake::Task['spec'].execute
end
end

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

task default: [:spec, :acceptance]
task default: %i[spec acceptance]

begin
require 'voxpupuli/rubocop/rake'
Expand Down
10 changes: 5 additions & 5 deletions lib/puppet/modulebuilder/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Builder
'/checksums.json',
'/REVISION',
'/spec/fixtures/modules/',
'/vendor/'
'/vendor/',
].freeze

attr_reader :destination, :logger
Expand Down Expand Up @@ -65,7 +65,7 @@ def build_dir
def build_context
{
parent_dir: destination,
build_dir_name: release_name
build_dir_name: release_name,
}.freeze
end

Expand Down Expand Up @@ -179,7 +179,7 @@ def ignore_file
@ignore_file ||= [
File.join(source, '.pdkignore'),
File.join(source, '.pmtignore'),
File.join(source, '.gitignore')
File.join(source, '.gitignore'),
].find { |file| file_exists?(file) && file_readable?(file) }
end

Expand Down Expand Up @@ -223,7 +223,7 @@ def build_package
tar = Minitar::Output.new(gz)
Find.find(build_context[:build_dir_name]) do |entry|
entry_meta = {
name: entry
name: entry,
}

orig_mode = File.stat(entry).mode
Expand Down Expand Up @@ -336,7 +336,7 @@ def package_already_exists?
def release_name
@release_name ||= [
metadata['name'],
metadata['version']
metadata['version'],
].join('-')
end

Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

SimpleCov.start do
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/puppet/modulebuilder/builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,15 @@
File.join('a' * 151, *['qwer'] * 19, 'bla'),
File.join('/', 'a' * 49, 'b' * 50),
File.join('a' * 49, "#{'b' * 50}x"),
File.join("#{'a' * 49}x", 'b' * 50)
File.join("#{'a' * 49}x", 'b' * 50),
]

bad_paths = {
File.join('a' * 152, 'b' * 11, 'c' * 93) => /longer than 256/i,
File.join('a' * 152, 'b' * 10, 'c' * 92) => /could not be split/i,
File.join('a' * 162, 'b' * 10) => /could not be split/i,
File.join('a' * 10, 'b' * 110) => /could not be split/i,
'a' * 114 => /could not be split/i
'a' * 114 => /could not be split/i,
}

good_paths.each do |path|
Expand Down Expand Up @@ -277,7 +277,7 @@
let(:ignore_patterns) do
[
'/vendor/',
'foo'
'foo',
]
end
let(:module_source) { File.join(root_dir, 'tmp', 'my-module') }
Expand Down Expand Up @@ -308,7 +308,7 @@
[
'.pdkignore',
'.pmtignore',
'.gitignore'
'.gitignore',
]
end
let(:available_files) { [] }
Expand Down

0 comments on commit 0b42f0f

Please sign in to comment.