puppet-lint-param-types 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: 22d550a0adabbfadc03b01e468b5762fd77903ea7f17c37de52eb6f7111b07ca
4
- data.tar.gz: 2c0f023ab60e5c0ab41b729ea53f09178fe9842ed7b857870520a6150d166cb6
3
+ metadata.gz: f2d799a0dda58fe97999a6d22914ec0b5d37a2902ccff7e80ec4513452b1534e
4
+ data.tar.gz: a1728dc506b46d9b0e4bdcef2cdceda1e8a93640e97833ef9ea15560312448c9
5
5
  SHA512:
6
- metadata.gz: 3aba31e51221cb2121e70d28b4a39273b65a75ea95743fc89b24344f5d62305015d962b53bffca83bb887f7b6fb7e48a522ed82b7d7b0dae0e0d94f872058b2c
7
- data.tar.gz: 252fa81c7fb0aef694f430ef327f5a45222b0a3df12b0217cced4b7f3b0ac4b330b1df494d0477f825b2503e599a92e3bce1915eaeadb210778e2162c6267260
6
+ metadata.gz: 23f4277200c2c69abaaaa3869d020820bc7e5274756f2b3fbcb7aa944cd6c6d14e0b9a346008c4c6d20fe3fa73121d8148e2bb241fa8677f177e79f50a594b14
7
+ data.tar.gz: 208b3146566d922723d4488ede82413c8cb1b1fdcf9fc300a6c2ecadcbfef4e9635c222223825963bc49c78641c030a952f9e7444bea2c828095e0193464ab3e
@@ -2,6 +2,7 @@ PuppetLint.new_check(:parameter_types) do
2
2
  def check
3
3
  (class_indexes + defined_type_indexes).each do |idx|
4
4
  next if idx[:param_tokens].nil?
5
+
5
6
  # https://github.com/puppetlabs/puppet-specifications/blob/master/language/catalog_expressions.md
6
7
  # Each individual parameter in the parameter list must start with
7
8
  # either a datatype or a variable name, so testing whether the parameter is typed
@@ -10,7 +11,7 @@ PuppetLint.new_check(:parameter_types) do
10
11
  paren_stack = []
11
12
  data_stack = []
12
13
  idx[:param_tokens].each do |token|
13
- next if [ :NEWLINE, :WHITESPACE, :INDENT, :COMMENT, :MLCOMMENT, :SLASH_COMMENT].include?(token.type)
14
+ next if %i[NEWLINE WHITESPACE INDENT COMMENT MLCOMMENT SLASH_COMMENT].include?(token.type)
14
15
 
15
16
  case state
16
17
  when :ST_BEGIN
@@ -20,9 +21,9 @@ PuppetLint.new_check(:parameter_types) do
20
21
  state = :ST_SKIP_TYPE
21
22
  elsif token.type == :VARIABLE
22
23
  notify :warning, {
23
- :message => "missing datatype for parameter #{idx[:name_token].value}::#{token.value}",
24
- :line => token.line,
25
- :column => token.column
24
+ message: "missing datatype for parameter #{idx[:name_token].value}::#{token.value}",
25
+ line: token.line,
26
+ column: token.column,
26
27
  }
27
28
  state = :ST_SKIP
28
29
  end
@@ -39,13 +40,11 @@ PuppetLint.new_check(:parameter_types) do
39
40
  data_stack.pop
40
41
  elsif token.type == :COMMA && data_stack.empty? && paren_stack.empty?
41
42
  state = :ST_BEGIN
42
- end
43
+ end
43
44
  # Datatypes cannot have variables so when a variable is found it must be
44
45
  # end of the data type
45
46
  when :ST_SKIP_TYPE
46
- if token.type == :VARIABLE
47
- state = :ST_SKIP
48
- end
47
+ state = :ST_SKIP if token.type == :VARIABLE
49
48
  end
50
49
  end
51
50
  end
@@ -3,16 +3,19 @@ require 'spec_helper'
3
3
  describe 'parameter_types' do
4
4
  let(:msg) { 'missing datatype for parameter spec::%s' }
5
5
 
6
- [ 'class', 'define' ].each do | rt |
6
+ %w[class define].each do |rt|
7
7
  context "#{rt} without parameters" do
8
8
  let(:code) { 'class spec() {}' }
9
- it 'should not be a problem' do
9
+
10
+ it 'is not a problem' do
10
11
  expect(problems).to have(0).problem
11
12
  end
12
13
  end
14
+
13
15
  context "simple #{rt} without type" do
14
16
  let(:code) { 'class spec($foo) { }' }
15
- it 'should be a problem' do
17
+
18
+ it 'is a problem' do
16
19
  expect(problems).to have(1).problem
17
20
  expect(problems).to contain_warning(msg % :foo).on_line(1)
18
21
  end
@@ -20,121 +23,132 @@ describe 'parameter_types' do
20
23
 
21
24
  context "#{rt} with many params without type" do
22
25
  let(:code) do
23
- <<-EOL
24
- class spec (
25
- $attr1,
26
- $attr2,
27
- $attr3
28
- ) { }
26
+ <<~EOL
27
+ class spec (
28
+ $attr1,
29
+ $attr2,
30
+ $attr3
31
+ ) { }
29
32
  EOL
30
33
  end
31
- it 'should be a problem' do
34
+
35
+ it 'is a problem' do
32
36
  expect(problems).to have(3).problem
33
37
  end
34
38
  end
39
+
35
40
  context "#{rt} with many params without type on one line" do
36
41
  let(:code) { 'class spec ($attr1, $attr2, $attr3 ) { }' }
37
- it 'should be a problem' do
42
+
43
+ it 'is a problem' do
38
44
  expect(problems).to have(3).problem
39
45
  end
40
46
  end
47
+
41
48
  context "#{rt} with many params and defaults without type" do
42
49
  let(:code) do
43
- <<-EOL
44
- class spec (
45
- $attr0,
46
- $attr1 = 1,
47
- $attr2 = $attr1,
48
- $attr3 = [ 'array', 'with', 'entries'],
49
- $attr4 = { 'key' => 'value' }
50
- $attr5 = {
51
- 'key' => 'value',
52
- 'key2' => [
53
- 'val1',
54
- 'val2',
55
- ],
56
- },
57
- ) { }
50
+ <<~EOL
51
+ class spec (
52
+ $attr0,
53
+ $attr1 = 1,
54
+ $attr2 = $attr1,
55
+ $attr3 = [ 'array', 'with', 'entries'],
56
+ $attr4 = { 'key' => 'value' }
57
+ $attr5 = {
58
+ 'key' => 'value',
59
+ 'key2' => [
60
+ 'val1',
61
+ 'val2',
62
+ ],
63
+ },
64
+ ) { }
58
65
  EOL
59
66
  end
60
- it 'should be a problem' do
67
+
68
+ it 'is a problem' do
61
69
  expect(problems).to have(5).problem
62
70
  end
63
71
  end
64
72
 
65
73
  context "#{rt} with some attributes typed" do
66
74
  let(:code) do
67
- <<-EOL
68
- class spec (
69
- Integer $attr1,
70
- String $attr2 = 'foo',
71
- $attr3 = undef,
72
- $attr4 = { 'key' => 'value' }
73
- Array[Struct[{
74
- name => String[1],
75
- source_url => String[1],
76
- delete => Optional[Boolean],
77
- exclude => Optional[Variant[String,Array[String]]],
78
- include => Optional[Variant[String,Array[String]]],
79
- sync_hour => Optional[String],
80
- }]] $repos = [],
81
- Hash $attr5 = {
82
- 'key' => 'value',
83
- 'key2' => [
84
- 'val1',
85
- 'val2',
86
- ],
87
- },
88
- ) { }
75
+ <<~EOL
76
+ class spec (
77
+ Integer $attr1,
78
+ String $attr2 = 'foo',
79
+ $attr3 = undef,
80
+ $attr4 = { 'key' => 'value' }
81
+ Array[Struct[{
82
+ name => String[1],
83
+ source_url => String[1],
84
+ delete => Optional[Boolean],
85
+ exclude => Optional[Variant[String,Array[String]]],
86
+ include => Optional[Variant[String,Array[String]]],
87
+ sync_hour => Optional[String],
88
+ }]] $repos = [],
89
+ Hash $attr5 = {
90
+ 'key' => 'value',
91
+ 'key2' => [
92
+ 'val1',
93
+ 'val2',
94
+ ],
95
+ },
96
+ ) { }
89
97
  EOL
90
98
  end
91
- it 'should be a problem' do
99
+
100
+ it 'is a problem' do
92
101
  expect(problems).to have(2).problem
93
102
  end
94
103
  end
104
+
95
105
  context "#{rt} with some attributes typed on one line" do
96
106
  let(:code) { 'class spec(Integer $attr1, $attr2 = 5, Variant[String,Integer] $attr 3, $attr4 = [1,2]) { }' }
97
- it 'should be a problem' do
107
+
108
+ it 'is a problem' do
98
109
  expect(problems).to have(2).problem
99
110
  end
100
111
  end
101
112
 
102
113
  context "#{rt} with all attributes typed" do
103
114
  let(:code) do
104
- <<-EOL
105
- class spec (
106
- Integer $attr1,
107
- String $attr2 = 'foo',
108
- Optional[String] $attr3 = undef,
109
- Optional[Variant[Integer,Array[String] $attr4 = undef,
110
- Stdlib::MyType $attr5 = undef,
111
- ) { }
115
+ <<~EOL
116
+ class spec (
117
+ Integer $attr1,
118
+ String $attr2 = 'foo',
119
+ Optional[String] $attr3 = undef,
120
+ Optional[Variant[Integer,Array[String] $attr4 = undef,
121
+ Stdlib::MyType $attr5 = undef,
122
+ ) { }
112
123
  EOL
113
124
  end
114
- it 'should not be a problem' do
125
+
126
+ it 'is not a problem' do
115
127
  expect(problems).to have(0).problem
116
128
  end
117
129
  end
130
+
118
131
  context "#{rt} with all attributes typed complex" do
119
132
  let(:code) do
120
- <<-EOL
121
- class spec (
122
- Integer $attr1,
123
- String $attr2 = 'foo',
124
- Optional[String] $attr3 = undef,
125
- Optional[Variant[Integer,Array[String] $attr4,
126
- Array[Struct[{
127
- name => String[1],
128
- source_url => String[1],
129
- delete => Optional[Boolean],
130
- exclude => Optional[Variant[String,Array[String]]],
131
- include => Optional[Variant[String,Array[String]]],
132
- sync_hour => Optional[String],
133
- }]] $repos = [],
134
- ) { }
133
+ <<~EOL
134
+ class spec (
135
+ Integer $attr1,
136
+ String $attr2 = 'foo',
137
+ Optional[String] $attr3 = undef,
138
+ Optional[Variant[Integer,Array[String] $attr4,
139
+ Array[Struct[{
140
+ name => String[1],
141
+ source_url => String[1],
142
+ delete => Optional[Boolean],
143
+ exclude => Optional[Variant[String,Array[String]]],
144
+ include => Optional[Variant[String,Array[String]]],
145
+ sync_hour => Optional[String],
146
+ }]] $repos = [],
147
+ ) { }
135
148
  EOL
136
149
  end
137
- it 'should not be a problem' do
150
+
151
+ it 'is not a problem' do
138
152
  expect(problems).to have(0).problem
139
153
  end
140
154
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-param-types
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
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: 2023-02-24 00:00:00.000000000 Z
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,76 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.1'
19
+ version: '3'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '4'
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: '1.1'
29
+ version: '3'
30
30
  - - "<"
31
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
- 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: rake
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'
32
+ version: '5'
89
33
  description: " A new check for puppet-lint that validates that all parameters are
90
34
  typed.\n"
91
35
  email: voxpupuli@groups.io
@@ -110,7 +54,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
54
  requirements:
111
55
  - - ">="
112
56
  - !ruby/object:Gem::Version
113
- version: '0'
57
+ version: 2.7.0
114
58
  required_rubygems_version: !ruby/object:Gem::Requirement
115
59
  requirements:
116
60
  - - ">="
@@ -121,6 +65,4 @@ rubygems_version: 3.2.33
121
65
  signing_key:
122
66
  specification_version: 4
123
67
  summary: puppet-lint check that validates that all parameters are typed
124
- test_files:
125
- - spec/puppet-lint/plugins/check_parameter_types_spec.rb
126
- - spec/spec_helper.rb
68
+ test_files: []