diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 3f9d2606..403d6282 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -4,7 +4,8 @@ name: Ruby on: pull_request: {} push: - branches: main + branches: + - main jobs: rubocop_and_matrix: diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 826a1af4..b3c1a71b 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -16,7 +16,7 @@ jobs: - name: setup ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: 3.4 # setup a package lock if one doesn't exist, otherwise do nothing - name: check lock run: '[ -f "Gemfile.lock" ] && echo "package lock file exists, skipping" || bundle lock' diff --git a/.rubocop.yml b/.rubocop.yml index 778f1bea..b0ee9c7c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,7 +5,7 @@ require: - rubocop-rspec AllCops: - TargetRubyVersion: 2.7 + TargetRubyVersion: 3.2 NewCops: enable Exclude: - "**/*.erb" diff --git a/lib/git/basic_submodules.rb b/lib/git/basic_submodules.rb index 02315a1c..37219c28 100644 --- a/lib/git/basic_submodules.rb +++ b/lib/git/basic_submodules.rb @@ -35,8 +35,8 @@ module BasicSubmodules # @option options [Boolean] :rebase rebase current branch of submodule onto the commit recorded in the superproject # @option options [Boolean] :recursive recurse into nested submodules # @return options [String] any output produced by `git` when submodules are initialized - def update_submodules(**options) - self.lib.update_submodules(**options) + def update_submodules(**) + self.lib.update_submodules(**) end end diff --git a/lib/vanagon/component/dsl.rb b/lib/vanagon/component/dsl.rb index 154938ba..7e0253b7 100644 --- a/lib/vanagon/component/dsl.rb +++ b/lib/vanagon/component/dsl.rb @@ -23,7 +23,7 @@ def initialize(name, settings, platform) # # @param name [String] name of the componennt # @param block [Proc] DSL definition of the component to call - def component(name, &block) + def component(name, &) yield(self, @component.settings, @component.platform) end @@ -59,28 +59,28 @@ def respond_to_missing?(method_name, include_private = false) # Set or add to the configure call for the component. The commands required to configure the component before building it. # # @param block [Proc] the command(s) required to configure the component - def configure(&block) + def configure(&) @component.configure << yield end # Set or add to the build call for the component. The commands required to build the component before testing/installing it. # # @param block [Proc] the command(s) required to build the component - def build(&block) + def build(&) @component.build << yield end # Set or add to the check call for the component. The commands required to test the component before installing it. # # @param block [Proc] the command(s) required to test the component - def check(&block) + def check(&) @component.check << yield end # Set or add to the install call for the component. The commands required to install the component. # # @param block [Proc] the command(s) required to install the component - def install(&block) + def install(&) @component.install << yield end diff --git a/lib/vanagon/component/rules.rb b/lib/vanagon/component/rules.rb index 219c611d..68684bf2 100644 --- a/lib/vanagon/component/rules.rb +++ b/lib/vanagon/component/rules.rb @@ -20,10 +20,10 @@ class Rules # # @!macro [attach] rule # @return [Makefile::Rule] The $1 rule - def self.rule(target, &block) + def self.rule(target, &) define_method("#{target}_rule") do Makefile::Rule.new("#{component.name}-#{target}") do |rule| - instance_exec(rule, &block) + instance_exec(rule, &) end end end diff --git a/lib/vanagon/extensions/set/json.rb b/lib/vanagon/extensions/set/json.rb index 732beeac..d086638f 100644 --- a/lib/vanagon/extensions/set/json.rb +++ b/lib/vanagon/extensions/set/json.rb @@ -1,4 +1,3 @@ -require 'set' require 'json' module SetJson diff --git a/lib/vanagon/platform.rb b/lib/vanagon/platform.rb index e27fe02d..a04be9b5 100644 --- a/lib/vanagon/platform.rb +++ b/lib/vanagon/platform.rb @@ -144,9 +144,9 @@ class Platform # Platform names currently contain some information about the platform. Fields # within the name are delimited by the '-' character, and this regex can be used to # extract those fields. - PLATFORM_REGEX = /^(.*)-(.*)-(.*)$/.freeze + PLATFORM_REGEX = /^(.*)-(.*)-(.*)$/ - VERSION_REGEX = /^([=<>]+)\s*([^<>=]*)$/.freeze + VERSION_REGEX = /^([=<>]+)\s*([^<>=]*)$/ # Loads a platform from the config/platforms directory # @@ -510,9 +510,9 @@ def package_override(project, var) # # @param *args [Array] List of arguments to pass on to the platform specific method # @raise [Vanagon::Error] an arror is raised if the current platform does not define add_repository - def add_build_repository(*args) + def add_build_repository(*) if self.respond_to?(:add_repository) - self.provision_with self.send(:add_repository, *args) + self.provision_with self.send(:add_repository, *) else raise Vanagon::Error, "Adding a build repository not defined for #{name}" end diff --git a/lib/vanagon/platform/dsl.rb b/lib/vanagon/platform/dsl.rb index f416da3a..76336e9b 100644 --- a/lib/vanagon/platform/dsl.rb +++ b/lib/vanagon/platform/dsl.rb @@ -470,8 +470,8 @@ def zypper_repo(definition) # # @param *args [Array] List of arguments to pass on to the platform specific method # @raise [Vanagon::Error] an arror is raised if the current platform does not define add_repository - def add_build_repository(*args) - @platform.add_build_repository(*args) + def add_build_repository(*) + @platform.add_build_repository(*) end def setting(name, value) diff --git a/lib/vanagon/project.rb b/lib/vanagon/project.rb index 918277ae..5c50e462 100644 --- a/lib/vanagon/project.rb +++ b/lib/vanagon/project.rb @@ -9,7 +9,7 @@ require 'time' # Used to parse the vendor field into name and email -VENDOR_REGEX = /^(.*) <(.*)>$/.freeze +VENDOR_REGEX = /^(.*) <(.*)>$/ class Vanagon class Project @@ -862,7 +862,7 @@ def load_yaml_settings(settings_uri, settings_sha1_uri = nil) source.file end - @settings.merge!(YAML.safe_load(File.read(yaml_path), permitted_classes: [Symbol])) + @settings.merge!(YAML.safe_load_file(yaml_path, permitted_classes: [Symbol])) end end diff --git a/lib/vanagon/project/dsl.rb b/lib/vanagon/project/dsl.rb index f42f5927..d8c9cb12 100644 --- a/lib/vanagon/project/dsl.rb +++ b/lib/vanagon/project/dsl.rb @@ -4,7 +4,6 @@ require 'vanagon/utilities' require 'vanagon/component/source' require 'git/rev_list' -require 'set' require 'yaml' class Vanagon @@ -28,7 +27,7 @@ def initialize(name, configdir, platform, include_components = []) # # @param name [String] name of the project # @param block [Proc] DSL definition of the project to call - def project(name, &block) + def project(name, &) yield(self) end diff --git a/lib/vanagon/utilities.rb b/lib/vanagon/utilities.rb index a0f70d27..c0ea15d9 100644 --- a/lib/vanagon/utilities.rb +++ b/lib/vanagon/utilities.rb @@ -158,7 +158,7 @@ def find_program_on_path(command, required = true) # @param timeout [Integer] number of seconds to run the block before timing out # @return [true] If the block succeeds, true is returned # @raise [Vanagon::Error] if the block fails after the retries are exhausted, an error is raised - def retry_with_timeout(tries = 5, timeout = 1, &blk) + def retry_with_timeout(tries = 5, timeout = 1, &) error = nil tries.to_i.times do Timeout::timeout(timeout.to_i) do @@ -276,8 +276,8 @@ def local_command(command, return_command_output: false, log: true) end end - def clean_environment(&block) - return Bundler.with_unbundled_env(&block) if defined?(Bundler) + def clean_environment(&) + return Bundler.with_unbundled_env(&) if defined?(Bundler) yield end private :clean_environment diff --git a/spec/lib/vanagon/project_spec.rb b/spec/lib/vanagon/project_spec.rb index e01d5766..06f63b09 100644 --- a/spec/lib/vanagon/project_spec.rb +++ b/spec/lib/vanagon/project_spec.rb @@ -258,7 +258,7 @@ class Project allow(Vanagon::Component::Source).to receive(:determine_source_type).and_return(:local) allow(Vanagon::Component::Source).to receive(:source).and_return(local_source) - allow(File).to receive(:read).with(yaml_path).and_return(yaml_content) + allow(YAML).to receive(:safe_load_file).with(yaml_path, permitted_classes: [Symbol]).and_return({ other: 'other', merged: 'yup' }) expect { project.load_yaml_settings(local_yaml_uri) }.not_to raise_exception end diff --git a/vanagon.gemspec b/vanagon.gemspec index 1ea9f4cf..1ade5ae6 100644 --- a/vanagon.gemspec +++ b/vanagon.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |gem| gem.authors = ['Puppet By Perforce', 'OpenVoxProjec'] gem.email = 'voxpupuli@groups.io' gem.homepage = 'http://github.com/OpenVoxProject/vanagon' - gem.required_ruby_version = ['>= 2.7', '< 4'] + gem.required_ruby_version = ['>= 3.2', '< 4'] gem.add_dependency('docopt', '~> 0.6.1') # Handle git repos responsibly