puppet-lint-unquoted_string-check 0.2.5 → 0.3.0

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
- NTdiYzg1ZjNkZjlhYTIwMTM3MDIzZGEwZTQyOWQ2MWQ5MjhhZDc1NQ==
4
+ ZmE3YTU1Mjg2ZDAxMzc2ZjllNjM5ODhlNGZmYzA5Mzc1ZjhlMjlkMw==
5
5
  data.tar.gz: !binary |-
6
- ODRkMThkZTEzMzNlZTQwZmUzYzMxMTkwYTc5YzNiZDIwMTcyY2Q1Zg==
6
+ ZDIxYjJlMDRlNGExMDE1YmM5YTI4N2I4ZTMxNTFmYjhlZWQzMDA2NQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjFmOTRiMmU3YzU0ZTc1ZjViMWYxZWM2OGMxZThjZjEwYWFkYzNhNTIzZTMx
10
- MjNhMDE4YTNkY2E1MGRhMmFkYzcwZjRlNjAyMjVmNTJhY2Y0ODhhY2E3NGVm
11
- N2RiMzk5ZThiOTQyOTg2NWQ4ODhkMTc4NDBjNGJlNDcxODg2NWE=
9
+ ZWE1NzJhYzhlNzE0MjYyZjY4NTgwZjExNmRhMzdiYTEyMTA5ZTY2NTM2NjRk
10
+ ZTZkYWE0NmY5ZTZlMGE4ZGNlZTk5ZjQ5ZDZhZDE5MTI4NjE5NzdhZGU1YTkx
11
+ NWIxMTc3NGM3MDRjY2I5N2MxZmQxNTA1ZmQ3YmE5Mjk2NTZhMjU=
12
12
  data.tar.gz: !binary |-
13
- NTcwZTU5NTI4OGQ4YjQ4YWI0YzcyOWJjOWU3MWJiYmNmOTZmZDU5ODkyNDZh
14
- NjM5Mzk3MWUwYjJiMjdmOGE1OTgzMGMyNmZkMjFmMDU5OTEyMjg4ZDU1NmRk
15
- NDdlZDMyMTlhYjAwYjgzMDc0NmFmYzQ4Yzk2MDIxOTg1YTQ3NTc=
13
+ ZDk0MWRjNGIyMjI5MTA1OGE0ZTQyZmMxZDQwNWU0NjUxNWY1Mzk4YTIyZmM2
14
+ NDliMzdlMmFjYjIxOTUzMTFlZjJjNjc0NDA1MTE1MDE1ODk1MmY0MjRhMTVj
15
+ Yjk0ZjlhMTFiYjBiZmExNTM2OGJhNzM4OTdlMGYyOGE1MDAwNWI=
data/README.md CHANGED
@@ -1,9 +1,112 @@
1
1
  puppet-lint-unquoted_string-check
2
2
  =================================
3
3
 
4
- [![Build Status](https://travis-ci.org/camptocamp/puppet-lint-unquoted_string-check.svg)](https://travis-ci.org/camptocamp/puppet-lint-unquoted_string-check)
5
- [![Code Climate](https://codeclimate.com/github/camptocamp/puppet-lint-unquoted_string-check/badges/gpa.svg)](https://codeclimate.com/github/camptocamp/puppet-lint-unquoted_string-check)
6
- [![Gem Version](https://badge.fury.io/rb/puppet-lint-unquoted_string-check.svg)](http://badge.fury.io/rb/puppet-lint-unquoted_string-check)
7
- [![Coverage Status](https://img.shields.io/coveralls/camptocamp/puppet-lint-unquoted_string-check.svg)](https://coveralls.io/r/camptocamp/puppet-lint-unquoted_string-check?branch=master)
4
+ [![Build Status](https://img.shields.io/travis/puppet-community/puppet-lint-unquoted_string-check.svg)](https://travis-ci.org/puppet-community/puppet-lint-unquoted_string-check)
5
+ [![Gem Version](https://img.shields.io/gem/v/puppet-lint-unquoted_string-check.svg)](https://rubygems.org/gems/puppet-lint-unquoted_string-check)
6
+ [![Gem Downloads](https://img.shields.io/gem/dt/puppet-lint-unquoted_string-check.svg)](https://rubygems.org/gems/puppet-lint-unquoted_string-check)
7
+ [![Coverage Status](https://img.shields.io/coveralls/puppet-community/puppet-lint-unquoted_string-check.svg)](https://coveralls.io/r/puppet-community/puppet-lint-unquoted_string-check?branch=master)
8
+ [![Gemnasium](https://img.shields.io/gemnasium/puppet-community/puppet-lint-unquoted_string-check.svg)](https://gemnasium.com/puppet-community/puppet-lint-unquoted_string-check)
9
+ [![Donated by Camptocamp](https://img.shields.io/badge/donated%20by-camptocamp-fb7047.svg)](#transfer-notice)
8
10
 
9
11
  A puppet-lint plugin to check that selectors and case statements cases are quoted.
12
+
13
+ ## Installing
14
+
15
+ ### From the command line
16
+
17
+ ```shell
18
+ $ gem install puppet-lint-unquoted_string-check
19
+ ```
20
+
21
+ ### In a Gemfile
22
+
23
+ ```ruby
24
+ gem 'puppet-lint-unquoted_string-check', :require => false
25
+ ```
26
+
27
+ ## Checks
28
+
29
+ ### Unquoted string in case
30
+
31
+ Unquoted strings in case statements are not valid with the future parser.
32
+
33
+ #### What you have done
34
+
35
+ ```puppet
36
+ case $::osfamily {
37
+ Debian: { }
38
+ RedHat: { }
39
+ default: { }
40
+ }
41
+ ```
42
+
43
+ #### What you should have done
44
+
45
+ ```puppet
46
+ case $::osfamily {
47
+ 'Debian': { }
48
+ 'RedHat': { }
49
+ default: { }
50
+ }
51
+ ```
52
+
53
+ #### Disabling the check
54
+
55
+ To disable this check, you can add `--no-unquoted_string_in_case-check` to your puppet-lint command line.
56
+
57
+ ```shell
58
+ $ puppet-lint --no-unquoted_string_in_case-check path/to/file.pp
59
+ ```
60
+
61
+ Alternatively, if you’re calling puppet-lint via the Rake task, you should insert the following line to your `Rakefile`.
62
+
63
+ ```ruby
64
+ PuppetLint.configuration.send('disable_unquoted_string_in_case')
65
+ ```
66
+
67
+
68
+ ### Unquoted string in selector
69
+
70
+ Unquoted strings in selector statements are not valid with the future parser.
71
+
72
+ #### What you have done
73
+
74
+ ```puppet
75
+ $foo = $::osfamily ? {
76
+ Debian => 'bar',
77
+ RedHat => 'baz',
78
+ default => 'qux',
79
+ }
80
+ ```
81
+
82
+ #### What you should have done
83
+
84
+ ```puppet
85
+ $foo = $::osfamily ? {
86
+ 'Debian' => 'bar',
87
+ 'RedHat' => 'baz',
88
+ default => 'qux',
89
+ }
90
+ ```
91
+
92
+ #### Disabling the check
93
+
94
+ To disable this check, you can add `--no-unquoted_string_in_selector-check` to your puppet-lint command line.
95
+
96
+ ```shell
97
+ $ puppet-lint --no-unquoted_string_in_selector-check path/to/file.pp
98
+ ```
99
+
100
+ Alternatively, if you’re calling puppet-lint via the Rake task, you should insert the following line to your `Rakefile`.
101
+
102
+ ```ruby
103
+ PuppetLint.configuration.send('disable_unquoted_string_in_selector')
104
+ ```
105
+
106
+ ## Transfer Notice
107
+
108
+ This plugin was originally authored by [Camptocamp](http://www.camptocamp.com).
109
+ The maintainer preferred that Puppet Community take ownership of the module for future improvement and maintenance.
110
+ Existing pull requests and issues were transferred over, please fork and continue to contribute here instead of Camptocamp.
111
+
112
+ Previously: https://github.com/camptocamp/puppet-lint-unquoted_string-check
@@ -22,6 +22,10 @@ def type_indexes(type)
22
22
  type_indexes
23
23
  end
24
24
 
25
+ def is_puppet_type(token)
26
+ token.type == :CLASSREF and [ 'Undef', 'Default', 'Integer', 'Float', 'Boolean', 'Regexp', 'String', 'Array', 'Hash', 'Resource', 'Class', 'Collection', 'Scalar', 'Numeric', 'CatalogEntry', 'Data', 'Tuple', 'Struct', 'Optional', 'NotUndef', 'Variant', 'Enum', 'Pattern', 'Any', 'Callable', 'Type', 'Runtime', ].include? token.value
27
+ end
28
+
25
29
  def notify_tokens(type, sep_type, message)
26
30
  type_indexes(type).each do |kase|
27
31
  type_tokens = tokens[kase[:start]..kase[:end]]
@@ -35,7 +39,7 @@ def notify_tokens(type, sep_type, message)
35
39
  :line => s.line,
36
40
  :column => s.column,
37
41
  :token => s,
38
- }
42
+ } unless is_puppet_type(s)
39
43
  end
40
44
  s = s.prev_token
41
45
  end
@@ -141,6 +141,23 @@ describe 'unquoted_string_in_case' do
141
141
  expect(problems).to contain_warning(msg).on_line(2).in_column(11)
142
142
  end
143
143
  end
144
+
145
+ context 'Puppet Types in case' do
146
+ let(:code) do
147
+ <<-EOS
148
+ case $value {
149
+ Integer: { notice('yes int')}
150
+ Array: { notice('yes array')}
151
+ 'Debian': { notice('this is Sparta')}
152
+ default: { notice('something else')}
153
+ }
154
+ EOS
155
+ end
156
+
157
+ it 'should not detect any problems' do
158
+ expect(problems).to have(0).problems
159
+ end
160
+ end
144
161
  end
145
162
 
146
163
  context 'with fix enabled' do
@@ -353,5 +370,26 @@ describe 'unquoted_string_in_case' do
353
370
  )
354
371
  end
355
372
  end
373
+
374
+ context 'Puppet Types in case' do
375
+ let(:code) do
376
+ <<-EOS
377
+ case $value {
378
+ Integer: { notice('yes int')}
379
+ Array: { notice('yes array')}
380
+ 'Debian': { notice('this is Sparta')}
381
+ default: { notice('something else')}
382
+ }
383
+ EOS
384
+ end
385
+
386
+ it 'should not detect any problems' do
387
+ expect(problems).to have(0).problems
388
+ end
389
+
390
+ it 'should not modify the manifest' do
391
+ expect(manifest).to eq(code)
392
+ end
393
+ end
356
394
  end
357
395
  end
@@ -1,5 +1,7 @@
1
- require 'coveralls'
2
- Coveralls.wear!
1
+ unless RUBY_VERSION =~ /^1\.8/
2
+ require 'coveralls'
3
+ Coveralls.wear!
4
+ end
3
5
 
4
6
  require 'puppet-lint'
5
7
 
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-unquoted_string-check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
- - Camptocamp
7
+ - Puppet Community
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-08 00:00:00.000000000 Z
11
+ date: 2016-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet-lint
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: '3.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - ~>
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: '1.0'
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: '3.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rspec
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +72,20 @@ dependencies:
66
72
  - - ~>
67
73
  - !ruby/object:Gem::Version
68
74
  version: '1.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: mime-types
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ~>
80
+ - !ruby/object:Gem::Version
81
+ version: '1.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ~>
87
+ - !ruby/object:Gem::Version
88
+ version: '1.0'
69
89
  - !ruby/object:Gem::Dependency
70
90
  name: coveralls
71
91
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +129,7 @@ files:
109
129
  - spec/puppet-lint/plugins/check_unquoted_string_in_case/check_unquoted_string_in_case_spec.rb
110
130
  - spec/puppet-lint/plugins/check_unquoted_string_in_case/check_unquoted_string_in_selector_spec.rb
111
131
  - spec/spec_helper.rb
112
- homepage: https://github.com/camptocamp/puppet-lint-unquoted_string-check
132
+ homepage: https://github.com/puppet-community/puppet-lint-unquoted_string-check
113
133
  licenses:
114
134
  - Apache-2.0
115
135
  metadata: {}