puppet-lint-param-types 0.0.1 → 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
- SHA1:
3
- metadata.gz: 26acacc6412f383e06f34f5ccea0bbd06cb294ee
4
- data.tar.gz: 4623def5816195954c9fff6989a6e007567236be
2
+ SHA256:
3
+ metadata.gz: f2d799a0dda58fe97999a6d22914ec0b5d37a2902ccff7e80ec4513452b1534e
4
+ data.tar.gz: a1728dc506b46d9b0e4bdcef2cdceda1e8a93640e97833ef9ea15560312448c9
5
5
  SHA512:
6
- metadata.gz: 62175cae22a41add32ca935a00aaeb14017fabbe724843523559642620d9c8c361a3a60cc31b5ee773bb2bc44dd1dfa2a8a4be812f58c90357d27f72be02477c
7
- data.tar.gz: 7e789a73b47386476657605cae8e9d78da1bc5752f94b14986a4791b5f363a52cba36c2c149bf2fa5650920af8c3dfb44f735b14e0d9808d2571a0e36682ff6f
6
+ metadata.gz: 23f4277200c2c69abaaaa3869d020820bc7e5274756f2b3fbcb7aa944cd6c6d14e0b9a346008c4c6d20fe3fa73121d8148e2bb241fa8677f177e79f50a594b14
7
+ data.tar.gz: 208b3146566d922723d4488ede82413c8cb1b1fdcf9fc300a6c2ecadcbfef4e9635c222223825963bc49c78641c030a952f9e7444bea2c828095e0193464ab3e
data/README.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # puppet-lint-param-types
2
2
 
3
+ [![License](https://img.shields.io/github/license/voxpupuli/puppet-lint-param-types.svg)](https://github.com/voxpupuli/puppet-lint-param-types/blob/master/LICENSE)
4
+ [![Test](https://github.com/voxpupuli/puppet-lint-param-types/actions/workflows/test.yml/badge.svg)](https://github.com/voxpupuli/puppet-lint-param-types/actions/workflows/test.yml)
5
+ [![Release](https://github.com/voxpupuli/puppet-lint-param-types/actions/workflows/release.yml/badge.svg)](https://github.com/voxpupuli/puppet-lint-param-types/actions/workflows/release.yml)
6
+ [![RubyGem Version](https://img.shields.io/gem/v/puppet-lint-param-types.svg)](https://rubygems.org/gems/puppet-lint-param-types)
7
+ [![RubyGem Downloads](https://img.shields.io/gem/dt/puppet-lint-param-types.svg)](https://rubygems.org/gems/puppet-lint-param-types)
8
+ [![Coverage Status](https://coveralls.io/repos/github/voxpupuli/puppet-lint-param-types/badge.svg?branch=master)](https://coveralls.io/github/voxpupuli/puppet-lint-param-types?branch=master)
9
+ [![Donated by Camptocamp](https://img.shields.io/badge/donated%20by-camptocamp-fb7047.svg)](#transfer-notice)
10
+
3
11
  This plugin validates that all class and defined type parameter are typed.
4
12
 
5
13
  ## Installation
@@ -53,3 +61,25 @@ class foo (
53
61
  ## References
54
62
 
55
63
  https://puppet.com/docs/puppet/latest/lang_data_type.html
64
+
65
+ ## Transfer Notice
66
+
67
+ This plugin was originally authored by [hostnet.nl](https://www.hostnet.nl/).
68
+ The maintainer preferred that Vox Pupuli take ownership of the gem for future improvement and maintenance.
69
+ Existing pull requests and issues were transferred over, please fork and continue to contribute here instead of hostnet.
70
+
71
+ Previously: https://github.com/hostnet/puppet-lint-param-types
72
+
73
+ ## License
74
+
75
+ This gem is licensed under the MIT license.
76
+
77
+ ## Release information
78
+
79
+ To make a new release, please do:
80
+ * update the version in the gemspec file
81
+ * Install gems with `bundle config --local path .vendor && bundle install --with release`
82
+ * generate the changelog with `bundle exec rake changelog`
83
+ * Check if the new version matches the closed issues/PRs in the changelog
84
+ * Create a PR with it
85
+ * After it got merged, push a tag. GitHub actions will do the actual release to rubygems and GitHub Packages
@@ -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,3 +1,29 @@
1
+ # frozen_string_literal: true
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
+
1
27
  require 'puppet-lint'
2
28
 
3
29
  PuppetLint::Plugins.load_spec_helper
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: 0.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Hostnet
7
+ - Vox Pupuli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-05 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,79 +16,23 @@ 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: '3.0'
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: '3.0'
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'
89
- description: |2
90
- A new check for puppet-lint that validates that all parameters are typed.
91
- email: opensource@hostnet.nl
32
+ version: '5'
33
+ description: " A new check for puppet-lint that validates that all parameters are
34
+ typed.\n"
35
+ email: voxpupuli@groups.io
92
36
  executables: []
93
37
  extensions: []
94
38
  extra_rdoc_files: []
@@ -110,18 +54,15 @@ 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
  - - ">="
117
61
  - !ruby/object:Gem::Version
118
62
  version: '0'
119
63
  requirements: []
120
- rubyforge_project:
121
- rubygems_version: 2.2.5
64
+ rubygems_version: 3.2.33
122
65
  signing_key:
123
66
  specification_version: 4
124
67
  summary: puppet-lint check that validates that all parameters are typed
125
- test_files:
126
- - spec/puppet-lint/plugins/check_parameter_types_spec.rb
127
- - spec/spec_helper.rb
68
+ test_files: []