puppet-lint-version_comparison-check 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '080c1a44f220a8186a060cf8bb65c4978e15ea9eae341bcdb1887fb4cb963de0'
|
4
|
+
data.tar.gz: aa9ff314e709c59c3d84c87d4e4d8c8243c5a85b74677d892dcb87847f1205b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aadedb778788535e4108d8ffe0889fe7831bbb03b240ea3a27b78b2482563fe9febfae443c8ae9e110d5068f84c6ad84b3045589b75e616a74868315dad75af
|
7
|
+
data.tar.gz: cf86cfe2781a3adadb4186fdb28e4f5a1a02e74749cc93a10ef18d9f980a4f15fc3cb01ef1d4005ee01515207be069e17e9917a21e0eec6598ed564f44323f03
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
## [2.0.0](https://github.com/voxpupuli/puppet-lint-version_comparison-check/tree/2.0.0) (2023-04-21)
|
6
|
+
|
7
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-version_comparison-check/compare/1.1.0...2.0.0)
|
8
|
+
|
9
|
+
**Breaking changes:**
|
10
|
+
|
11
|
+
- Drop Ruby \< 2.7; Add RuboCop [\#15](https://github.com/voxpupuli/puppet-lint-version_comparison-check/pull/15) ([bastelfreak](https://github.com/bastelfreak))
|
12
|
+
|
13
|
+
## [1.1.0](https://github.com/voxpupuli/puppet-lint-version_comparison-check/tree/1.1.0) (2022-11-29)
|
14
|
+
|
15
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-version_comparison-check/compare/1.0.0...1.1.0)
|
16
|
+
|
17
|
+
**Implemented enhancements:**
|
18
|
+
|
19
|
+
- puppet-lint: Allow 3.x [\#13](https://github.com/voxpupuli/puppet-lint-version_comparison-check/pull/13) ([bastelfreak](https://github.com/bastelfreak))
|
20
|
+
|
21
|
+
## [1.0.0](https://github.com/voxpupuli/puppet-lint-version_comparison-check/tree/1.0.0) (2021-09-17)
|
22
|
+
|
23
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-version_comparison-check/compare/0.2.1...1.0.0)
|
24
|
+
|
25
|
+
**Merged pull requests:**
|
26
|
+
|
27
|
+
- README.md: fix typo [\#8](https://github.com/voxpupuli/puppet-lint-version_comparison-check/pull/8) ([kenyon](https://github.com/kenyon))
|
28
|
+
- cleanup Gemfile/gemspec/README.md [\#7](https://github.com/voxpupuli/puppet-lint-version_comparison-check/pull/7) ([bastelfreak](https://github.com/bastelfreak))
|
29
|
+
- Convert to Github Actions [\#5](https://github.com/voxpupuli/puppet-lint-version_comparison-check/pull/5) ([ekohl](https://github.com/ekohl))
|
30
|
+
|
31
|
+
## [0.2.1](https://github.com/voxpupuli/puppet-lint-version_comparison-check/tree/0.2.1) (2016-06-22)
|
32
|
+
|
33
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-version_comparison-check/compare/0.1.2...0.2.1)
|
34
|
+
|
35
|
+
**Merged pull requests:**
|
36
|
+
|
37
|
+
- With the release of puppet-lint 2.0.0, support ~\>2.0 versions. [\#3](https://github.com/voxpupuli/puppet-lint-version_comparison-check/pull/3) ([rnelson0](https://github.com/rnelson0))
|
38
|
+
- With the release of puppet-lint 2.0.0, support ~\>2.0 versions. [\#2](https://github.com/voxpupuli/puppet-lint-version_comparison-check/pull/2) ([rnelson0](https://github.com/rnelson0))
|
39
|
+
|
40
|
+
## [0.1.2](https://github.com/voxpupuli/puppet-lint-version_comparison-check/tree/0.1.2) (2015-02-19)
|
41
|
+
|
42
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-version_comparison-check/compare/0.1.1...0.1.2)
|
43
|
+
|
44
|
+
## [0.1.1](https://github.com/voxpupuli/puppet-lint-version_comparison-check/tree/0.1.1) (2015-02-19)
|
45
|
+
|
46
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-version_comparison-check/compare/0.1.0...0.1.1)
|
47
|
+
|
48
|
+
## [0.1.0](https://github.com/voxpupuli/puppet-lint-version_comparison-check/tree/0.1.0) (2015-02-19)
|
49
|
+
|
50
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-lint-version_comparison-check/compare/87366d0663f2fe11ea14eb3c8cc5560452811970...0.1.0)
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
@@ -1,25 +1,26 @@
|
|
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
|
-
return true if [
|
6
|
-
token.next_code_token &&
|
4
|
+
return true if %i[GREATEREQUAL GREATERTHAN LESSEQUAL LESSTHAN].include?(token.type)
|
5
|
+
return true if %i[ISEQUAL NOTEQUAL].include?(token.type) &&
|
6
|
+
token.next_code_token &&
|
7
7
|
token.next_code_token.type == :NUMBER
|
8
8
|
end
|
9
9
|
|
10
10
|
def check
|
11
|
-
tokens.each_with_index do |token,
|
11
|
+
tokens.each_with_index do |token, _token_idx|
|
12
12
|
next unless token.type == :VARIABLE
|
13
|
-
next unless
|
13
|
+
next unless /(?:version|release)$/.match?(token.value)
|
14
14
|
next unless is_num_comparison?(token.next_code_token)
|
15
|
+
|
15
16
|
notify :warning, {
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
17
|
+
message: 'version compared as number',
|
18
|
+
line: token.line,
|
19
|
+
column: token.column,
|
20
|
+
token: token,
|
20
21
|
}
|
21
22
|
end
|
22
|
-
end
|
23
|
+
end
|
23
24
|
|
24
25
|
def compared_value(token)
|
25
26
|
token.next_code_token.next_code_token.value
|
@@ -32,23 +33,23 @@ PuppetLint.new_check(:version_comparison) do
|
|
32
33
|
)
|
33
34
|
lparen = PuppetLint::Lexer::Token.new(
|
34
35
|
:LPAREN, '(',
|
35
|
-
problem[:token].line, problem[:token].column+1
|
36
|
+
problem[:token].line, problem[:token].column + 1
|
36
37
|
)
|
37
38
|
rparen = PuppetLint::Lexer::Token.new(
|
38
39
|
:RPAREN, ')',
|
39
|
-
problem[:token].line, problem[:token].column+2 # not +2
|
40
|
+
problem[:token].line, problem[:token].column + 2 # not +2
|
40
41
|
)
|
41
42
|
space = PuppetLint::Lexer::Token.new(
|
42
43
|
:WHITESPACE, ' ',
|
43
|
-
problem[:token].line, problem[:token].column+3 # not +3
|
44
|
+
problem[:token].line, problem[:token].column + 3 # not +3
|
44
45
|
)
|
45
46
|
comma = PuppetLint::Lexer::Token.new(
|
46
47
|
:COMMA, ',',
|
47
|
-
problem[:token].line, problem[:token].column+4 # not +4
|
48
|
+
problem[:token].line, problem[:token].column + 4 # not +4
|
48
49
|
)
|
49
50
|
value = PuppetLint::Lexer::Token.new(
|
50
51
|
:SSTRING, compared_value(problem[:token]),
|
51
|
-
problem[:token].line, problem[:token].column+5 # not +5
|
52
|
+
problem[:token].line, problem[:token].column + 5 # not +5
|
52
53
|
)
|
53
54
|
|
54
55
|
idx = tokens.index(problem[:token])
|
@@ -57,12 +58,12 @@ PuppetLint.new_check(:version_comparison) do
|
|
57
58
|
value_token.value = 0
|
58
59
|
value_token.type = :NUMBER
|
59
60
|
# Insert ')' after value
|
60
|
-
tokens.insert(idx+1, rparen)
|
61
|
+
tokens.insert(idx + 1, rparen)
|
61
62
|
# Insert value as string after comma
|
62
|
-
tokens.insert(idx+1, value)
|
63
|
+
tokens.insert(idx + 1, value)
|
63
64
|
# Insert comma after token
|
64
|
-
tokens.insert(idx+1, space)
|
65
|
-
tokens.insert(idx+1, comma)
|
65
|
+
tokens.insert(idx + 1, space)
|
66
|
+
tokens.insert(idx + 1, comma)
|
66
67
|
# Insert 'versioncmp(' before token
|
67
68
|
tokens.insert(idx, lparen)
|
68
69
|
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 { }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vox Pupuli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|
@@ -16,96 +16,27 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '5'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '3'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
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
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '1.0'
|
61
|
-
- !ruby/object:Gem::Dependency
|
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
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - "~>"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '1.0'
|
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'
|
32
|
+
version: '5'
|
103
33
|
description: " A puppet-lint plugin to check for versions compared as numbers.\n"
|
104
34
|
email: voxpupuli@groups.io
|
105
35
|
executables: []
|
106
36
|
extensions: []
|
107
37
|
extra_rdoc_files: []
|
108
38
|
files:
|
39
|
+
- CHANGELOG.md
|
109
40
|
- LICENSE
|
110
41
|
- README.md
|
111
42
|
- lib/puppet-lint/plugins/check_version_comparison.rb
|
@@ -123,17 +54,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
54
|
requirements:
|
124
55
|
- - ">="
|
125
56
|
- !ruby/object:Gem::Version
|
126
|
-
version:
|
57
|
+
version: 2.7.0
|
127
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
59
|
requirements:
|
129
60
|
- - ">="
|
130
61
|
- !ruby/object:Gem::Version
|
131
62
|
version: '0'
|
132
63
|
requirements: []
|
133
|
-
rubygems_version: 3.2.
|
64
|
+
rubygems_version: 3.2.33
|
134
65
|
signing_key:
|
135
66
|
specification_version: 4
|
136
67
|
summary: A puppet-lint plugin to check for versions compared as numbers.
|
137
|
-
test_files:
|
138
|
-
- spec/puppet-lint/plugins/check_version_comparison/version_comparison_spec.rb
|
139
|
-
- spec/spec_helper.rb
|
68
|
+
test_files: []
|