From dee3fdd4722c537a10b1d9ec4fa22b58d87e33db Mon Sep 17 00:00:00 2001 From: dcrosby Date: Tue, 17 Dec 2024 12:50:57 -0800 Subject: [PATCH 1/4] Migrate from Chefstyle to Cookstyle Signed-off-by: David Crosby --- Gemfile | 2 +- Rakefile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 16ecb97..45f4bd5 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ group :docs do end group :test do - gem "chefstyle", "=0.4.0" # pin needed until we drop Ruby 2.0/2.1 support + gem "cookstyle", ">= 7.32.8" gem "rspec", "~> 3.0" gem "rspec-its" gem "rake" diff --git a/Rakefile b/Rakefile index 5bea062..f33cb2e 100644 --- a/Rakefile +++ b/Rakefile @@ -15,14 +15,14 @@ rescue LoadError end begin - require "chefstyle" + require "cookstyle/chefstyle" require "rubocop/rake_task" desc "Run Chefstyle tests" RuboCop::RakeTask.new(:style) do |task| task.options += ["--display-cop-names", "--no-color"] end rescue LoadError - puts "chefstyle gem is not installed. bundle install first to make sure all dependencies are installed." + puts "cookstyle gem is not installed. bundle install first to make sure all dependencies are installed." end begin From 9881555ab582baed0fe082161bea9dd475c69e35 Mon Sep 17 00:00:00 2001 From: dcrosby Date: Tue, 17 Dec 2024 12:57:40 -0800 Subject: [PATCH 2/4] [rubocop] Style/ExpandPathArguments Signed-off-by: David Crosby --- mixlib-versioning.gemspec | 2 +- spec/spec_helper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mixlib-versioning.gemspec b/mixlib-versioning.gemspec index a218f77..04eeb61 100644 --- a/mixlib-versioning.gemspec +++ b/mixlib-versioning.gemspec @@ -1,4 +1,4 @@ -lib = File.expand_path("../lib", __FILE__) +lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "mixlib/versioning/version" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e979906..6a38852 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -20,7 +20,7 @@ require "rspec/its" # load all shared examples and shared contexts -Dir[File.expand_path("../support/**/*.rb", __FILE__)].each do |file| +Dir[File.expand_path("support/**/*.rb", __dir__)].each do |file| require(file) end From ed9334ed5bfa442619ce17760d99d2d7a2342733 Mon Sep 17 00:00:00 2001 From: dcrosby Date: Tue, 17 Dec 2024 12:57:26 -0800 Subject: [PATCH 3/4] [rubocop] Style/RedundantBegin Signed-off-by: David Crosby --- lib/mixlib/versioning.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/mixlib/versioning.rb b/lib/mixlib/versioning.rb index 5fa759d..f6e2686 100644 --- a/lib/mixlib/versioning.rb +++ b/lib/mixlib/versioning.rb @@ -66,11 +66,11 @@ def self.parse(version_string, format = nil) # Attempt to parse from the most specific formats first. parsed_version = nil formats.each do |version| - begin - break parsed_version = version.new(version_string) - rescue Mixlib::Versioning::ParseError - next - end + + break parsed_version = version.new(version_string) + rescue Mixlib::Versioning::ParseError + next + end parsed_version end From f0f0cac5d7f6023ea1c691e1b44f4fa325b24e06 Mon Sep 17 00:00:00 2001 From: dcrosby Date: Tue, 17 Dec 2024 12:56:22 -0800 Subject: [PATCH 4/4] [rubocop] Style/MutableConstant Signed-off-by: David Crosby --- lib/mixlib/versioning/format/git_describe.rb | 2 +- lib/mixlib/versioning/format/opscode_semver.rb | 4 ++-- lib/mixlib/versioning/format/partial_semver.rb | 2 +- lib/mixlib/versioning/format/rubygems.rb | 2 +- lib/mixlib/versioning/format/semver.rb | 2 +- lib/mixlib/versioning/version.rb | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/mixlib/versioning/format/git_describe.rb b/lib/mixlib/versioning/format/git_describe.rb index 79dad05..e97b66a 100644 --- a/lib/mixlib/versioning/format/git_describe.rb +++ b/lib/mixlib/versioning/format/git_describe.rb @@ -44,7 +44,7 @@ class Format # @author Seth Chisamore () # @author Christopher Maier () class GitDescribe < Format - GIT_DESCRIBE_REGEX = /^(\d+)\.(\d+)\.(\d+)(?:\-|\.)?(.+)?\-(\d+)\-g([a-f0-9]{7,40})(?:\-)?(\d+)?$/ + GIT_DESCRIBE_REGEX = /^(\d+)\.(\d+)\.(\d+)(?:\-|\.)?(.+)?\-(\d+)\-g([a-f0-9]{7,40})(?:\-)?(\d+)?$/.freeze attr_reader :commits_since, :commit_sha diff --git a/lib/mixlib/versioning/format/opscode_semver.rb b/lib/mixlib/versioning/format/opscode_semver.rb index 4999cc1..dc61248 100644 --- a/lib/mixlib/versioning/format/opscode_semver.rb +++ b/lib/mixlib/versioning/format/opscode_semver.rb @@ -55,7 +55,7 @@ class Format # @author Christopher Maier () class OpscodeSemVer < SemVer # The pattern is: `YYYYMMDDHHMMSS.git.COMMITS_SINCE.SHA1` - OPSCODE_BUILD_REGEX = /^\d{14}(\.git\.\d+\.[a-f0-9]{7})?$/ + OPSCODE_BUILD_REGEX = /^\d{14}(\.git\.\d+\.[a-f0-9]{7})?$/.freeze # Allows the following: # @@ -65,7 +65,7 @@ class OpscodeSemVer < SemVer # rc, rc.0, rc.1, rc.2, etc. # ``` # - OPSCODE_PRERELEASE_REGEX = /^(alpha|beta|rc)(\.\d+)?$/ + OPSCODE_PRERELEASE_REGEX = /^(alpha|beta|rc)(\.\d+)?$/.freeze # @see SemVer#parse def parse(version_string) diff --git a/lib/mixlib/versioning/format/partial_semver.rb b/lib/mixlib/versioning/format/partial_semver.rb index c48bb71..a34f1aa 100644 --- a/lib/mixlib/versioning/format/partial_semver.rb +++ b/lib/mixlib/versioning/format/partial_semver.rb @@ -40,7 +40,7 @@ class Format # @author Ryan Hass () class PartialSemVer < Format # http://rubular.com/r/NmRSN8vCie - PARTIAL_REGEX = /^(\d+)\.?(?:(\d*))$/ + PARTIAL_REGEX = /^(\d+)\.?(?:(\d*))$/.freeze # @see Format#parse def parse(version_string) match = version_string.match(PARTIAL_REGEX) rescue nil diff --git a/lib/mixlib/versioning/format/rubygems.rb b/lib/mixlib/versioning/format/rubygems.rb index 432bfd5..26bebb2 100644 --- a/lib/mixlib/versioning/format/rubygems.rb +++ b/lib/mixlib/versioning/format/rubygems.rb @@ -42,7 +42,7 @@ class Format # @author Seth Chisamore () # @author Christopher Maier () class Rubygems < Format - RUBYGEMS_REGEX = /^(\d+)\.(\d+)\.(\d+)(?:\.([[:alnum:]]+(?:\.[[:alnum:]]+)?))?(?:\-(\d+))?$/ + RUBYGEMS_REGEX = /^(\d+)\.(\d+)\.(\d+)(?:\.([[:alnum:]]+(?:\.[[:alnum:]]+)?))?(?:\-(\d+))?$/.freeze # @see Format#parse def parse(version_string) diff --git a/lib/mixlib/versioning/format/semver.rb b/lib/mixlib/versioning/format/semver.rb index 7256a15..3a845cd 100644 --- a/lib/mixlib/versioning/format/semver.rb +++ b/lib/mixlib/versioning/format/semver.rb @@ -42,7 +42,7 @@ class Format # @author Seth Chisamore () # @author Christopher Maier () class SemVer < Format - SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][a-zA-Z0-9-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][a-zA-Z0-9-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/ + SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][a-zA-Z0-9-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][a-zA-Z0-9-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/.freeze # @see Format#parse def parse(version_string) diff --git a/lib/mixlib/versioning/version.rb b/lib/mixlib/versioning/version.rb index f6b99fa..e5286e6 100644 --- a/lib/mixlib/versioning/version.rb +++ b/lib/mixlib/versioning/version.rb @@ -18,6 +18,6 @@ module Mixlib class Versioning - VERSION = "1.2.18" + VERSION = "1.2.18".freeze end end