File tree 3 files changed +8
-27
lines changed
3 files changed +8
-27
lines changed Original file line number Diff line number Diff line change 22
22
- ' 2.7'
23
23
- ' 3.2'
24
24
- ' 3.3'
25
+ - ' 3.4'
25
26
name : " spec (ruby ${{ matrix.ruby_version }})"
26
27
uses : " puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main"
27
28
secrets : " inherit"
37
38
- ' 2.7'
38
39
- ' 3.2'
39
40
- ' 3.3'
41
+ - ' 3.4'
40
42
name : " acceptance (ruby ${{ matrix.ruby_version }})"
41
43
needs : " spec"
42
44
uses : " puppetlabs/cat-github-actions/.github/workflows/gem_acceptance.yml@main"
Original file line number Diff line number Diff line change @@ -55,7 +55,9 @@ def fix_problems
55
55
#
56
56
# Returns an Array of PuppetLint::Lexer::Token objects.
57
57
def tokens
58
- PuppetLint ::Data . tokens
58
+ # When called from a plugins `check` method, the tokens returned should be a copy
59
+ called_from_check = ( caller_locations ( 1 ..1 ) . first . label == 'check' )
60
+ PuppetLint ::Data . tokens ( duplicate : called_from_check )
59
61
end
60
62
61
63
def add_token ( index , token )
Original file line number Diff line number Diff line change @@ -38,37 +38,14 @@ def tokens=(tokens)
38
38
@defaults_indexes = nil
39
39
end
40
40
41
- # @api private
42
- def ruby1?
43
- @ruby1 = RbConfig ::CONFIG [ 'MAJOR' ] == '1' if @ruby1 . nil?
44
- @ruby1
45
- end
46
-
47
41
# Get the tokenised manifest.
48
42
#
43
+ # @param duplicate [Boolean] if true, returns a duplicate of the token array.
49
44
# @return [Array[PuppetLint::Lexer::Token]]
50
45
#
51
46
# @api public
52
- def tokens
53
- calling_method = if ruby1?
54
- begin
55
- caller [ 0 ] [ %r{`.*'} ] [ 1 ..-2 ] # rubocop:disable Performance/Caller
56
- rescue NoMethodError
57
- caller [ 1 ] [ %r{`.*'} ] [ 1 ..-2 ] # rubocop:disable Performance/Caller
58
- end
59
- else
60
- begin
61
- caller ( 0 ..0 ) . first [ %r{`.*'} ] [ 1 ..-2 ]
62
- rescue NoMethodError
63
- caller ( 1 ..1 ) . first [ %r{`.*'} ] [ 1 ..-2 ]
64
- end
65
- end
66
-
67
- if calling_method == 'check'
68
- @tokens . dup
69
- else
70
- @tokens
71
- end
47
+ def tokens ( duplicate : false )
48
+ duplicate ? @tokens . dup : @tokens
72
49
end
73
50
74
51
# Add new token.
You can’t perform that action at this time.
0 commit comments