puppet-lint-version_comparison-check 1.1.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f0fb488a190f4b634f9913035b143587b4d04ab06067f43823c4d5a1362f9af
|
4
|
+
data.tar.gz: 660b7366183263734bb2202822568ab24d96552bb1513e710ad53f3786191e5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0070ed982948400602f81bf5b8cacd8a42da6ce7ed2044aea8080eca6769aef3cf266c1aa0e45c7541b2fb91c2a3a87f38cc349d5a762f863810516a0ab5ddf
|
7
|
+
data.tar.gz: cd95872558df90c2c74196b517ed452c190f25467d0f1fd7833f09e761efcf9f9a0af0a564d583b539b06a1f231cb1281bcd8ef47c367c459cfd9fc0a5b0caac
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,22 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
+
## [3.0.0](https://github.com/voxpupuli/puppet-lint-version_comparison-check/tree/3.0.0) (2025-09-25)
|
6
|
+
|
7
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-version_comparison-check/compare/2.0.0...3.0.0)
|
8
|
+
|
9
|
+
**Breaking changes:**
|
10
|
+
|
11
|
+
- Require Ruby 3.2+ & puppet-lint 5.1+ [\#26](https://github.com/voxpupuli/puppet-lint-version_comparison-check/pull/26) ([bastelfreak](https://github.com/bastelfreak))
|
12
|
+
|
13
|
+
## [2.0.0](https://github.com/voxpupuli/puppet-lint-version_comparison-check/tree/2.0.0) (2023-04-21)
|
14
|
+
|
15
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-version_comparison-check/compare/1.1.0...2.0.0)
|
16
|
+
|
17
|
+
**Breaking changes:**
|
18
|
+
|
19
|
+
- Drop Ruby \< 2.7; Add RuboCop [\#15](https://github.com/voxpupuli/puppet-lint-version_comparison-check/pull/15) ([bastelfreak](https://github.com/bastelfreak))
|
20
|
+
|
5
21
|
## [1.1.0](https://github.com/voxpupuli/puppet-lint-version_comparison-check/tree/1.1.0) (2022-11-29)
|
6
22
|
|
7
23
|
[Full Changelog](https://github.com/voxpupuli/puppet-lint-version_comparison-check/compare/1.0.0...1.1.0)
|
@@ -1,25 +1,27 @@
|
|
1
1
|
PuppetLint.new_check(:version_comparison) do
|
2
2
|
def is_num_comparison?(token)
|
3
3
|
return false unless token
|
4
|
-
return true if [
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
return true if %i[GREATEREQUAL GREATERTHAN LESSEQUAL LESSTHAN].include?(token.type)
|
5
|
+
|
6
|
+
true if %i[ISEQUAL NOTEQUAL].include?(token.type) &&
|
7
|
+
token.next_code_token &&
|
8
|
+
token.next_code_token.type == :NUMBER
|
8
9
|
end
|
9
10
|
|
10
11
|
def check
|
11
|
-
tokens.each_with_index do |token,
|
12
|
+
tokens.each_with_index do |token, _token_idx|
|
12
13
|
next unless token.type == :VARIABLE
|
13
|
-
next unless
|
14
|
+
next unless /(?:version|release)$/.match?(token.value)
|
14
15
|
next unless is_num_comparison?(token.next_code_token)
|
16
|
+
|
15
17
|
notify :warning, {
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
18
|
+
message: 'version compared as number',
|
19
|
+
line: token.line,
|
20
|
+
column: token.column,
|
21
|
+
token: token,
|
20
22
|
}
|
21
23
|
end
|
22
|
-
end
|
24
|
+
end
|
23
25
|
|
24
26
|
def compared_value(token)
|
25
27
|
token.next_code_token.next_code_token.value
|
@@ -32,23 +34,23 @@ PuppetLint.new_check(:version_comparison) do
|
|
32
34
|
)
|
33
35
|
lparen = PuppetLint::Lexer::Token.new(
|
34
36
|
:LPAREN, '(',
|
35
|
-
problem[:token].line, problem[:token].column+1
|
37
|
+
problem[:token].line, problem[:token].column + 1
|
36
38
|
)
|
37
39
|
rparen = PuppetLint::Lexer::Token.new(
|
38
40
|
:RPAREN, ')',
|
39
|
-
problem[:token].line, problem[:token].column+2 # not +2
|
41
|
+
problem[:token].line, problem[:token].column + 2 # not +2
|
40
42
|
)
|
41
43
|
space = PuppetLint::Lexer::Token.new(
|
42
44
|
:WHITESPACE, ' ',
|
43
|
-
problem[:token].line, problem[:token].column+3 # not +3
|
45
|
+
problem[:token].line, problem[:token].column + 3 # not +3
|
44
46
|
)
|
45
47
|
comma = PuppetLint::Lexer::Token.new(
|
46
48
|
:COMMA, ',',
|
47
|
-
problem[:token].line, problem[:token].column+4 # not +4
|
49
|
+
problem[:token].line, problem[:token].column + 4 # not +4
|
48
50
|
)
|
49
51
|
value = PuppetLint::Lexer::Token.new(
|
50
52
|
:SSTRING, compared_value(problem[:token]),
|
51
|
-
problem[:token].line, problem[:token].column+5 # not +5
|
53
|
+
problem[:token].line, problem[:token].column + 5 # not +5
|
52
54
|
)
|
53
55
|
|
54
56
|
idx = tokens.index(problem[:token])
|
@@ -57,12 +59,12 @@ PuppetLint.new_check(:version_comparison) do
|
|
57
59
|
value_token.value = 0
|
58
60
|
value_token.type = :NUMBER
|
59
61
|
# Insert ')' after value
|
60
|
-
tokens.insert(idx+1, rparen)
|
62
|
+
tokens.insert(idx + 1, rparen)
|
61
63
|
# Insert value as string after comma
|
62
|
-
tokens.insert(idx+1, value)
|
64
|
+
tokens.insert(idx + 1, value)
|
63
65
|
# Insert comma after token
|
64
|
-
tokens.insert(idx+1, space)
|
65
|
-
tokens.insert(idx+1, comma)
|
66
|
+
tokens.insert(idx + 1, space)
|
67
|
+
tokens.insert(idx + 1, comma)
|
66
68
|
# Insert 'versioncmp(' before token
|
67
69
|
tokens.insert(idx, lparen)
|
68
70
|
tokens.insert(idx, versioncmp)
|
@@ -14,7 +14,7 @@ describe 'version_comparison' do
|
|
14
14
|
EOS
|
15
15
|
end
|
16
16
|
|
17
|
-
it '
|
17
|
+
it 'does not detect any problems' do
|
18
18
|
expect(problems).to have(0).problems
|
19
19
|
end
|
20
20
|
end
|
@@ -29,11 +29,11 @@ describe 'version_comparison' do
|
|
29
29
|
EOS
|
30
30
|
end
|
31
31
|
|
32
|
-
it '
|
32
|
+
it 'detects 4 problems' do
|
33
33
|
expect(problems).to have(4).problems
|
34
34
|
end
|
35
35
|
|
36
|
-
it '
|
36
|
+
it 'creates warnings' do
|
37
37
|
expect(problems).to contain_warning(msg).on_line(1).in_column(12)
|
38
38
|
expect(problems).to contain_warning(msg).on_line(2).in_column(12)
|
39
39
|
expect(problems).to contain_warning(msg).on_line(3).in_column(12)
|
@@ -61,7 +61,7 @@ describe 'version_comparison' do
|
|
61
61
|
EOS
|
62
62
|
end
|
63
63
|
|
64
|
-
it '
|
64
|
+
it 'does not detect any problems' do
|
65
65
|
expect(problems).to have(0).problems
|
66
66
|
end
|
67
67
|
end
|
@@ -77,11 +77,11 @@ describe 'version_comparison' do
|
|
77
77
|
EOS
|
78
78
|
end
|
79
79
|
|
80
|
-
it '
|
80
|
+
it 'detects 5 problems' do
|
81
81
|
expect(problems).to have(5).problems
|
82
82
|
end
|
83
83
|
|
84
|
-
it '
|
84
|
+
it 'creates warnings' do
|
85
85
|
expect(problems).to contain_fixed(msg).on_line(1).in_column(12)
|
86
86
|
expect(problems).to contain_fixed(msg).on_line(2).in_column(12)
|
87
87
|
expect(problems).to contain_fixed(msg).on_line(3).in_column(12)
|
@@ -89,9 +89,9 @@ describe 'version_comparison' do
|
|
89
89
|
expect(problems).to contain_fixed(msg).on_line(5).in_column(12)
|
90
90
|
end
|
91
91
|
|
92
|
-
it '
|
92
|
+
it 'shoulds use versioncmp' do
|
93
93
|
expect(manifest).to eq(
|
94
|
-
|
94
|
+
<<-EOS,
|
95
95
|
if versioncmp($::lsbmajdistrelease, '4') >= 0 { }
|
96
96
|
if versioncmp($version, '1') <= 0 { }
|
97
97
|
if versioncmp($some_version, '3') < 0 { }
|
data/spec/spec_helper.rb
CHANGED
@@ -1,29 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
begin
|
4
|
-
require 'simplecov'
|
5
|
-
require 'simplecov-console'
|
6
|
-
require 'codecov'
|
7
|
-
rescue LoadError
|
8
|
-
else
|
9
|
-
SimpleCov.start do
|
10
|
-
track_files 'lib/**/*.rb'
|
11
|
-
|
12
|
-
add_filter '/spec'
|
13
|
-
|
14
|
-
enable_coverage :branch
|
15
|
-
|
16
|
-
# do not track vendored files
|
17
|
-
add_filter '/vendor'
|
18
|
-
add_filter '/.vendor'
|
19
|
-
end
|
20
|
-
|
21
|
-
SimpleCov.formatters = [
|
22
|
-
SimpleCov::Formatter::Console,
|
23
|
-
SimpleCov::Formatter::Codecov,
|
24
|
-
]
|
25
|
-
end
|
26
|
-
|
27
3
|
require 'puppet-lint'
|
4
|
+
require 'rspec/collection_matchers'
|
28
5
|
|
29
6
|
PuppetLint::Plugins.load_spec_helper
|
metadata
CHANGED
@@ -1,105 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-lint-version_comparison-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vox Pupuli
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: puppet-lint
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.0'
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '4'
|
23
|
-
type: :runtime
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '1.0'
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '4'
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: rspec
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '3.0'
|
40
|
-
type: :development
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - "~>"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '3.0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: rspec-its
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - "~>"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '1.0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
15
|
requirements:
|
58
16
|
- - "~>"
|
59
17
|
- !ruby/object:Gem::Version
|
60
|
-
version: '1
|
61
|
-
|
62
|
-
name: rspec-collection_matchers
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '1.0'
|
68
|
-
type: :development
|
18
|
+
version: '5.1'
|
19
|
+
type: :runtime
|
69
20
|
prerelease: false
|
70
21
|
version_requirements: !ruby/object:Gem::Requirement
|
71
22
|
requirements:
|
72
23
|
- - "~>"
|
73
24
|
- !ruby/object:Gem::Version
|
74
|
-
version: '1
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: simplecov
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - ">="
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '0'
|
82
|
-
type: :development
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - ">="
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '0'
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: rake
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - ">="
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '0'
|
96
|
-
type: :development
|
97
|
-
prerelease: false
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - ">="
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: '0'
|
25
|
+
version: '5.1'
|
103
26
|
description: " A puppet-lint plugin to check for versions compared as numbers.\n"
|
104
27
|
email: voxpupuli@groups.io
|
105
28
|
executables: []
|
@@ -116,7 +39,6 @@ homepage: https://github.com/voxpupuli/puppet-lint-version_comparison-check
|
|
116
39
|
licenses:
|
117
40
|
- Apache-2.0
|
118
41
|
metadata: {}
|
119
|
-
post_install_message:
|
120
42
|
rdoc_options: []
|
121
43
|
require_paths:
|
122
44
|
- lib
|
@@ -124,17 +46,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
46
|
requirements:
|
125
47
|
- - ">="
|
126
48
|
- !ruby/object:Gem::Version
|
127
|
-
version: '
|
49
|
+
version: '3.2'
|
128
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
51
|
requirements:
|
130
52
|
- - ">="
|
131
53
|
- !ruby/object:Gem::Version
|
132
54
|
version: '0'
|
133
55
|
requirements: []
|
134
|
-
rubygems_version: 3.
|
135
|
-
signing_key:
|
56
|
+
rubygems_version: 3.6.9
|
136
57
|
specification_version: 4
|
137
58
|
summary: A puppet-lint plugin to check for versions compared as numbers.
|
138
|
-
test_files:
|
139
|
-
- spec/puppet-lint/plugins/check_version_comparison/version_comparison_spec.rb
|
140
|
-
- spec/spec_helper.rb
|
59
|
+
test_files: []
|