From c54718d813289313c2329b9373f2f0ded20ddecf Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 8 Apr 2024 21:39:49 +0200 Subject: [PATCH 1/3] Update fakefs and rubocop to latest version Remove `spec` from files (spec are included when gem installed) Remove `test_files` (not required anymore) --- pathspec.gemspec | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pathspec.gemspec b/pathspec.gemspec index 7d81b12..f6a8eee 100644 --- a/pathspec.gemspec +++ b/pathspec.gemspec @@ -1,3 +1,5 @@ +# frozen_string_literal: true + lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) @@ -8,10 +10,9 @@ Gem::Specification.new do |s| s.description = 'Use to match path patterns such as gitignore' s.authors = ['Brandon High'] s.email = 'highb@users.noreply.github.com' - s.files = Dir.glob('{lib,spec,docs}/**/*') + %w[LICENSE README.md CHANGELOG.md] + s.files = Dir.glob('{lib,docs}/**/*') + %w[LICENSE README.md CHANGELOG.md] s.bindir = 'bin' s.executables << 'pathspec-rb' - s.test_files = s.files.grep(%r{^spec/}) s.require_paths = ['lib'] s.metadata['allowed_push_host'] = 'https://rubygems.org' s.metadata['rubygems_mfa_required'] = 'true' @@ -19,10 +20,10 @@ Gem::Specification.new do |s| s.license = 'Apache-2.0' s.required_ruby_version = '>= 3.1.0' s.add_development_dependency 'bundler', '~> 2.2' - s.add_development_dependency 'fakefs', '~> 1.3' + s.add_development_dependency 'fakefs', '~> 2.5' s.add_development_dependency 'kramdown', '~> 2.3' s.add_development_dependency 'rake', '~> 13.0' s.add_development_dependency 'rspec', '~> 3.10' - s.add_development_dependency 'rubocop', '~> 1.7' + s.add_development_dependency 'rubocop', '~> 1.63.0' s.add_development_dependency 'simplecov', '~> 0.21' end From 06132c10faccb844a169d65ef38bb6db2ee6a61d Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 8 Apr 2024 21:40:15 +0200 Subject: [PATCH 2/3] Regenerate rubocop Fix frozen_string_literal --- .rubocop.yml | 2 +- .rubocop_todo.yml | 100 ++++++++++------------- Gemfile | 2 + Rakefile | 2 + lib/pathspec.rb | 2 + lib/pathspec/gitignorespec.rb | 6 +- lib/pathspec/regexspec.rb | 2 + lib/pathspec/spec.rb | 2 + spec/spec_helper.rb | 2 + spec/unit/pathspec/gitignorespec_spec.rb | 2 + spec/unit/pathspec/spec_spec.rb | 2 + spec/unit/pathspec_spec.rb | 2 + 12 files changed, 64 insertions(+), 62 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index bb0a941..63c3ce1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,7 +1,7 @@ inherit_from: .rubocop_todo.yml AllCops: - TargetRubyVersion: 2.6 + TargetRubyVersion: 3.1 NewCops: enable Style/NumericPredicate: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6c8109c..40eed2d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,27 +1,33 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2018-01-11 16:42:16 -0800 using RuboCop version 0.52.1. +# on 2024-04-08 19:36:04 UTC using RuboCop version 1.63.0. # 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 # versions of RuboCop, may require this file to be generated again. +# Offense count: 7 +# Configuration parameters: EnforcedStyle, AllowedGems, Include. +# SupportedStyles: Gemfile, gems.rb, gemspec +# Include: **/*.gemspec, **/Gemfile, **/gems.rb +Gemspec/DevelopmentDependencies: + Exclude: + - 'pathspec.gemspec' + # Offense count: 2 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Layout/BlockEndNewline: Exclude: - 'spec/unit/pathspec_spec.rb' # Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent +# This cop supports safe autocorrection (--autocorrect). Layout/HeredocIndentation: Exclude: - 'spec/unit/pathspec_spec.rb' # Offense count: 8 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. # SupportedStyles: space, no_space # SupportedStylesForEmptyBraces: space, no_space @@ -30,39 +36,37 @@ Layout/SpaceInsideBlockBraces: - 'lib/pathspec.rb' - 'spec/unit/pathspec_spec.rb' -# Offense count: 2 -Lint/ImplicitStringConcatenation: - Exclude: - - 'lib/pathspec/gitignorespec.rb' - # Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. Lint/UnusedMethodArgument: Exclude: - 'lib/pathspec/spec.rb' # Offense count: 3 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AutoCorrect. Lint/UselessAssignment: Exclude: - 'spec/unit/pathspec_spec.rb' -# Offense count: 2 +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect, CheckForMethodsWithNoSideEffects. Lint/Void: Exclude: - 'lib/pathspec.rb' - - 'lib/pathspec/gitignorespec.rb' # Offense count: 3 +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: - Enabled: false - Max: 62 + Max: 63 -# Offense count: 7 -# Configuration parameters: CountComments, ExcludedMethods. +# Offense count: 8 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. +# AllowedMethods: refine Metrics/BlockLength: - Enabled: false - Max: 270 + Max: 300 # Offense count: 2 # Configuration parameters: CountBlocks. @@ -70,62 +74,40 @@ Metrics/BlockNesting: Max: 4 # Offense count: 1 -# Configuration parameters: CountComments. +# Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 146 + Max: 123 -# Offense count: 2 +# Offense count: 1 +# Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: - Max: 26 + Max: 18 # Offense count: 3 -# Configuration parameters: CountComments. +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: - Max: 77 + Max: 69 # Offense count: 2 +# Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/PerceivedComplexity: - Max: 32 + Max: 31 # Offense count: 25 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods. -# SupportedStyles: line_count_based, semantic, braces_for_chaining +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. +# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object # FunctionalMethods: let, let!, subject, watch -# IgnoredMethods: lambda, proc, it +# AllowedMethods: lambda, proc, it Style/BlockDelimiters: Exclude: - 'spec/unit/pathspec_spec.rb' -# Offense count: 11 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: when_needed, always, never -Style/FrozenStringLiteralComment: - Exclude: - - 'Gemfile' - - 'Rakefile' - - 'lib/pathspec.rb' - - 'lib/pathspec/gitignorespec.rb' - - 'lib/pathspec/regexspec.rb' - - 'lib/pathspec/spec.rb' - - 'pathspec.gemspec' - - 'spec/spec_helper.rb' - - 'spec/unit/pathspec/gitignorespec_spec.rb' - - 'spec/unit/pathspec/spec_spec.rb' - - 'spec/unit/pathspec_spec.rb' - # Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: IgnoredMethods. -# IgnoredMethods: respond_to, define_method +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments. +# AllowedMethods: define_method Style/SymbolProc: Exclude: - 'lib/pathspec.rb' - -# Offense count: 7 -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. -# URISchemes: http, https -Layout/LineLength: - Max: 108 diff --git a/Gemfile b/Gemfile index fa75df1..7f4f5e9 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'https://rubygems.org' gemspec diff --git a/Rakefile b/Rakefile index b09e579..ab05425 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + begin require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) diff --git a/lib/pathspec.rb b/lib/pathspec.rb index 9cd4b14..4f468ab 100644 --- a/lib/pathspec.rb +++ b/lib/pathspec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'pathspec/gitignorespec' require 'pathspec/regexspec' require 'find' diff --git a/lib/pathspec/gitignorespec.rb b/lib/pathspec/gitignorespec.rb index 38e2a25..7eb595c 100644 --- a/lib/pathspec/gitignorespec.rb +++ b/lib/pathspec/gitignorespec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'pathspec/regexspec' class PathSpec @@ -87,7 +89,7 @@ def initialize(original_pattern) # rubocop:disable Metrics/CyclomaticComplexity end # Build regular expression from pattern. - regex = '^' + regex = +'^' need_slash = false regex_end = pattern_segs.size - 1 pattern_segs.each_index do |i| @@ -165,7 +167,7 @@ def translate_segment_glob(pattern) # the POSIX function `fnmatch()` with the `FNM_PATHNAME` flag set. escape = false - regex = '' + regex = +'' i = 0 while i < pattern.size diff --git a/lib/pathspec/regexspec.rb b/lib/pathspec/regexspec.rb index 46b7e44..521c192 100644 --- a/lib/pathspec/regexspec.rb +++ b/lib/pathspec/regexspec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'pathspec/spec' class PathSpec diff --git a/lib/pathspec/spec.rb b/lib/pathspec/spec.rb index 812d69d..1181684 100644 --- a/lib/pathspec/spec.rb +++ b/lib/pathspec/spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PathSpec # Abstract spec class Spec diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3ae0c3b..4da3bd2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + begin require 'simplecov' SimpleCov.start diff --git a/spec/unit/pathspec/gitignorespec_spec.rb b/spec/unit/pathspec/gitignorespec_spec.rb index edea99c..b2cdeda 100644 --- a/spec/unit/pathspec/gitignorespec_spec.rb +++ b/spec/unit/pathspec/gitignorespec_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'pathspec/gitignorespec' diff --git a/spec/unit/pathspec/spec_spec.rb b/spec/unit/pathspec/spec_spec.rb index 7a9059e..e1cf0ac 100644 --- a/spec/unit/pathspec/spec_spec.rb +++ b/spec/unit/pathspec/spec_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'pathspec/spec' diff --git a/spec/unit/pathspec_spec.rb b/spec/unit/pathspec_spec.rb index 8a27ca0..f079fe1 100644 --- a/spec/unit/pathspec_spec.rb +++ b/spec/unit/pathspec_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'fakefs/safe' require 'pathspec' From 9a00fc0fb653dd9e42fde9a7090815c3c5ec1bbf Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 8 Apr 2024 21:52:26 +0200 Subject: [PATCH 3/3] Update ruby/setup-ruby to v1 --- .github/workflows/gem-push.yml | 2 +- .github/workflows/ruby.yml | 19 +++---------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/.github/workflows/gem-push.yml b/.github/workflows/gem-push.yml index 8a84c28..891d491 100644 --- a/.github/workflows/gem-push.yml +++ b/.github/workflows/gem-push.yml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Ruby 3.1 - uses: ruby/setup-ruby@d4526a55538b775af234ba4af27118ed6f8f6677 + uses: ruby/setup-ruby@v1 with: ruby-version: '3.1' bundler-cache: true # runs 'bundle install' and caches installed gems automatically diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index d5d2562..bff8253 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -15,19 +15,14 @@ on: jobs: build: - runs-on: ubuntu-latest strategy: matrix: ruby-version: ['3.1', '3.2', '3.3'] - steps: - uses: actions/checkout@v4 - name: Set up Ruby - # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, - # change this to (see https://github.com/ruby/setup-ruby#versioning): - # uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@d4526a55538b775af234ba4af27118ed6f8f6677 + uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true # runs 'bundle install' and caches installed gems automatically @@ -37,23 +32,15 @@ jobs: run: gem install ./pathspec*.gem test: - runs-on: ubuntu-latest strategy: matrix: ruby-version: ['3.1', '3.2', '3.3'] - # TODO: Fix rubocop issues - # raketasks: ['rubocop', 'spec', 'docs'] - raketasks: ['spec', 'docs'] - - + raketasks: ['rubocop', 'spec', 'docs'] steps: - uses: actions/checkout@v4 - name: Set up Ruby - # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, - # change this to (see https://github.com/ruby/setup-ruby#versioning): - # uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@d4526a55538b775af234ba4af27118ed6f8f6677 + uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true # runs 'bundle install' and caches installed gems automatically