Skip to content

Commit 23737d2

Browse files
authored
Add frozen string literal + small update (#50)
* Update fakefs and rubocop to latest version Remove `spec` from files (spec are included when gem installed) Remove `test_files` (not required anymore) * Regenerate rubocop Fix frozen_string_literal * Update ruby/setup-ruby to v1
1 parent 7b67ad9 commit 23737d2

15 files changed

Lines changed: 73 additions & 83 deletions

.github/workflows/gem-push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v4
1919
- name: Set up Ruby 3.1
20-
uses: ruby/setup-ruby@d4526a55538b775af234ba4af27118ed6f8f6677
20+
uses: ruby/setup-ruby@v1
2121
with:
2222
ruby-version: '3.1'
2323
bundler-cache: true # runs 'bundle install' and caches installed gems automatically

.github/workflows/ruby.yml

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,14 @@ on:
1515

1616
jobs:
1717
build:
18-
1918
runs-on: ubuntu-latest
2019
strategy:
2120
matrix:
2221
ruby-version: ['3.1', '3.2', '3.3']
23-
2422
steps:
2523
- uses: actions/checkout@v4
2624
- name: Set up Ruby
27-
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
28-
# change this to (see https://github.com/ruby/setup-ruby#versioning):
29-
# uses: ruby/setup-ruby@v1
30-
uses: ruby/setup-ruby@d4526a55538b775af234ba4af27118ed6f8f6677
25+
uses: ruby/setup-ruby@v1
3126
with:
3227
ruby-version: ${{ matrix.ruby-version }}
3328
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
@@ -37,23 +32,15 @@ jobs:
3732
run: gem install ./pathspec*.gem
3833

3934
test:
40-
4135
runs-on: ubuntu-latest
4236
strategy:
4337
matrix:
4438
ruby-version: ['3.1', '3.2', '3.3']
45-
# TODO: Fix rubocop issues
46-
# raketasks: ['rubocop', 'spec', 'docs']
47-
raketasks: ['spec', 'docs']
48-
49-
39+
raketasks: ['rubocop', 'spec', 'docs']
5040
steps:
5141
- uses: actions/checkout@v4
5242
- name: Set up Ruby
53-
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
54-
# change this to (see https://github.com/ruby/setup-ruby#versioning):
55-
# uses: ruby/setup-ruby@v1
56-
uses: ruby/setup-ruby@d4526a55538b775af234ba4af27118ed6f8f6677
43+
uses: ruby/setup-ruby@v1
5744
with:
5845
ruby-version: ${{ matrix.ruby-version }}
5946
bundler-cache: true # runs 'bundle install' and caches installed gems automatically

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
inherit_from: .rubocop_todo.yml
22

33
AllCops:
4-
TargetRubyVersion: 2.6
4+
TargetRubyVersion: 3.1
55
NewCops: enable
66

77
Style/NumericPredicate:

.rubocop_todo.yml

Lines changed: 41 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2018-01-11 16:42:16 -0800 using RuboCop version 0.52.1.
3+
# on 2024-04-08 19:36:04 UTC using RuboCop version 1.63.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

9+
# Offense count: 7
10+
# Configuration parameters: EnforcedStyle, AllowedGems, Include.
11+
# SupportedStyles: Gemfile, gems.rb, gemspec
12+
# Include: **/*.gemspec, **/Gemfile, **/gems.rb
13+
Gemspec/DevelopmentDependencies:
14+
Exclude:
15+
- 'pathspec.gemspec'
16+
917
# Offense count: 2
10-
# Cop supports --auto-correct.
18+
# This cop supports safe autocorrection (--autocorrect).
1119
Layout/BlockEndNewline:
1220
Exclude:
1321
- 'spec/unit/pathspec_spec.rb'
1422

1523
# Offense count: 6
16-
# Cop supports --auto-correct.
17-
# Configuration parameters: EnforcedStyle.
18-
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
24+
# This cop supports safe autocorrection (--autocorrect).
1925
Layout/HeredocIndentation:
2026
Exclude:
2127
- 'spec/unit/pathspec_spec.rb'
2228

2329
# Offense count: 8
24-
# Cop supports --auto-correct.
30+
# This cop supports safe autocorrection (--autocorrect).
2531
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
2632
# SupportedStyles: space, no_space
2733
# SupportedStylesForEmptyBraces: space, no_space
@@ -30,102 +36,78 @@ Layout/SpaceInsideBlockBraces:
3036
- 'lib/pathspec.rb'
3137
- 'spec/unit/pathspec_spec.rb'
3238

33-
# Offense count: 2
34-
Lint/ImplicitStringConcatenation:
35-
Exclude:
36-
- 'lib/pathspec/gitignorespec.rb'
37-
3839
# Offense count: 1
39-
# Cop supports --auto-correct.
40-
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
40+
# This cop supports safe autocorrection (--autocorrect).
41+
# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
4142
Lint/UnusedMethodArgument:
4243
Exclude:
4344
- 'lib/pathspec/spec.rb'
4445

4546
# Offense count: 3
47+
# This cop supports unsafe autocorrection (--autocorrect-all).
48+
# Configuration parameters: AutoCorrect.
4649
Lint/UselessAssignment:
4750
Exclude:
4851
- 'spec/unit/pathspec_spec.rb'
4952

50-
# Offense count: 2
53+
# Offense count: 1
54+
# This cop supports safe autocorrection (--autocorrect).
55+
# Configuration parameters: AutoCorrect, CheckForMethodsWithNoSideEffects.
5156
Lint/Void:
5257
Exclude:
5358
- 'lib/pathspec.rb'
54-
- 'lib/pathspec/gitignorespec.rb'
5559

5660
# Offense count: 3
61+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
5762
Metrics/AbcSize:
58-
Enabled: false
59-
Max: 62
63+
Max: 63
6064

61-
# Offense count: 7
62-
# Configuration parameters: CountComments, ExcludedMethods.
65+
# Offense count: 8
66+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
67+
# AllowedMethods: refine
6368
Metrics/BlockLength:
64-
Enabled: false
65-
Max: 270
69+
Max: 300
6670

6771
# Offense count: 2
6872
# Configuration parameters: CountBlocks.
6973
Metrics/BlockNesting:
7074
Max: 4
7175

7276
# Offense count: 1
73-
# Configuration parameters: CountComments.
77+
# Configuration parameters: CountComments, CountAsOne.
7478
Metrics/ClassLength:
75-
Max: 146
79+
Max: 123
7680

77-
# Offense count: 2
81+
# Offense count: 1
82+
# Configuration parameters: AllowedMethods, AllowedPatterns.
7883
Metrics/CyclomaticComplexity:
79-
Max: 26
84+
Max: 18
8085

8186
# Offense count: 3
82-
# Configuration parameters: CountComments.
87+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
8388
Metrics/MethodLength:
84-
Max: 77
89+
Max: 69
8590

8691
# Offense count: 2
92+
# Configuration parameters: AllowedMethods, AllowedPatterns.
8793
Metrics/PerceivedComplexity:
88-
Max: 32
94+
Max: 31
8995

9096
# Offense count: 25
91-
# Cop supports --auto-correct.
92-
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods.
93-
# SupportedStyles: line_count_based, semantic, braces_for_chaining
97+
# This cop supports safe autocorrection (--autocorrect).
98+
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
99+
# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
94100
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
95101
# FunctionalMethods: let, let!, subject, watch
96-
# IgnoredMethods: lambda, proc, it
102+
# AllowedMethods: lambda, proc, it
97103
Style/BlockDelimiters:
98104
Exclude:
99105
- 'spec/unit/pathspec_spec.rb'
100106

101-
# Offense count: 11
102-
# Cop supports --auto-correct.
103-
# Configuration parameters: EnforcedStyle.
104-
# SupportedStyles: when_needed, always, never
105-
Style/FrozenStringLiteralComment:
106-
Exclude:
107-
- 'Gemfile'
108-
- 'Rakefile'
109-
- 'lib/pathspec.rb'
110-
- 'lib/pathspec/gitignorespec.rb'
111-
- 'lib/pathspec/regexspec.rb'
112-
- 'lib/pathspec/spec.rb'
113-
- 'pathspec.gemspec'
114-
- 'spec/spec_helper.rb'
115-
- 'spec/unit/pathspec/gitignorespec_spec.rb'
116-
- 'spec/unit/pathspec/spec_spec.rb'
117-
- 'spec/unit/pathspec_spec.rb'
118-
119107
# Offense count: 1
120-
# Cop supports --auto-correct.
121-
# Configuration parameters: IgnoredMethods.
122-
# IgnoredMethods: respond_to, define_method
108+
# This cop supports unsafe autocorrection (--autocorrect-all).
109+
# Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments.
110+
# AllowedMethods: define_method
123111
Style/SymbolProc:
124112
Exclude:
125113
- 'lib/pathspec.rb'
126-
127-
# Offense count: 7
128-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
129-
# URISchemes: http, https
130-
Layout/LineLength:
131-
Max: 108

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24

35
gemspec

Rakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
begin
24
require 'rspec/core/rake_task'
35
RSpec::Core::RakeTask.new(:spec)

lib/pathspec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'pathspec/gitignorespec'
24
require 'pathspec/regexspec'
35
require 'find'

lib/pathspec/gitignorespec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'pathspec/regexspec'
24

35
class PathSpec
@@ -87,7 +89,7 @@ def initialize(original_pattern) # rubocop:disable Metrics/CyclomaticComplexity
8789
end
8890

8991
# Build regular expression from pattern.
90-
regex = '^'
92+
regex = +'^'
9193
need_slash = false
9294
regex_end = pattern_segs.size - 1
9395
pattern_segs.each_index do |i|
@@ -165,7 +167,7 @@ def translate_segment_glob(pattern)
165167
# the POSIX function `fnmatch()` with the `FNM_PATHNAME` flag set.
166168

167169
escape = false
168-
regex = ''
170+
regex = +''
169171
i = 0
170172

171173
while i < pattern.size

lib/pathspec/regexspec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'pathspec/spec'
24

35
class PathSpec

lib/pathspec/spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class PathSpec
24
# Abstract spec
35
class Spec

0 commit comments

Comments
 (0)