From 0b42f0fdd804741c9d82263143252c5f9071fddd Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 28 Jun 2024 14:04:45 +0200 Subject: [PATCH] rubocop: Fix style cops --- .rubocop_todo.yml | 51 +------------------ Gemfile | 6 +-- Rakefile | 4 +- lib/puppet/modulebuilder/builder.rb | 10 ++-- spec/spec_helper.rb | 2 +- .../unit/puppet/modulebuilder/builder_spec.rb | 8 +-- 6 files changed, 16 insertions(+), 65 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1cf11a7..b98bf2b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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 @@ -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. diff --git a/Gemfile b/Gemfile index a66ce44..b5b86a9 100644 --- a/Gemfile +++ b/Gemfile @@ -6,8 +6,8 @@ source 'https://rubygems.org' gemspec def location_for(place_or_version, fake_version = nil) - git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} - file_url_regex = %r{\Afile:\/\/(?.*)} + git_url_regex = /\A(?(https?|git)[:@][^#]*)(#(?.*))?/ + file_url_regex = %r{\Afile://(?.*)} 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 @@ -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 diff --git a/Rakefile b/Rakefile index b3830c3..9d15e08 100644 --- a/Rakefile +++ b/Rakefile @@ -11,7 +11,7 @@ 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 @@ -19,7 +19,7 @@ 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' diff --git a/lib/puppet/modulebuilder/builder.rb b/lib/puppet/modulebuilder/builder.rb index 958d5e0..0dffaf2 100644 --- a/lib/puppet/modulebuilder/builder.rb +++ b/lib/puppet/modulebuilder/builder.rb @@ -13,7 +13,7 @@ class Builder '/checksums.json', '/REVISION', '/spec/fixtures/modules/', - '/vendor/' + '/vendor/', ].freeze attr_reader :destination, :logger @@ -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 @@ -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 @@ -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 @@ -336,7 +336,7 @@ def package_already_exists? def release_name @release_name ||= [ metadata['name'], - metadata['version'] + metadata['version'], ].join('-') end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6d27108..0e2dbca 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,7 +7,7 @@ SimpleCov.formatters = [ SimpleCov::Formatter::HTMLFormatter, - SimpleCov::Formatter::Console + SimpleCov::Formatter::Console, ] SimpleCov.start do diff --git a/spec/unit/puppet/modulebuilder/builder_spec.rb b/spec/unit/puppet/modulebuilder/builder_spec.rb index dc7bbb2..17e3b02 100644 --- a/spec/unit/puppet/modulebuilder/builder_spec.rb +++ b/spec/unit/puppet/modulebuilder/builder_spec.rb @@ -231,7 +231,7 @@ 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 = { @@ -239,7 +239,7 @@ 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| @@ -277,7 +277,7 @@ let(:ignore_patterns) do [ '/vendor/', - 'foo' + 'foo', ] end let(:module_source) { File.join(root_dir, 'tmp', 'my-module') } @@ -308,7 +308,7 @@ [ '.pdkignore', '.pmtignore', - '.gitignore' + '.gitignore', ] end let(:available_files) { [] }