puppet-lint 2.2.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +40 -19
  3. data/README.md +181 -174
  4. data/Rakefile +1 -1
  5. data/lib/puppet-lint/bin.rb +6 -0
  6. data/lib/puppet-lint/lexer.rb +1 -1
  7. data/lib/puppet-lint/plugins.rb +16 -10
  8. data/lib/puppet-lint/plugins/check_classes/arrow_on_right_operand_line.rb +46 -0
  9. data/lib/puppet-lint/plugins/check_classes/autoloader_layout.rb +33 -0
  10. data/lib/puppet-lint/plugins/check_classes/class_inherits_from_params_class.rb +20 -0
  11. data/lib/puppet-lint/plugins/check_classes/code_on_top_scope.rb +20 -0
  12. data/lib/puppet-lint/plugins/check_classes/inherits_across_namespaces.rb +22 -0
  13. data/lib/puppet-lint/plugins/check_classes/names_containing_dash.rb +23 -0
  14. data/lib/puppet-lint/plugins/check_classes/names_containing_uppercase.rb +28 -0
  15. data/lib/puppet-lint/plugins/check_classes/nested_classes_or_defines.rb +28 -0
  16. data/lib/puppet-lint/plugins/check_classes/parameter_order.rb +44 -0
  17. data/lib/puppet-lint/plugins/check_classes/right_to_left_relationship.rb +15 -0
  18. data/lib/puppet-lint/plugins/check_classes/variable_scope.rb +143 -0
  19. data/lib/puppet-lint/plugins/check_comments/slash_comments.rb +22 -0
  20. data/lib/puppet-lint/plugins/{check_comments.rb → check_comments/star_comments.rb} +1 -24
  21. data/lib/puppet-lint/plugins/{check_conditionals.rb → check_conditionals/case_without_default.rb} +1 -27
  22. data/lib/puppet-lint/plugins/check_conditionals/selector_inside_resource.rb +25 -0
  23. data/lib/puppet-lint/plugins/{check_documentation.rb → check_documentation/documentation.rb} +0 -0
  24. data/lib/puppet-lint/plugins/{check_nodes.rb → check_nodes/unquoted_node_name.rb} +0 -0
  25. data/lib/puppet-lint/plugins/check_resources/duplicate_params.rb +37 -0
  26. data/lib/puppet-lint/plugins/check_resources/ensure_first_param.rb +70 -0
  27. data/lib/puppet-lint/plugins/check_resources/ensure_not_symlink_target.rb +44 -0
  28. data/lib/puppet-lint/plugins/check_resources/file_mode.rb +42 -0
  29. data/lib/puppet-lint/plugins/check_resources/unquoted_file_mode.rb +31 -0
  30. data/lib/puppet-lint/plugins/check_resources/unquoted_resource_title.rb +22 -0
  31. data/lib/puppet-lint/plugins/check_strings/double_quoted_strings.rb +27 -0
  32. data/lib/puppet-lint/plugins/check_strings/only_variable_string.rb +63 -0
  33. data/lib/puppet-lint/plugins/check_strings/puppet_url_without_modules.rb +25 -0
  34. data/lib/puppet-lint/plugins/check_strings/quoted_booleans.rb +26 -0
  35. data/lib/puppet-lint/plugins/check_strings/single_quote_string_with_variables.rb +17 -0
  36. data/lib/puppet-lint/plugins/check_strings/variables_not_enclosed.rb +23 -0
  37. data/lib/puppet-lint/plugins/check_variables/variable_contains_dash.rb +21 -0
  38. data/lib/puppet-lint/plugins/{check_variables.rb → check_variables/variable_is_lowercase.rb} +0 -22
  39. data/lib/puppet-lint/plugins/check_whitespace/140chars.rb +21 -0
  40. data/lib/puppet-lint/plugins/check_whitespace/2sp_soft_tabs.rb +19 -0
  41. data/lib/puppet-lint/plugins/check_whitespace/80chars.rb +21 -0
  42. data/lib/puppet-lint/plugins/{check_whitespace.rb → check_whitespace/arrow_alignment.rb} +0 -118
  43. data/lib/puppet-lint/plugins/check_whitespace/hard_tabs.rb +24 -0
  44. data/lib/puppet-lint/plugins/check_whitespace/trailing_whitespace.rb +28 -0
  45. data/lib/puppet-lint/tasks/puppet-lint.rb +4 -0
  46. data/lib/puppet-lint/version.rb +1 -1
  47. data/spec/puppet-lint/bin_spec.rb +18 -1
  48. data/spec/puppet-lint/lexer_spec.rb +19 -0
  49. metadata +41 -68
  50. data/lib/puppet-lint/plugins/check_classes.rb +0 -433
  51. data/lib/puppet-lint/plugins/check_resources.rb +0 -251
  52. data/lib/puppet-lint/plugins/check_strings.rb +0 -186
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d38c3e980312a05a89ce9927adb0f804a9bb2b3a
4
- data.tar.gz: 9ed350e5a31848d582093b528b516c8834250bd8
3
+ metadata.gz: 5cf7e44161d54a800d685bcfd4cf152f5d8513c9
4
+ data.tar.gz: dedf83a5d6c65efd93413867bce94c198b622b0c
5
5
  SHA512:
6
- metadata.gz: 29ed416ab704c80e28e01fff7c024fb92406a5dc091f2ebbd4e247b214b49560aca37e71e03730adfd71846f08c8396122fc4e30d043881e20434a920b43d6ac
7
- data.tar.gz: dbf341808a24b94dbaa7e1b01145832b5995f7c197fa651300aac7e38bdb5f688c6f1b57271b9496648bf9604788a278cb522e3679d3e4e4a669b0bfafb85123
6
+ metadata.gz: 40ae10c6e1b29822cbc3146c9a1fb4dcbfcabacc3d934710d9b7ca654bfdbd3ba45a44186f03b32ff77ba1dbeb147f58131a7fc197e08cccac60f4ec9fa13153
7
+ data.tar.gz: fb7c37f37510e8d6f6fb100e797e2d002cc539ad08c5bbaddda33c301d077ba09761d71d967692ad95f5de6b8b8e7f9a66d03f1ac12370d9e0b89fb41932effb
data/CHANGELOG.md CHANGED
@@ -1,10 +1,34 @@
1
1
  # Change Log
2
2
 
3
+ ## [2.3.0](https://github.com/rodjek/puppet-lint/tree/2.3.0) (2017-07-12)
4
+ [Full Changelog](https://github.com/rodjek/puppet-lint/compare/2.2.1...2.3.0)
5
+
6
+ **Closed issues:**
7
+
8
+ - Inappropriate =\> Indentation Warning in Hash [\#698](https://github.com/rodjek/puppet-lint/issues/698)
9
+ - Regression: arrow\_alignment check broken between 2.1.1 and 2.2.x releases when left side contains text after variable interpolation [\#697](https://github.com/rodjek/puppet-lint/issues/697)
10
+ - Check `arrow\_on\_right\_operand\_line` is undocumented. [\#688](https://github.com/rodjek/puppet-lint/issues/688)
11
+
12
+ **Merged pull requests:**
13
+
14
+ - \(maint\) Fixes puppet-lint json formatting to output valid json to stdout [\#719](https://github.com/rodjek/puppet-lint/pull/719) ([bmjen](https://github.com/bmjen))
15
+ - Permit puppet-lint to load "prerelease" gems [\#718](https://github.com/rodjek/puppet-lint/pull/718) ([kpaulisse](https://github.com/kpaulisse))
16
+ - Document the configuration file better [\#713](https://github.com/rodjek/puppet-lint/pull/713) ([binford2k](https://github.com/binford2k))
17
+ - Replace deprecated plugin with an improved alternative. [\#712](https://github.com/rodjek/puppet-lint/pull/712) ([deanwilson](https://github.com/deanwilson))
18
+ - Readme formatting fixes [\#709](https://github.com/rodjek/puppet-lint/pull/709) ([dbeckham](https://github.com/dbeckham))
19
+ - Readme edit [\#707](https://github.com/rodjek/puppet-lint/pull/707) ([jbondpdx](https://github.com/jbondpdx))
20
+ - Take into account length of DQPOST token when updating column number [\#701](https://github.com/rodjek/puppet-lint/pull/701) ([dbeckham](https://github.com/dbeckham))
21
+ - Add pattern support to rake task [\#700](https://github.com/rodjek/puppet-lint/pull/700) ([dbeckham](https://github.com/dbeckham))
22
+ - Note arrow\_on\_right\_operand\_line in the README [\#690](https://github.com/rodjek/puppet-lint/pull/690) ([rodjek](https://github.com/rodjek))
23
+ - Document the arrow\_on\_right\_operand\_line check on the website [\#689](https://github.com/rodjek/puppet-lint/pull/689) ([rodjek](https://github.com/rodjek))
24
+ - One file per plugin. Fixes \#657 [\#671](https://github.com/rodjek/puppet-lint/pull/671) ([Darhazer](https://github.com/Darhazer))
25
+
3
26
  ## [2.2.1](https://github.com/rodjek/puppet-lint/tree/2.2.1) (2017-03-29)
4
27
  [Full Changelog](https://github.com/rodjek/puppet-lint/compare/2.2.0...2.2.1)
5
28
 
6
29
  **Closed issues:**
7
30
 
31
+ - Error on whitespace with 2.2.0 [\#683](https://github.com/rodjek/puppet-lint/issues/683)
8
32
  - "undefined method `map' for nil:NilClass" when running check\_whitespace [\#681](https://github.com/rodjek/puppet-lint/issues/681)
9
33
  - "undefined method `next\_token='" when fixing with check\_whitespace [\#680](https://github.com/rodjek/puppet-lint/issues/680)
10
34
  - Release 2.2.0 planning and discussion [\#668](https://github.com/rodjek/puppet-lint/issues/668)
@@ -19,43 +43,46 @@
19
43
 
20
44
  **Closed issues:**
21
45
 
46
+ - Plugins reorganization: One file per check [\#657](https://github.com/rodjek/puppet-lint/issues/657)
47
+ - 2.1.1 git tag [\#652](https://github.com/rodjek/puppet-lint/issues/652)
48
+ - Quoted boolean triggers on the command 'true' [\#646](https://github.com/rodjek/puppet-lint/issues/646)
49
+ - Namevars detected as optional parameters [\#633](https://github.com/rodjek/puppet-lint/issues/633)
50
+ - 'Duplicate Parameter' warning on dynamic class parameter [\#627](https://github.com/rodjek/puppet-lint/issues/627)
51
+ - arrow\_alignment should only check the alignment of the first arrow on each line [\#609](https://github.com/rodjek/puppet-lint/issues/609)
52
+ - Top-scope variable warning on inline lambda [\#549](https://github.com/rodjek/puppet-lint/issues/549)
53
+ - Puppet-lint crash with new puppet 4 syntax [\#516](https://github.com/rodjek/puppet-lint/issues/516)
54
+ - Top-scope warning when looping though an array of hashes [\#464](https://github.com/rodjek/puppet-lint/issues/464)
55
+ - Array of hashes one-liner throws a "Indentation of =\> is not properly aligned" [\#446](https://github.com/rodjek/puppet-lint/issues/446)
22
56
  - Missed bad file modes in file with multiple resource bodies [\#663](https://github.com/rodjek/puppet-lint/issues/663)
23
57
  - Provide helper methods to search for specific tokens [\#660](https://github.com/rodjek/puppet-lint/issues/660)
24
58
  - ensure\_first\_param fix can create invalid syntax [\#659](https://github.com/rodjek/puppet-lint/issues/659)
25
59
  - puppet-lint dies with inline\_template syntax [\#656](https://github.com/rodjek/puppet-lint/issues/656)
26
60
  - Variable use like "${$a}" isn't reported as an error and is changed with no message when run with --fix [\#655](https://github.com/rodjek/puppet-lint/issues/655)
27
61
  - Linter gets confused with arrays of hashes [\#654](https://github.com/rodjek/puppet-lint/issues/654)
28
- - 2.1.1 git tag [\#652](https://github.com/rodjek/puppet-lint/issues/652)
29
62
  - heredoc throws unhandled exception [\#649](https://github.com/rodjek/puppet-lint/issues/649)
30
- - Quoted boolean triggers on the command 'true' [\#646](https://github.com/rodjek/puppet-lint/issues/646)
31
63
  - Match function breaks puppet-lint [\#645](https://github.com/rodjek/puppet-lint/issues/645)
32
64
  - top-scope variable being used without an explicit namespace in a string with a lookup [\#635](https://github.com/rodjek/puppet-lint/issues/635)
33
65
  - unquoted file mode & mode should be represented as a 4 digit when file mode is done by a lookup [\#634](https://github.com/rodjek/puppet-lint/issues/634)
34
- - Namevars detected as optional parameters [\#633](https://github.com/rodjek/puppet-lint/issues/633)
35
- - 'Duplicate Parameter' warning on dynamic class parameter [\#627](https://github.com/rodjek/puppet-lint/issues/627)
36
66
  - double\_quoted\_strings-check issue with escaped character in the string [\#625](https://github.com/rodjek/puppet-lint/issues/625)
37
67
  - unable to disable 140chars check with control comments "block" [\#622](https://github.com/rodjek/puppet-lint/issues/622)
38
- - arrow\_alignment should only check the alignment of the first arrow on each line [\#609](https://github.com/rodjek/puppet-lint/issues/609)
39
68
  - unquoted\_node\_name crash when curly braces missing [\#582](https://github.com/rodjek/puppet-lint/issues/582)
40
69
  - Heredoc triggers exception in arrow\_alignment check [\#578](https://github.com/rodjek/puppet-lint/issues/578)
41
70
  - Each + With = Fake positive top-scope variable detection [\#576](https://github.com/rodjek/puppet-lint/issues/576)
42
- - Top-scope variable warning on inline lambda [\#549](https://github.com/rodjek/puppet-lint/issues/549)
43
71
  - Top-scope variable warning on nested each loops [\#548](https://github.com/rodjek/puppet-lint/issues/548)
44
- - Puppet-lint crash with new puppet 4 syntax [\#516](https://github.com/rodjek/puppet-lint/issues/516)
45
72
  - `arrow\_alignment --fix` doesn't indent keys when introducing line breaks; erroneously reports success [\#506](https://github.com/rodjek/puppet-lint/issues/506)
46
- - Top-scope warning when looping though an array of hashes [\#464](https://github.com/rodjek/puppet-lint/issues/464)
47
- - Array of hashes one-liner throws a "Indentation of =\> is not properly aligned" [\#446](https://github.com/rodjek/puppet-lint/issues/446)
48
73
  - heredoc escape gives syntax error [\#430](https://github.com/rodjek/puppet-lint/issues/430)
49
74
  - NoMethodError when multiple heredocs are used [\#395](https://github.com/rodjek/puppet-lint/issues/395)
50
75
 
51
76
  **Merged pull requests:**
52
77
 
78
+ - Support double quoted strings inside interpolated values in double quoted strings [\#676](https://github.com/rodjek/puppet-lint/pull/676) ([rodjek](https://github.com/rodjek))
79
+ - Check that arrow is on the line of right operand [\#672](https://github.com/rodjek/puppet-lint/pull/672) ([Darhazer](https://github.com/Darhazer))
80
+ - Deal with ruby 1.8.7 gem issues [\#630](https://github.com/rodjek/puppet-lint/pull/630) ([mterzo](https://github.com/mterzo))
81
+ - Plugin review; disable unnecessary plugins [\#567](https://github.com/rodjek/puppet-lint/pull/567) ([rnelson0](https://github.com/rnelson0))
53
82
  - Ignore selectors when finding resource type [\#678](https://github.com/rodjek/puppet-lint/pull/678) ([rodjek](https://github.com/rodjek))
54
83
  - Fix for arrow\_alignment bugs in \#506 [\#677](https://github.com/rodjek/puppet-lint/pull/677) ([rodjek](https://github.com/rodjek))
55
- - Support double quoted strings inside interpolated values in double quoted strings [\#676](https://github.com/rodjek/puppet-lint/pull/676) ([rodjek](https://github.com/rodjek))
56
84
  - Don't silently remove unnecessary $ from enclosed variables [\#674](https://github.com/rodjek/puppet-lint/pull/674) ([rodjek](https://github.com/rodjek))
57
85
  - Fix ensure\_first\_param fix method to retrieve the full value of the ensure parameter [\#673](https://github.com/rodjek/puppet-lint/pull/673) ([rodjek](https://github.com/rodjek))
58
- - Check that arrow is on the line of right operand [\#672](https://github.com/rodjek/puppet-lint/pull/672) ([Darhazer](https://github.com/Darhazer))
59
86
  - Restrict appveyor testing to Ruby versions that appveyor supports [\#670](https://github.com/rodjek/puppet-lint/pull/670) ([james-stocks](https://github.com/james-stocks))
60
87
  - Clear expected parameter column after processing each block when checking arrow alignment [\#669](https://github.com/rodjek/puppet-lint/pull/669) ([rodjek](https://github.com/rodjek))
61
88
  - Allow regexps to used as function arguments [\#665](https://github.com/rodjek/puppet-lint/pull/665) ([rodjek](https://github.com/rodjek))
@@ -71,10 +98,8 @@
71
98
  - Correctly handle nested lambdas [\#637](https://github.com/rodjek/puppet-lint/pull/637) ([hanazuki](https://github.com/hanazuki))
72
99
  - Support for nested multiple-variable assignments [\#636](https://github.com/rodjek/puppet-lint/pull/636) ([hanazuki](https://github.com/hanazuki))
73
100
  - Add LoadError to fix broken tests [\#631](https://github.com/rodjek/puppet-lint/pull/631) ([davidmogar](https://github.com/davidmogar))
74
- - Deal with ruby 1.8.7 gem issues [\#630](https://github.com/rodjek/puppet-lint/pull/630) ([mterzo](https://github.com/mterzo))
75
- - Plugin review; disable unnecessary plugins [\#567](https://github.com/rodjek/puppet-lint/pull/567) ([rnelson0](https://github.com/rnelson0))
76
101
 
77
- ## [2.1.1](https://github.com/rodjek/puppet-lint/tree/2.1.1) (2017-02-13)
102
+ ## [2.1.1](https://github.com/rodjek/puppet-lint/tree/2.1.1) (2017-02-15)
78
103
  [Full Changelog](https://github.com/rodjek/puppet-lint/compare/2.1.0...2.1.1)
79
104
 
80
105
  **Closed issues:**
@@ -123,8 +148,6 @@
123
148
 
124
149
  **Merged pull requests:**
125
150
 
126
- - 2.1.0 Release [\#612](https://github.com/rodjek/puppet-lint/pull/612) ([rnelson0](https://github.com/rnelson0))
127
- - Puppet-lint version bump to 2.1.0.pre [\#608](https://github.com/rodjek/puppet-lint/pull/608) ([rnelson0](https://github.com/rnelson0))
128
151
  - Ignore \*.pp files at the top level [\#597](https://github.com/rodjek/puppet-lint/pull/597) ([rnelson0](https://github.com/rnelson0))
129
152
  - Show logs in rspec tests [\#596](https://github.com/rodjek/puppet-lint/pull/596) ([ghoneycutt](https://github.com/ghoneycutt))
130
153
  - Count lines in comments and double quoted strings [\#577](https://github.com/rodjek/puppet-lint/pull/577) ([paran1](https://github.com/paran1))
@@ -163,7 +186,6 @@
163
186
 
164
187
  **Merged pull requests:**
165
188
 
166
- - Release 2.0.2 [\#536](https://github.com/rodjek/puppet-lint/pull/536) ([rnelson0](https://github.com/rnelson0))
167
189
  - Revert "Bugfix: properly handling $gronk-$grouik with --fix \(fix \#442\)" [\#535](https://github.com/rodjek/puppet-lint/pull/535) ([rnelson0](https://github.com/rnelson0))
168
190
 
169
191
  ## [2.0.1](https://github.com/rodjek/puppet-lint/tree/2.0.1) (2016-08-18)
@@ -223,7 +245,6 @@
223
245
  **Merged pull requests:**
224
246
 
225
247
  - Continue supporting Ruby \< 2 [\#529](https://github.com/rodjek/puppet-lint/pull/529) ([ghoneycutt](https://github.com/ghoneycutt))
226
- - Release 2.0.1 [\#528](https://github.com/rodjek/puppet-lint/pull/528) ([rnelson0](https://github.com/rnelson0))
227
248
  - Use underscores instead of CamelCase in example [\#527](https://github.com/rodjek/puppet-lint/pull/527) ([ghoneycutt](https://github.com/ghoneycutt))
228
249
  - new linter for top\_scope\_facts [\#526](https://github.com/rodjek/puppet-lint/pull/526) ([mmckinst](https://github.com/mmckinst))
229
250
  - \(GH462\) Multi-line comments can now be fixed. [\#525](https://github.com/rodjek/puppet-lint/pull/525) ([rnelson0](https://github.com/rnelson0))
@@ -822,4 +843,4 @@ If the additional gems you use for checks are pinned to 1.x, you should pin pupp
822
843
  ## [0.0.1](https://github.com/rodjek/puppet-lint/tree/0.0.1) (2011-08-15)
823
844
 
824
845
 
825
- \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
846
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
data/README.md CHANGED
@@ -1,242 +1,262 @@
1
- # Puppet-lint
1
+ # Puppet Lint
2
2
 
3
3
  [![Build
4
4
  Status](https://secure.travis-ci.org/rodjek/puppet-lint.png)](http://travis-ci.org/rodjek/puppet-lint)
5
5
  [![Inline docs](http://inch-ci.org/github/rodjek/puppet-lint.png?branch=master)](http://inch-ci.org/github/rodjek/puppet-lint)
6
6
 
7
- Puppet Lint will test modules and manifests against the recommended Puppet
8
- style guidelines from the [Puppet Labs style
9
- guide](http://docs.puppetlabs.com/guides/style_guide.html) as closely as practical. It is not meant to validate syntax. Please use `puppet parser validate` for that.
7
+ Puppet Lint tests Puppet code against the recommended [Puppet language style
8
+ guide](http://docs.puppet.com/puppet/latest/style_guide.html). Puppet Lint validates only code style; it does not validate syntax. To test syntax, use Puppet's `puppet parser validate` command.
9
+
10
+ ## Compatibility warning
11
+
12
+ Puppet Lint version 2 is the last planned version with support for Puppet 3 and Ruby 1.8.7. The next major version of Puppet Lint will drop support for these versions.
10
13
 
11
14
  ## Installation
12
15
 
13
- gem install puppet-lint
16
+ Install the Puppet Lint gem by running:
14
17
 
15
- ## Usage
18
+ ```
19
+ gem install puppet-lint
20
+ ```
16
21
 
17
- ### By hand
22
+ ## Testing with Puppet Lint
18
23
 
19
- You can test a single manifest file by running
24
+ To test manifests for correct Puppet style, run the `puppet-lint` command with the path to the files you want to test.
20
25
 
21
- puppet-lint <path to file>
26
+ For example:
22
27
 
23
- Puppet Lint has a large number of options to modify which checks should be run.
28
+ ```
29
+ puppet-lint ~/modules/puppetlabs-java/manifests/init.pp
30
+ ```
24
31
 
25
- You can disable any of the checks when running the `puppet-lint` command by
26
- adding a `--no-<check name>-check` flag to the command. For example, if you
27
- wanted to skip the 140 character check, you would run
28
- ```
29
- puppet-lint --no-140chars-check <path to file>
30
32
  ```
33
+ puppet-lint ~/modules/puppetlabs-mysql/manifests
34
+ ```
35
+
36
+ ### Fix issues automatically
37
+
38
+ To instruct Lint to automatically fix any issues that it detects, use the `--fix` flag:
31
39
 
32
- You can also instruct puppet-lint to automatically fix issues it detects with the `--fix` flag.
33
40
  ```
34
- puppet-lint --fix /modules
41
+ puppet-lint --fix /modules
35
42
  ```
36
43
 
37
- Note that this can be combined with the `--only-checks` option to help avoid enormous patch sets.
44
+ ### Modify which checks to run
45
+
46
+ Puppet Lint options allow you to modify which checks to run. You can disable any of the checks temporarily or permanently, or you can limit testing to specific checks.
47
+
48
+ #### Run specific checks
49
+
50
+ To run only specific checks, use the `--only-checks` option, with a comma-separated list of arguments specifying which checks to make:
51
+
38
52
  ```
39
- puppet-lint --only-checks trailing_whitespace --fix modules/
53
+ puppet-lint --only-checks trailing_whitespace,140chars modules/
40
54
  ```
41
55
 
42
- You can also use [control comments](http://puppet-lint.com/controlcomments/) to disable checks
43
- within puppet code on a per line or per block basis using `#lint:ignore:<check_name>`:
56
+ To avoid enormous patch sets when using the `--fix` flag, use the `--only-checks` option to limit which checks Puppet Lint makes:
57
+
44
58
  ```
45
- class foo {
46
- $bar = 'bar'
47
- # This ignores the double_quoted_strings check over multiple lines
48
- # lint:ignore:double_quoted_strings
49
- $baz = "baz"
50
- $gronk = "gronk"
51
- # lint:endignore
52
-
53
- # This ignores the 140chars check on a single line
54
- $this_line_has_a_really_long_name_and_value_that_is_much_longer_than_the_style_guide_recommends = "I mean, a really, really long line like you can't believe" # lint:ignore:140chars
55
- }
59
+ puppet-lint --only-checks trailing_whitespace --fix modules/
56
60
  ```
57
61
 
58
- See puppet-lint --help for a full list of options.
62
+ ### Disable Lint checks
59
63
 
60
- ### Rake
64
+ You can disable specific Lint checks on the command line, disable them permanently with a configuration file, or disable them with control comments within your Puppet code.
61
65
 
62
- If you want to test your entire Puppet manifest directory, you can add
63
- `require 'puppet-lint/tasks/puppet-lint'` to your Rakefile and then run
66
+ #### Disable checks on the command line
64
67
 
65
- rake lint
68
+ To disable any of the checks when running the `puppet-lint` command, add a `--no-<check name>-check` flag to the command. For example, to skip the 140-character check, run:
66
69
 
67
- If you want to modify the default behaviour of the rake task, you can modify
68
- the PuppetLint configuration by defining the task yourself.
70
+ ```
71
+ puppet-lint --no-140chars-check modules/
72
+ ```
73
+
74
+ #### Disable checks within Puppet code
69
75
 
70
- PuppetLint::RakeTask.new :lint do |config|
71
- # Pattern of files to check, defaults to `**/*.pp`
72
- config.pattern = 'modules'
76
+ To disable checks from within your Puppet code itself, use [control comments](http://puppet-lint.com/controlcomments/). Disable checks on either a per-line or per-block basis using `#lint:ignore:<check_name>`.
73
77
 
74
- # Pattern of files to ignore
75
- config.ignore_paths = ['modules/apt', 'modules/stdlib']
78
+ For example:
76
79
 
77
- # List of checks to disable
78
- config.disable_checks = ['documentation', '140chars']
80
+ ```puppet
81
+ class foo {
82
+ $bar = 'bar'
79
83
 
80
- # Should puppet-lint prefix it's output with the file being checked,
81
- # defaults to true
82
- config.with_filename = false
84
+ # This ignores the double_quoted_strings check over multiple lines
83
85
 
84
- # Should the task fail if there were any warnings, defaults to false
85
- config.fail_on_warnings = true
86
+ # lint:ignore:double_quoted_strings
87
+ $baz = "baz"
88
+ $gronk = "gronk"
89
+ # lint:endignore
86
90
 
87
- # Format string for puppet-lint's output (see the puppet-lint help output
88
- # for details
89
- config.log_format = '%{filename} - %{message}'
91
+ # This ignores the 140chars check on a single line
90
92
 
91
- # Print out the context for the problem, defaults to false
92
- config.with_context = true
93
+ $this_line_has_a_really_long_name_and_value_that_is_much_longer_than_the_style_guide_recommends = "I mean, a really, really long line like you can't believe" # lint:ignore:140chars
94
+ }
95
+ ```
93
96
 
94
- # Enable automatic fixing of problems, defaults to false
95
- config.fix = true
97
+ ## Configuration file
96
98
 
97
- # Show ignored problems in the output, defaults to false
98
- config.show_ignored = true
99
+ Each time Puppet Lint starts up, it loads configuration from three files in order:
99
100
 
100
- # Compare module layout relative to the module root
101
- config.relative = true
102
- end
101
+ 1. `/etc/puppet-lint.rc`
102
+ 1. `~/.puppet-lint.rc`
103
+ 1. `.puppet-lint.rc`
103
104
 
104
- ### Settings
105
+ This means that a flag in the local `.puppet-lint.rc` will take precedence over a flag in the global `/etc/puppet-lint.rc`, for example. Flags specified on the command line take final precedence and override all config file options.
105
106
 
106
- puppet-lint will also check for a `.puppet-lint.rc` file in the current
107
- directory and your home directory and read in flags from there, so if you
108
- wanted to always skip the hard tab character check, you could create
109
- `~/.puppet-lint.rc` containing
107
+ Any flag that can be specified on the command line can also be specified in the configuration file. For example, to always skip the hard tab character check, create `~/.puppet-lint.rc` and include the line:
110
108
 
111
109
  ```
112
110
  --no-hard_tabs-check
113
111
  ```
114
112
 
115
- ## Compatibility Warning
113
+ Or to specify a whitelist of allowed checks, include a line like:
116
114
 
117
- Release 2.1.0 of puppet-lint is the last planned version with support for Puppet 3 and Ruby 1.8.7. Future versions will drop support for these versions.
115
+ ```
116
+ --only-checks=trailing_whitespace,hard_tabs,duplicate_params,double_quoted_strings,unquoted_file_mode,only_variable_string,variables_not_enclosed,single_quote_string_with_variables,variable_contains_dash,ensure_not_symlink_target,unquoted_resource_title,relative_classname_inclusion,file_mode,resource_reference_without_title_capital,leading_zero,arrow_alignment,variable_is_lowercase,ensure_first_param,resource_reference_without_whitespace,file_ensure,trailing_comma,leading_zero
117
+ ```
118
118
 
119
- ## Implemented Tests
119
+ ## Testing with Puppet Lint as a Rake task
120
120
 
121
- At the moment, the following tests have been implemented:
121
+ To test your entire Puppet manifest directory, add `require 'puppet-lint/tasks/puppet-lint'` to your Rakefile and then run:
122
122
 
123
- ### Spacing, Indentation & Whitespace
123
+ ```
124
+ rake lint
125
+ ```
124
126
 
125
- * Must use two-space soft tabs.
126
- * Must not use literal tab characters.
127
- * Must not contain trailing white space.
128
- * Should not exceed an 140 character line width
129
- * An exception has been made for `source => 'puppet://...'` lines as
130
- splitting these over multiple lines decreases the readability of the
131
- manifests.
132
- * Should align arrows (`=>`) within blocks of attributes.
127
+ To modify the default behaviour of the Rake task, modify the Puppet Lint configuration by defining the task yourself. For example:
133
128
 
134
- ### Quoting
129
+ ```ruby
130
+ PuppetLint::RakeTask.new :lint do |config|
131
+ # Pattern of files to check, defaults to `**/*.pp`
132
+ config.pattern = 'modules'
135
133
 
136
- * All strings that do not contain variables should be enclosed in single
137
- quotes.
138
- * An exception has been made for double quoted strings containing \n or \t.
139
- * All strings that contain variables must be enclosed in double quotes.
140
- * All variables should be enclosed in braces when interpolated in a string.
141
- * Variables standing by themselves should not be quoted.
134
+ # Pattern of files to ignore
135
+ config.ignore_paths = ['modules/apt', 'modules/stdlib']
142
136
 
143
- ### Capitalization
144
- * All variables should be in lowercase
137
+ # List of checks to disable
138
+ config.disable_checks = ['documentation', '140chars']
145
139
 
146
- ### Resources
140
+ # Should puppet-lint prefix it's output with the file being checked,
141
+ # defaults to true
142
+ config.with_filename = false
147
143
 
148
- * All resource titles should be quoted.
149
- * An exception has been made for resource titles that consist of only
150
- a variable standing by itself.
151
- * If a resource declaration includes an `ensure` attribute, it should be the
152
- first attribute specified.
153
- * Symbolic links should be declared by using an ensure value of `link` and
154
- explicitly specifying a value for the `target` attribute.
155
- * File modes should be represented as a 4 digit string enclosed in single
156
- quotes or use symbolic file modes.
144
+ # Should the task fail if there were any warnings, defaults to false
145
+ config.fail_on_warnings = true
157
146
 
158
- ### Conditionals
147
+ # Format string for puppet-lint's output (see the puppet-lint help output
148
+ # for details
149
+ config.log_format = '%{filename} - %{message}'
159
150
 
160
- * You should not intermingle conditionals inside resource declarations (i.e.
161
- selectors inside resources).
162
- * Case statements should have a default case.
151
+ # Print out the context for the problem, defaults to false
152
+ config.with_context = true
163
153
 
164
- ### Classes
154
+ # Enable automatic fixing of problems, defaults to false
155
+ config.fix = true
165
156
 
166
- * Relationship declarations with the chaining syntax should only be used in
167
- the 'left to right' direction.
168
- * Classes should not be defined inside a class.
169
- * Defines should not be defined inside a class.
170
- * Classes should not inherit between namespaces.
171
- * Required parameters in class & defined type definitions should be listed
172
- before optional parameters.
173
- * When using top-scope variables, including facts, Puppet modules should
174
- explicitly specify the empty namespace.
157
+ # Show ignored problems in the output, defaults to false
158
+ config.show_ignored = true
175
159
 
176
- ## Disabling checks
160
+ # Compare module layout relative to the module root
161
+ config.relative = true
162
+ end
163
+ ```
177
164
 
178
- ### puppet-lint
165
+ ### Disable checks in the Lint Rake task
179
166
 
180
- You can disable any of the checks when running the `puppet-lint` command by
181
- adding a `--no-<check name>-check` flag to the command. For example, if you
182
- wanted to skip the 140 character check, you would run
167
+ You can also disable checks when running Puppet Lint through the supplied Rake task by modifying your `Rakefile`.
183
168
 
184
- ```
185
- puppet-lint --no-140chars-check /path/to/my/manifest.pp
186
- ```
169
+ * To disable a check, add the following line after the `require` statement in your `Rakefile`:
187
170
 
188
- puppet-lint will also check for a `.puppet-lint.rc` file in the current
189
- directory and your home directory and read in flags from there, so if you
190
- wanted to always skip the hard tab character check, you could create
191
- `~/.puppet-lint.rc` containing
171
+ ```ruby
172
+ PuppetLint.configuration.send("disable_<check name>")
173
+ ```
192
174
 
193
- ```
194
- --no-hard_tabs-check
195
- ```
175
+ For example, to disable the 140-character check, add:
196
176
 
197
- For a list of all the flags just type:
177
+ ```ruby
178
+ PuppetLint.configuration.send("disable_140chars")
179
+ ```
198
180
 
199
- ```
200
- puppet-lint --help
201
- ```
181
+ * To set the Lint Rake task to ignore certain paths:
202
182
 
203
- ### Rake task
183
+ ```ruby
184
+ PuppetLint.configuration.ignore_paths = ["vendor/**/*.pp"]
185
+ ```
204
186
 
205
- You can also disable checks when running puppet-lint through the supplied Rake
206
- task. Simply add the following line after the `require` statement in your
207
- `Rakefile`.
187
+ * To set a pattern of files that Lint should check:
208
188
 
209
- ``` ruby
210
- PuppetLint.configuration.send("disable_<check name>")
211
- ```
189
+ ```ruby
190
+ # Defaults to `**/*.pp`
191
+ PuppetLint.configuration.pattern = "modules"
192
+ ```
212
193
 
213
- So, to disable the 140 character check, you would add:
194
+ ## Options
214
195
 
215
- ``` ruby
216
- PuppetLint.configuration.send("disable_140chars")
217
- ```
196
+ See `puppet-lint --help` for a full list of command line options and checks.
218
197
 
219
- The Rake task also supports ignoring certain paths
220
- from being linted:
198
+ ## Checks
221
199
 
222
- ``` ruby
223
- PuppetLint.configuration.ignore_paths = ["vendor/**/*.pp"]
224
- ```
200
+ For a complete list of checks, and how to resolve errors on each check, see the Puppet Lint [checks](http://puppet-lint.com/checks/) page.
201
+
202
+ ### Spacing, Indentation, and Whitespace
203
+
204
+ * Must use two-space soft tabs.
205
+ * Must not use literal tab characters.
206
+ * Must not contain trailing white space.
207
+ * Should not exceed an 140-character line width.
208
+ * An exception has been made for `source => 'puppet://...'` lines as splitting these over multiple lines decreases the readability of the manifests.
209
+ * Should align arrows (`=>`) within blocks of attributes.
210
+
211
+ ### Quoting
212
+
213
+ * All strings that do not contain variables should be enclosed in single quotes.
214
+ * An exception has been made for double-quoted strings containing \n or \t.
215
+ * All strings that contain variables must be enclosed in double quotes.
216
+ * All variables should be enclosed in braces when interpolated in a string.
217
+ * Variables standing by themselves should not be quoted.
218
+
219
+ ### Capitalization
220
+
221
+ * All variables should be in lowercase.
222
+
223
+ ### Resources
224
+
225
+ * All resource titles should be quoted.
226
+ * An exception has been made for resource titles that consist of only a variable standing by itself.
227
+ * If a resource declaration includes an `ensure` attribute, it should be the first attribute specified.
228
+ * Symbolic links should be declared by using an ensure value of `link` and explicitly specifying a value for the `target` attribute.
229
+ * File modes should be represented as a 4-digit string enclosed in single quotes or use symbolic file modes.
230
+
231
+ ### Conditionals
232
+
233
+ * You should not intermingle conditionals inside resource declarations (that is, selectors inside resources).
234
+ * Case statements should have a default case.
235
+
236
+ ### Classes
237
+
238
+ * Relationship declarations with the chaining syntax should only be used in the 'left to right' direction.
239
+ * Classes should not be defined inside a class.
240
+ * Defines should not be defined inside a class.
241
+ * Classes should not inherit between namespaces.
242
+ * Required parameters in class & defined type definitions should be listed before optional parameters.
243
+ * When using top-scope variables, including facts, Puppet modules should explicitly specify the empty namespace.
244
+ * Chaining operators should appear on the same line as the right hand operand.
225
245
 
226
246
  ## Reporting bugs or incorrect results
227
247
 
228
- If you find a bug in puppet-lint or its results, please create an issue in the
229
- [repo issues tracker](https://github.com/rodjek/puppet-lint/issues/). Bonus
248
+ If you find a bug in Puppet Lint or its results, please create an issue in the
249
+ [repo issues tracker](https://github.com/rodjek/puppet-lint/issues/). Bonus
230
250
  points will be awarded if you also include a patch that fixes the issue.
231
251
 
232
- ## Thank You
252
+ ## Thank you
233
253
 
234
254
  Many thanks to the following people for contributing to puppet-lint
235
255
 
236
- * James Turnbull (@kartar)
237
- * Jan Vansteenkiste (@vStone)
238
- * Julian Simpson (@simpsonjulian)
239
- * S. Zachariah Sprackett (@zsprackett)
256
+ * James Turnbull (@kartar)
257
+ * Jan Vansteenkiste (@vStone)
258
+ * Julian Simpson (@simpsonjulian)
259
+ * S. Zachariah Sprackett (@zsprackett)
240
260
 
241
261
  As well as the many people who have reported the issues they've had!
242
262
 
@@ -244,21 +264,8 @@ As well as the many people who have reported the issues they've had!
244
264
 
245
265
  Copyright (c) 2011-2016 Tim Sharpe
246
266
 
247
- Permission is hereby granted, free of charge, to any person obtaining
248
- a copy of this software and associated documentation files (the
249
- "Software"), to deal in the Software without restriction, including
250
- without limitation the rights to use, copy, modify, merge, publish,
251
- distribute, sublicense, and/or sell copies of the Software, and to
252
- permit persons to whom the Software is furnished to do so, subject to
253
- the following conditions:
254
-
255
- The above copyright notice and this permission notice shall be
256
- included in all copies or substantial portions of the Software.
257
-
258
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
259
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
260
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
261
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
262
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
263
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
264
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
267
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
268
+
269
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
270
+
271
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.