puppet-lint-absolute_classname-check 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTE5NTQ1ZmIwYjNmOTJkMDAxNTIwNThiZTk5NzkzNmY4MGI2NWM5OA==
4
+ MWE2YWIwM2QzN2NhZjA2NWQ4MjUzYjBiMjc0NzMxZjIyZjAwYzMyOQ==
5
5
  data.tar.gz: !binary |-
6
- MDg2NWMyNWEwNmVhODdmYzlhYzVlZjgwZDgyYTVjMjc0MTJmODgyYQ==
6
+ MTI1ZjVjNWNiZDY5NGQ5YjJlNWE1Y2E5YWIxNzg1Y2JjZjI4NTBkZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjkwMzFhMmYwYWU2OGI2OWRhZGYyMDUzN2I1YjhiMzU2YzU1ZWE1YTc5ZjI1
10
- MDY5NjFjMmNkMjE4YWIwMjY2NDNmYTQ3OTc3M2I5ZmQ2NTMwNTBlMGJiOTBl
11
- ZTNlNDhiMjUzNmFkOGZiZjE3ZGE4ZDgxODE3NjgxZjU2YTNiNGQ=
9
+ OTFmNmQzM2E1NDFmYWJhY2IxNGE3MzMyZTczZWNkYTRlNDkyZWZiOTNlNTgz
10
+ MjI5MGJmNWJjMDhlMDhjYTI0YTk5ZTAzZjkxOGRkNWI0YWFiMDQ1YTZkZjQz
11
+ NzQ1MGY5NWYwYjFiYmQ2MzcyOTA2Zjk2NTRjMWNhNGNiNTg5OTE=
12
12
  data.tar.gz: !binary |-
13
- ZGJiNWRjYzFmYzBhYmE0ZTYwNTk4M2Q4MDk4ZTJiZWFkMzcyNzgzZGExNzNh
14
- M2FmNzU0ODUwYzJlOGI0ZGIyZGY0NWQyMjE1MTBkODY4MjExMDcxMjU3YjEx
15
- YTgwM2ZmMjRmMmQwNTQ4YjFjMGU0YjU5ZTI5YmNjZmUxNWVkYzQ=
13
+ ODU5NmFkZmJkNGM5YzIyMDBiMWRjOThmN2I5YTUwMjNjMWE5N2YwNjIxN2Ri
14
+ NGQ0ZWNiMzc5YzRkZmMwYjM5ZTIwYWQ0NWYzNjUyYzUxM2UwYTg2YWI0NTBh
15
+ ZWY0YzNjMGZkYWFmOWJhYmFjOGFmZmJiNjQ4NWM3MWJmOWM1MTI=
data/README.md CHANGED
@@ -40,42 +40,3 @@ Alternatively, if you’re calling puppet-lint via the Rake task, you should ins
40
40
  ```ruby
41
41
  PuppetLint.configuration.send('disable_absolute_classname')
42
42
  ```
43
-
44
-
45
- ### Unquoted string in selector
46
-
47
- Unquoted strings in selector statements are not valid with the future parser.
48
-
49
- #### What you have done
50
-
51
- ```puppet
52
- $foo = $::osfamily ? {
53
- Debian => 'bar',
54
- RedHat => 'baz',
55
- default => 'qux',
56
- }
57
- ```
58
-
59
- #### What you should have done
60
-
61
- ```puppet
62
- $foo = $::osfamily ? {
63
- 'Debian' => 'bar',
64
- 'RedHat' => 'baz',
65
- default => 'qux',
66
- }
67
- ```
68
-
69
- #### Disabling the check
70
-
71
- To disable this check, you can add `--no-absolute_classname-check` to your puppet-lint command line.
72
-
73
- ```shell
74
- $ puppet-lint --no-absolute_classname-check path/to/file.pp
75
- ```
76
-
77
- Alternatively, if you’re calling puppet-lint via the Rake task, you should insert the following line to your `Rakefile`.
78
-
79
- ```ruby
80
- PuppetLint.configuration.send('disable_absolute_classname')
81
- ```
@@ -3,14 +3,21 @@ PuppetLint.new_check(:relative_classname_inclusion) do
3
3
  tokens.each_with_index do |token, token_idx|
4
4
  if token.type == :NAME && token.value == 'include'
5
5
  s = token.next_code_token
6
- while ![:NEWLINE, :RBRACK].include? s.type
7
- if (s.type == :NAME || s.type == :SSTRING) && s.value !~ /^::/
8
- notify :warning, {
9
- :message => 'class included by relative name',
10
- :line => s.line,
11
- :column => s.column,
12
- :token => s,
13
- }
6
+ in_function = 0
7
+ while s.type != :NEWLINE
8
+ if s.type == :NAME || s.type == :SSTRING
9
+ if s.next_code_token.type == :LPAREN
10
+ in_function += 1
11
+ elsif in_function > 0 && s.next_code_token.type == :RPAREN
12
+ in_function -= 1
13
+ elsif in_function == 0 && s.value !~ /^::/
14
+ notify :warning, {
15
+ :message => 'class included by relative name',
16
+ :line => s.line,
17
+ :column => s.column,
18
+ :token => s,
19
+ }
20
+ end
14
21
  end
15
22
  s = s.next_token
16
23
  end
@@ -9,6 +9,11 @@ describe 'relative_classname_inclusion' do
9
9
  <<-EOS
10
10
  include ::foobar
11
11
  include('::foobar')
12
+ include(foobar(baz))
13
+ include(foobar('baz'))
14
+
15
+ include ::foo, ::bar
16
+ include('::foo', '::bar')
12
17
 
13
18
  class { '::foobar': }
14
19
 
@@ -57,6 +62,11 @@ describe 'relative_classname_inclusion' do
57
62
  <<-EOS
58
63
  include ::foobar
59
64
  include('::foobar')
65
+ include(foobar(baz))
66
+ include(foobar('baz'))
67
+
68
+ include ::foo, ::bar
69
+ include('::foo', '::bar')
60
70
 
61
71
  class { '::foobar': }
62
72
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-absolute_classname-check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Camptocamp