puppet-lint-param-types 1.0.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: 22d550a0adabbfadc03b01e468b5762fd77903ea7f17c37de52eb6f7111b07ca
4
- data.tar.gz: 2c0f023ab60e5c0ab41b729ea53f09178fe9842ed7b857870520a6150d166cb6
3
+ metadata.gz: bab0542e14de18004a0eef09d9336e3c342743c539f3c9d0a7a6145992aa6366
4
+ data.tar.gz: 8857ccefc81330497e2dff272322edc84f9631bc49b53c16bb1fc08b1b422dcb
5
5
  SHA512:
6
- metadata.gz: 3aba31e51221cb2121e70d28b4a39273b65a75ea95743fc89b24344f5d62305015d962b53bffca83bb887f7b6fb7e48a522ed82b7d7b0dae0e0d94f872058b2c
7
- data.tar.gz: 252fa81c7fb0aef694f430ef327f5a45222b0a3df12b0217cced4b7f3b0ac4b330b1df494d0477f825b2503e599a92e3bce1915eaeadb210778e2162c6267260
6
+ metadata.gz: 43c493fec315b50182d02be4085772abf25043e43fdd056bb0b4cb426b2eeed64560407a5c5855e0b01bcbe4d85d4b391a6f7f4ebe1b082348ef6809716667ca
7
+ data.tar.gz: d5b6b3cbc109fb6b9a6a4648ed202883bba289d10e67b7be5c9bc7d901d8f79c389c471786fa7ac3e54dfc1b3ecacce3fa14d772cba6631b6490642945cce0d6
@@ -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
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,91 +1,28 @@
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: 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: 2023-02-24 00:00:00.000000000 Z
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
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '1.1'
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.1'
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '4'
33
- - !ruby/object:Gem::Dependency
34
- name: rspec
35
14
  requirement: !ruby/object:Gem::Requirement
36
15
  requirements:
37
16
  - - "~>"
38
17
  - !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
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.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'
25
+ version: '5.1'
89
26
  description: " A new check for puppet-lint that validates that all parameters are
90
27
  typed.\n"
91
28
  email: voxpupuli@groups.io
@@ -98,11 +35,10 @@ files:
98
35
  - lib/puppet-lint/plugins/check_parameter_types.rb
99
36
  - spec/puppet-lint/plugins/check_parameter_types_spec.rb
100
37
  - spec/spec_helper.rb
101
- homepage: https://github.com/hostnet/puppet-lint-param-types
38
+ homepage: https://github.com/voxpupuli/puppet-lint-param-types
102
39
  licenses:
103
40
  - MIT
104
41
  metadata: {}
105
- post_install_message:
106
42
  rdoc_options: []
107
43
  require_paths:
108
44
  - lib
@@ -110,17 +46,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
46
  requirements:
111
47
  - - ">="
112
48
  - !ruby/object:Gem::Version
113
- version: '0'
49
+ version: '3.2'
114
50
  required_rubygems_version: !ruby/object:Gem::Requirement
115
51
  requirements:
116
52
  - - ">="
117
53
  - !ruby/object:Gem::Version
118
54
  version: '0'
119
55
  requirements: []
120
- rubygems_version: 3.2.33
121
- signing_key:
56
+ rubygems_version: 3.6.9
122
57
  specification_version: 4
123
58
  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
59
+ test_files: []