puppet-lint 2.3.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +74 -0
  3. data/.rubocop_todo.yml +89 -0
  4. data/.travis.yml +11 -9
  5. data/CHANGELOG.md +54 -0
  6. data/Gemfile +3 -0
  7. data/Rakefile +14 -3
  8. data/appveyor.yml +1 -4
  9. data/bin/puppet-lint +1 -1
  10. data/lib/puppet-lint.rb +25 -21
  11. data/lib/puppet-lint/bin.rb +15 -19
  12. data/lib/puppet-lint/checkplugin.rb +24 -17
  13. data/lib/puppet-lint/checks.rb +42 -31
  14. data/lib/puppet-lint/configuration.rb +11 -8
  15. data/lib/puppet-lint/data.rb +236 -164
  16. data/lib/puppet-lint/lexer.rb +225 -203
  17. data/lib/puppet-lint/lexer/token.rb +34 -18
  18. data/lib/puppet-lint/optparser.rb +33 -30
  19. data/lib/puppet-lint/plugins.rb +42 -38
  20. data/lib/puppet-lint/plugins/check_classes/arrow_on_right_operand_line.rb +26 -28
  21. data/lib/puppet-lint/plugins/check_classes/autoloader_layout.rb +21 -20
  22. data/lib/puppet-lint/plugins/check_classes/class_inherits_from_params_class.rb +8 -9
  23. data/lib/puppet-lint/plugins/check_classes/code_on_top_scope.rb +9 -8
  24. data/lib/puppet-lint/plugins/check_classes/inherits_across_namespaces.rb +12 -11
  25. data/lib/puppet-lint/plugins/check_classes/names_containing_dash.rb +13 -12
  26. data/lib/puppet-lint/plugins/check_classes/names_containing_uppercase.rb +14 -13
  27. data/lib/puppet-lint/plugins/check_classes/nested_classes_or_defines.rb +9 -10
  28. data/lib/puppet-lint/plugins/check_classes/parameter_order.rb +40 -31
  29. data/lib/puppet-lint/plugins/check_classes/right_to_left_relationship.rb +3 -2
  30. data/lib/puppet-lint/plugins/check_classes/variable_scope.rb +21 -24
  31. data/lib/puppet-lint/plugins/check_comments/slash_comments.rb +3 -2
  32. data/lib/puppet-lint/plugins/check_comments/star_comments.rb +6 -5
  33. data/lib/puppet-lint/plugins/check_conditionals/case_without_default.rb +21 -20
  34. data/lib/puppet-lint/plugins/check_conditionals/selector_inside_resource.rb +10 -13
  35. data/lib/puppet-lint/plugins/check_documentation/documentation.rb +26 -17
  36. data/lib/puppet-lint/plugins/check_nodes/unquoted_node_name.rb +11 -11
  37. data/lib/puppet-lint/plugins/check_resources/duplicate_params.rb +4 -3
  38. data/lib/puppet-lint/plugins/check_resources/ensure_first_param.rb +17 -18
  39. data/lib/puppet-lint/plugins/check_resources/ensure_not_symlink_target.rb +17 -16
  40. data/lib/puppet-lint/plugins/check_resources/file_mode.rb +22 -23
  41. data/lib/puppet-lint/plugins/check_resources/unquoted_file_mode.rb +14 -13
  42. data/lib/puppet-lint/plugins/check_resources/unquoted_resource_title.rb +9 -8
  43. data/lib/puppet-lint/plugins/check_strings/double_quoted_strings.rb +8 -8
  44. data/lib/puppet-lint/plugins/check_strings/only_variable_string.rb +29 -42
  45. data/lib/puppet-lint/plugins/check_strings/puppet_url_without_modules.rb +5 -4
  46. data/lib/puppet-lint/plugins/check_strings/quoted_booleans.rb +3 -2
  47. data/lib/puppet-lint/plugins/check_strings/single_quote_string_with_variables.rb +4 -3
  48. data/lib/puppet-lint/plugins/check_strings/variables_not_enclosed.rb +3 -2
  49. data/lib/puppet-lint/plugins/check_variables/variable_contains_dash.rb +9 -8
  50. data/lib/puppet-lint/plugins/check_variables/variable_is_lowercase.rb +9 -8
  51. data/lib/puppet-lint/plugins/check_whitespace/140chars.rb +9 -9
  52. data/lib/puppet-lint/plugins/check_whitespace/2sp_soft_tabs.rb +4 -3
  53. data/lib/puppet-lint/plugins/check_whitespace/80chars.rb +10 -10
  54. data/lib/puppet-lint/plugins/check_whitespace/arrow_alignment.rb +23 -22
  55. data/lib/puppet-lint/plugins/check_whitespace/hard_tabs.rb +3 -2
  56. data/lib/puppet-lint/plugins/check_whitespace/trailing_whitespace.rb +3 -2
  57. data/lib/puppet-lint/tasks/puppet-lint.rb +3 -3
  58. data/lib/puppet-lint/version.rb +1 -1
  59. data/puppet-lint.gemspec +4 -4
  60. data/spec/puppet-lint/bin_spec.rb +268 -140
  61. data/spec/puppet-lint/checks_spec.rb +229 -0
  62. data/spec/puppet-lint/configuration_spec.rb +10 -9
  63. data/spec/puppet-lint/data_spec.rb +84 -0
  64. data/spec/puppet-lint/ignore_overrides_spec.rb +71 -40
  65. data/spec/puppet-lint/lexer/token_spec.rb +1 -1
  66. data/spec/puppet-lint/lexer_spec.rb +306 -73
  67. data/spec/puppet-lint/plugins/check_classes/arrow_on_right_operand_line_spec.rb +12 -6
  68. data/spec/puppet-lint/plugins/check_classes/autoloader_layout_spec.rb +10 -10
  69. data/spec/puppet-lint/plugins/check_classes/class_inherits_from_params_class_spec.rb +15 -11
  70. data/spec/puppet-lint/plugins/check_classes/code_on_top_scope_spec.rb +26 -21
  71. data/spec/puppet-lint/plugins/check_classes/inherits_across_namespaces_spec.rb +3 -3
  72. data/spec/puppet-lint/plugins/check_classes/name_contains_uppercase_spec.rb +4 -5
  73. data/spec/puppet-lint/plugins/check_classes/names_containing_dash_spec.rb +13 -0
  74. data/spec/puppet-lint/plugins/check_classes/nested_classes_or_defines_spec.rb +33 -25
  75. data/spec/puppet-lint/plugins/check_classes/parameter_order_spec.rb +80 -55
  76. data/spec/puppet-lint/plugins/check_classes/right_to_left_relationship_spec.rb +2 -2
  77. data/spec/puppet-lint/plugins/check_classes/variable_scope_spec.rb +165 -130
  78. data/spec/puppet-lint/plugins/check_comments/slash_comments_spec.rb +2 -2
  79. data/spec/puppet-lint/plugins/check_comments/star_comments_spec.rb +53 -35
  80. data/spec/puppet-lint/plugins/check_conditionals/case_without_default_spec.rb +59 -49
  81. data/spec/puppet-lint/plugins/check_conditionals/selector_inside_resource_spec.rb +18 -14
  82. data/spec/puppet-lint/plugins/check_documentation/documentation_spec.rb +14 -10
  83. data/spec/puppet-lint/plugins/check_nodes/unquoted_node_name_spec.rb +7 -7
  84. data/spec/puppet-lint/plugins/check_resources/duplicate_params_spec.rb +54 -44
  85. data/spec/puppet-lint/plugins/check_resources/ensure_first_param_spec.rb +114 -89
  86. data/spec/puppet-lint/plugins/check_resources/ensure_not_symlink_target_spec.rb +41 -30
  87. data/spec/puppet-lint/plugins/check_resources/file_mode_spec.rb +46 -40
  88. data/spec/puppet-lint/plugins/check_resources/unquoted_file_mode_spec.rb +46 -40
  89. data/spec/puppet-lint/plugins/check_resources/unquoted_resource_title_spec.rb +95 -71
  90. data/spec/puppet-lint/plugins/check_strings/double_quoted_strings_spec.rb +28 -24
  91. data/spec/puppet-lint/plugins/check_strings/only_variable_string_spec.rb +11 -9
  92. data/spec/puppet-lint/plugins/check_strings/puppet_url_without_modules_spec.rb +1 -2
  93. data/spec/puppet-lint/plugins/check_strings/single_quote_string_with_variables_spec.rb +18 -14
  94. data/spec/puppet-lint/plugins/check_variables/variable_contains_dash_spec.rb +1 -1
  95. data/spec/puppet-lint/plugins/check_variables/variable_is_lowercase_spec.rb +1 -1
  96. data/spec/puppet-lint/plugins/check_whitespace/140chars_spec.rb +22 -15
  97. data/spec/puppet-lint/plugins/check_whitespace/2sp_soft_tabs_spec.rb +8 -6
  98. data/spec/puppet-lint/plugins/check_whitespace/80chars_spec.rb +23 -29
  99. data/spec/puppet-lint/plugins/check_whitespace/arrow_alignment_spec.rb +588 -494
  100. data/spec/puppet-lint/plugins/check_whitespace/hard_tabs_spec.rb +1 -1
  101. data/spec/puppet-lint/plugins/check_whitespace/trailing_whitespace_spec.rb +27 -19
  102. data/spec/puppet-lint_spec.rb +2 -12
  103. data/spec/spec_helper.rb +35 -30
  104. metadata +6 -5
  105. data/lib/puppet-lint/monkeypatches.rb +0 -2
  106. data/lib/puppet-lint/monkeypatches/string_percent.rb +0 -52
  107. data/lib/puppet-lint/monkeypatches/string_prepend.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5cf7e44161d54a800d685bcfd4cf152f5d8513c9
4
- data.tar.gz: dedf83a5d6c65efd93413867bce94c198b622b0c
3
+ metadata.gz: 3516ab4e6adac864c4fb3e43ce1f90bb5d81288c
4
+ data.tar.gz: a518428edb88a71dd7bb0708e060d5ee76fbd16c
5
5
  SHA512:
6
- metadata.gz: 40ae10c6e1b29822cbc3146c9a1fb4dcbfcabacc3d934710d9b7ca654bfdbd3ba45a44186f03b32ff77ba1dbeb147f58131a7fc197e08cccac60f4ec9fa13153
7
- data.tar.gz: fb7c37f37510e8d6f6fb100e797e2d002cc539ad08c5bbaddda33c301d077ba09761d71d967692ad95f5de6b8b8e7f9a66d03f1ac12370d9e0b89fb41932effb
6
+ metadata.gz: 70a5239c7b36ef55024580ebcda52e5bee45db6d12b21d2e957233930555dd3c91645a3f0076a393dfd79481511ab39a555689994aa4827c6a52b4326bc3745e
7
+ data.tar.gz: db50c67864f94a834f141af85eaf062a7a8d62f2c74fda37510bb959685e9594dd09406ca11f3b58338ade7154ffee51ed5e72dd53597ebb8503693237addf77
data/.rubocop.yml ADDED
@@ -0,0 +1,74 @@
1
+ ---
2
+ inherit_from: './.rubocop_todo.yml'
3
+ AllCops:
4
+ TargetRubyVersion: 1.9
5
+
6
+ Style/HashSyntax:
7
+ EnforcedStyle: hash_rockets
8
+
9
+ Layout/FirstArrayElementLineBreak:
10
+ Enabled: true
11
+ Layout/FirstHashElementLineBreak:
12
+ Enabled: true
13
+ Layout/FirstMethodArgumentLineBreak:
14
+ Enabled: true
15
+ Layout/FirstMethodParameterLineBreak:
16
+ Enabled: true
17
+ Layout/IndentArray:
18
+ EnforcedStyle: consistent
19
+ Layout/MultilineArrayBraceLayout:
20
+ EnforcedStyle: new_line
21
+ Layout/MultilineAssignmentLayout:
22
+ Enabled: true
23
+ EnforcedStyle: same_line
24
+ Layout/MultilineHashBraceLayout:
25
+ EnforcedStyle: new_line
26
+ Layout/MultilineMethodDefinitionBraceLayout:
27
+ EnforcedStyle: new_line
28
+
29
+ Style/AutoResourceCleanup:
30
+ Enabled: true
31
+ Style/BlockDelimiters:
32
+ EnforcedStyle: braces_for_chaining
33
+ Style/BracesAroundHashParameters:
34
+ EnforcedStyle: context_dependent
35
+ Style/Encoding:
36
+ Enabled: false
37
+ Style/MethodCallWithArgsParentheses:
38
+ Enabled: true
39
+ IgnoreMacros: true
40
+ IgnoredMethods:
41
+ - puts
42
+ - require
43
+ - include
44
+ - it
45
+ - context
46
+ - describe
47
+ - to
48
+ - to_not
49
+ - raise
50
+ - desc
51
+ - task
52
+ - exit
53
+ - should
54
+ - gem
55
+ - group
56
+ - attr_reader
57
+ - attr_accessor
58
+ - attr_writer
59
+ - source
60
+ Style/MethodCalledOnDoEndBlock:
61
+ Enabled: true
62
+ Style/RegexpLiteral:
63
+ EnforcedStyle: percent_r
64
+ Style/TrailingCommaInArguments:
65
+ EnforcedStyleForMultiline: comma
66
+ Style/TrailingCommaInLiteral:
67
+ EnforcedStyleForMultiline: comma
68
+ Style/FormatStringToken:
69
+ Enabled: false
70
+ Style/FileName:
71
+ Exclude:
72
+ - 'lib/puppet-lint.rb'
73
+ - 'lib/puppet-lint/tasks/puppet-lint.rb'
74
+ - 'spec/puppet-lint_spec.rb'
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,89 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2017-08-28 12:57:58 +1000 using RuboCop version 0.49.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 3
10
+ # Configuration parameters: Include.
11
+ # Include: **/Gemfile, **/gems.rb
12
+ Bundler/DuplicatedGem:
13
+ Exclude:
14
+ - 'Gemfile'
15
+
16
+ # Offense count: 2
17
+ # Cop supports --auto-correct.
18
+ # Configuration parameters: Include, TreatCommentsAsGroupSeparators.
19
+ # Include: **/Gemfile, **/gems.rb
20
+ Bundler/OrderedGems:
21
+ Exclude:
22
+ - 'Gemfile'
23
+
24
+ # Offense count: 9
25
+ # Configuration parameters: AllowSafeAssignment.
26
+ Lint/AssignmentInCondition:
27
+ Exclude:
28
+ - 'lib/puppet-lint/lexer.rb'
29
+ - 'lib/puppet-lint/plugins/check_classes/variable_scope.rb'
30
+
31
+ # Offense count: 52
32
+ Metrics/AbcSize:
33
+ Max: 153
34
+
35
+ # Offense count: 121
36
+ # Configuration parameters: CountComments, ExcludedMethods.
37
+ Metrics/BlockLength:
38
+ Max: 1136
39
+
40
+ # Offense count: 8
41
+ # Configuration parameters: CountBlocks.
42
+ Metrics/BlockNesting:
43
+ Max: 5
44
+
45
+ # Offense count: 2
46
+ # Configuration parameters: CountComments.
47
+ Metrics/ClassLength:
48
+ Max: 383
49
+
50
+ # Offense count: 20
51
+ Metrics/CyclomaticComplexity:
52
+ Max: 26
53
+
54
+ # Offense count: 238
55
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
56
+ # URISchemes: http, https
57
+ Metrics/LineLength:
58
+ Max: 223
59
+
60
+ # Offense count: 65
61
+ # Configuration parameters: CountComments.
62
+ Metrics/MethodLength:
63
+ Max: 94
64
+
65
+ # Offense count: 18
66
+ Metrics/PerceivedComplexity:
67
+ Max: 25
68
+
69
+ # Offense count: 1
70
+ # Cop supports --auto-correct.
71
+ Performance/RedundantBlockCall:
72
+ Exclude:
73
+ - 'lib/puppet-lint/tasks/puppet-lint.rb'
74
+
75
+ # Offense count: 7
76
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
77
+ # SupportedStyles: nested, compact
78
+ Style/ClassAndModuleChildren:
79
+ Exclude:
80
+ - 'lib/puppet-lint.rb'
81
+ - 'lib/puppet-lint/bin.rb'
82
+ - 'lib/puppet-lint/checkplugin.rb'
83
+ - 'lib/puppet-lint/checks.rb'
84
+ - 'lib/puppet-lint/data.rb'
85
+ - 'lib/puppet-lint/optparser.rb'
86
+
87
+ # Offense count: 20
88
+ Style/MultilineBlockChain:
89
+ Enabled: false
data/.travis.yml CHANGED
@@ -6,16 +6,18 @@ branches:
6
6
  only:
7
7
  - master
8
8
  bundler_args: --without development system_tests
9
+ script:
10
+ - bundle exec rake $CHECK
11
+ env:
12
+ - CHECK=test
9
13
  rvm:
10
- - 1.8.7
11
14
  - 1.9.3
12
15
  - 2.0.0
13
- - 2.1.9
14
- - 2.3.1
15
- - 2.4.0
16
+ - 2.1.10
17
+ - 2.2.7
18
+ - 2.3.4
19
+ - 2.4.1
16
20
  matrix:
17
- allow_failures:
18
- - rvm: 1.8.7
19
- notifications:
20
- email:
21
- - tim@bombasticmonkey.com
21
+ include:
22
+ - rvm: 2.4.1
23
+ env: CHECK=rubocop
data/CHANGELOG.md CHANGED
@@ -1,5 +1,59 @@
1
1
  # Change Log
2
2
 
3
+ ## [2.3.1](https://github.com/rodjek/puppet-lint/tree/2.3.1) (2017-09-27)
4
+ [Full Changelog](https://github.com/rodjek/puppet-lint/compare/2.3.0...2.3.1)
5
+
6
+ **Fixed bugs:**
7
+
8
+ - NoMethodError: undefined method `type' for nil:NilClass [\#732](https://github.com/rodjek/puppet-lint/issues/732)
9
+ - NoMethodError: undefined method `end\_with?' for nil:NilClass [\#727](https://github.com/rodjek/puppet-lint/issues/727)
10
+ - puppet-lint not applying some lint:ignore statements when there are more then 2 on the same line [\#726](https://github.com/rodjek/puppet-lint/issues/726)
11
+ - optional paramter warning false positve when inheriting params [\#716](https://github.com/rodjek/puppet-lint/issues/716)
12
+ - invalid byte sequence in UTF-8 in selmodule-example.pp [\#714](https://github.com/rodjek/puppet-lint/issues/714)
13
+ - puppet-lint --fix encountered an error that it doesn't know how to handle [\#706](https://github.com/rodjek/puppet-lint/issues/706)
14
+ - Mangled file after running puppet-lint due to chained function call [\#703](https://github.com/rodjek/puppet-lint/issues/703)
15
+ - `incompatible encoding regexp match` for non-printing characters in place of space [\#693](https://github.com/rodjek/puppet-lint/issues/693)
16
+ - Unhandled error case [\#691](https://github.com/rodjek/puppet-lint/issues/691)
17
+
18
+ **Closed issues:**
19
+
20
+ - puppet-lint has encountered an error that it doesn't know how to handle [\#750](https://github.com/rodjek/puppet-lint/issues/750)
21
+ - Variable use like "a+1 = ${$a + 1}" isn't reported but silently changed by --fix to "a+1 = ${a} + 1" [\#749](https://github.com/rodjek/puppet-lint/issues/749)
22
+ - using --fix changes line endings [\#748](https://github.com/rodjek/puppet-lint/issues/748)
23
+ - Puppet lint syntax error - puppet parser validate no issues [\#746](https://github.com/rodjek/puppet-lint/issues/746)
24
+ - Error not handled [\#745](https://github.com/rodjek/puppet-lint/issues/745)
25
+ - Whoops, not sure why. ArgumentError: bad value for range [\#742](https://github.com/rodjek/puppet-lint/issues/742)
26
+ - ArgumentError: bad value for range [\#741](https://github.com/rodjek/puppet-lint/issues/741)
27
+ - Line numbers off after multi-line strings with variables [\#736](https://github.com/rodjek/puppet-lint/issues/736)
28
+ - Whoops! It looks like puppet-lint has encountered an error [\#729](https://github.com/rodjek/puppet-lint/issues/729)
29
+ - puppet lint config log\_format not working [\#725](https://github.com/rodjek/puppet-lint/issues/725)
30
+ - Quoted booleans in Puppet5 for Enum type declarations. [\#720](https://github.com/rodjek/puppet-lint/issues/720)
31
+ - Chaining arrow syntax fix introduces trailing whitespaces [\#695](https://github.com/rodjek/puppet-lint/issues/695)
32
+ - Refactor check\_comments.rb [\#587](https://github.com/rodjek/puppet-lint/issues/587)
33
+ - Puppethack 12/2016 Issues [\#583](https://github.com/rodjek/puppet-lint/issues/583)
34
+ - Allow multiple block-level ignore comments [\#498](https://github.com/rodjek/puppet-lint/issues/498)
35
+ - puppet-lint crashes with "invalid byte sequence in UTF-8 \(ArgumentError\)" [\#458](https://github.com/rodjek/puppet-lint/issues/458)
36
+
37
+ **Merged pull requests:**
38
+
39
+ - Render the ${} enclosures as part of the string tokens [\#752](https://github.com/rodjek/puppet-lint/pull/752) ([rodjek](https://github.com/rodjek))
40
+ - Open manifest as binary when writing fixed manifest [\#751](https://github.com/rodjek/puppet-lint/pull/751) ([rodjek](https://github.com/rodjek))
41
+ - Remove monkeypatches to implement String\#% [\#744](https://github.com/rodjek/puppet-lint/pull/744) ([rodjek](https://github.com/rodjek))
42
+ - Add unit tests for PuppetLint::Checks [\#743](https://github.com/rodjek/puppet-lint/pull/743) ([rodjek](https://github.com/rodjek))
43
+ - Update CI configuration [\#739](https://github.com/rodjek/puppet-lint/pull/739) ([rodjek](https://github.com/rodjek))
44
+ - Rubocop compliance [\#738](https://github.com/rodjek/puppet-lint/pull/738) ([rodjek](https://github.com/rodjek))
45
+ - Fix line numbers being off with multi-line strings containing variables [\#737](https://github.com/rodjek/puppet-lint/pull/737) ([cbowman0](https://github.com/cbowman0))
46
+ - Split control comments into words before parsing [\#735](https://github.com/rodjek/puppet-lint/pull/735) ([rodjek](https://github.com/rodjek))
47
+ - Handle unicode spaces in the tokeniser [\#734](https://github.com/rodjek/puppet-lint/pull/734) ([rodjek](https://github.com/rodjek))
48
+ - Handle SE Linux policy package files [\#733](https://github.com/rodjek/puppet-lint/pull/733) ([rodjek](https://github.com/rodjek))
49
+ - Take into account Optional data type when checking parameter order [\#731](https://github.com/rodjek/puppet-lint/pull/731) ([rodjek](https://github.com/rodjek))
50
+ - Read the manifest files as UTF-8 [\#730](https://github.com/rodjek/puppet-lint/pull/730) ([rodjek](https://github.com/rodjek))
51
+ - Improve handling of unterminated double quoted strings [\#728](https://github.com/rodjek/puppet-lint/pull/728) ([rodjek](https://github.com/rodjek))
52
+ - Chaining arrow syntax fix introduces trailing whitespaces [\#708](https://github.com/rodjek/puppet-lint/pull/708) ([rnelson0](https://github.com/rnelson0))
53
+ - Add helper methods to add and remove tokens while maintaining the token links [\#694](https://github.com/rodjek/puppet-lint/pull/694) ([Darhazer](https://github.com/Darhazer))
54
+ - Code style improvements [\#661](https://github.com/rodjek/puppet-lint/pull/661) ([Darhazer](https://github.com/Darhazer))
55
+ - Plugins: Improve code readability [\#658](https://github.com/rodjek/puppet-lint/pull/658) ([Darhazer](https://github.com/Darhazer))
56
+
3
57
  ## [2.3.0](https://github.com/rodjek/puppet-lint/tree/2.3.0) (2017-07-12)
4
58
  [Full Changelog](https://github.com/rodjek/puppet-lint/compare/2.2.1...2.3.0)
5
59
 
data/Gemfile CHANGED
@@ -25,6 +25,9 @@ group :test do
25
25
  # requires ruby 1.9+, on 1.8 we'll fall back to the old regex parsing
26
26
  gem 'rspec-json_expectations', '~> 1.4'
27
27
  end
28
+
29
+ gem 'rubocop', '0.49.1' if RUBY_VERSION > '2.0'
30
+ gem 'simplecov', :require => false
28
31
  end
29
32
 
30
33
  group :development do
data/Rakefile CHANGED
@@ -8,12 +8,23 @@ RSpec::Core::RakeTask.new(:test)
8
8
 
9
9
  begin
10
10
  require 'github_changelog_generator/task'
11
- GitHubChangelogGenerator::RakeTask.new :changelog do |config|
11
+ GitHubChangelogGenerator::RakeTask.new(:changelog) do |config|
12
12
  version = PuppetLint::VERSION
13
- config.future_release = "#{version}"
14
- config.exclude_labels = %w{duplicate question invalid wontfix release-pr}
13
+ config.future_release = version.to_s
14
+ config.exclude_labels = %w[duplicate question invalid wontfix release-pr]
15
15
  end
16
16
  rescue LoadError
17
+ $stderr.puts 'Changelog generation requires Ruby 2.0 or higher'
18
+ end
19
+
20
+ begin
21
+ require 'rubocop/rake_task'
22
+
23
+ RuboCop::RakeTask.new(:rubocop) do |task|
24
+ task.options = %w[-D -E]
25
+ end
26
+ rescue LoadError
27
+ $stderr.puts 'Rubocop is not available for this version of Ruby.'
17
28
  end
18
29
 
19
30
  # vim: syntax=ruby
data/appveyor.yml CHANGED
@@ -12,6 +12,7 @@ environment:
12
12
  - RUBY_VERSION: 21
13
13
  - RUBY_VERSION: 22
14
14
  - RUBY_VERSION: 23-x64
15
+ - RUBY_VERSION: 24-x64
15
16
 
16
17
  install:
17
18
  - SET PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
@@ -26,7 +27,3 @@ before_test:
26
27
 
27
28
  test_script:
28
29
  - bundle exec rake test
29
-
30
- notifications:
31
- email:
32
- - tim@bombasticmonkey.com
data/bin/puppet-lint CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
 
5
5
  require 'puppet-lint'
6
6
 
data/lib/puppet-lint.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'set'
2
4
  require 'json'
3
5
  require 'puppet-lint/version'
@@ -6,7 +8,6 @@ require 'puppet-lint/configuration'
6
8
  require 'puppet-lint/data'
7
9
  require 'puppet-lint/checks'
8
10
  require 'puppet-lint/bin'
9
- require 'puppet-lint/monkeypatches'
10
11
 
11
12
  class PuppetLint::NoCodeError < StandardError; end
12
13
  class PuppetLint::NoFix < StandardError; end
@@ -47,7 +48,7 @@ class PuppetLint
47
48
  # Public: Initialise a new PuppetLint object.
48
49
  def initialize
49
50
  @code = nil
50
- @statistics = {:error => 0, :warning => 0, :fixed => 0, :ignored => 0}
51
+ @statistics = { :error => 0, :warning => 0, :fixed => 0, :ignored => 0 }
51
52
  @manifest = ''
52
53
  end
53
54
 
@@ -70,10 +71,16 @@ class PuppetLint
70
71
  #
71
72
  # Returns nothing.
72
73
  def file=(path)
73
- if File.exist? path
74
- @path = path
75
- @code = File.read(path)
74
+ return unless File.exist?(path)
75
+
76
+ @path = path
77
+ File.open(path, 'r:UTF-8') do |f|
78
+ @code = f.read
76
79
  end
80
+
81
+ # Check if the input is an SE Linux policy package file (which also use
82
+ # the .pp extension), which all have the first 4 bytes 0xf97cff8f.
83
+ @code = '' if @code[0..3].unpack('V').first == 0xf97cff8f
77
84
  end
78
85
 
79
86
  # Internal: Retrieve the format string to be used when writing problems to
@@ -85,12 +92,11 @@ class PuppetLint
85
92
  if configuration.log_format == ''
86
93
  ## recreate previous old log format as far as thats possible.
87
94
  format = '%{KIND}: %{message} on line %{line}'
88
- if configuration.with_filename
89
- format.prepend '%{path} - '
90
- end
95
+ format.prepend('%{path} - ') if configuration.with_filename
91
96
  configuration.log_format = format
92
97
  end
93
- return configuration.log_format
98
+
99
+ configuration.log_format
94
100
  end
95
101
 
96
102
  # Internal: Format a problem message and print it to STDOUT.
@@ -101,9 +107,8 @@ class PuppetLint
101
107
  def format_message(message)
102
108
  format = log_format
103
109
  puts format % message
104
- if message[:kind] == :ignored && !message[:reason].nil?
105
- puts " #{message[:reason]}"
106
- end
110
+
111
+ puts " #{message[:reason]}" if message[:kind] == :ignored && !message[:reason].nil?
107
112
  end
108
113
 
109
114
  # Internal: Get the line of the manifest on which the problem was found
@@ -112,8 +117,7 @@ class PuppetLint
112
117
  #
113
118
  # Returns the problematic line as a string.
114
119
  def get_context(message)
115
- line = PuppetLint::Data.manifest_lines[message[:line] - 1]
116
- return line.strip
120
+ PuppetLint::Data.manifest_lines[message[:line] - 1].strip
117
121
  end
118
122
 
119
123
  # Internal: Print out the line of the manifest on which the problem was found
@@ -126,9 +130,9 @@ class PuppetLint
126
130
  return if message[:check] == 'documentation'
127
131
  return if message[:kind] == :fixed
128
132
  line = get_context(message)
129
- offset = line.index(/\S/) || 1
133
+ offset = line.index(%r{\S}) || 1
130
134
  puts "\n #{line.strip}"
131
- printf "%#{message[:column] + 2 - offset}s\n\n", '^'
135
+ printf("%#{message[:column] + 2 - offset}s\n\n", '^')
132
136
  end
133
137
 
134
138
  # Internal: Print the reported problems with a manifest to stdout.
@@ -149,12 +153,14 @@ class PuppetLint
149
153
  message['context'] = get_context(message) if configuration.with_context
150
154
  json << message
151
155
  else
152
- format_message message
156
+ format_message(message)
153
157
  print_context(message) if configuration.with_context
154
158
  end
155
159
  end
156
160
  end
157
161
  puts JSON.pretty_generate(json) if configuration.json
162
+
163
+ $stderr.puts 'Try running `puppet parser validate <file>`' if problems.any? { |p| p[:check] == :syntax }
158
164
  end
159
165
 
160
166
  # Public: Determine if PuppetLint found any errors in the manifest.
@@ -177,9 +183,7 @@ class PuppetLint
177
183
  # Returns nothing.
178
184
  # Raises PuppetLint::NoCodeError if no manifest code has been loaded.
179
185
  def run
180
- if @code.nil?
181
- raise PuppetLint::NoCodeError
182
- end
186
+ raise PuppetLint::NoCodeError if @code.nil?
183
187
 
184
188
  if @code.empty?
185
189
  @problems = []
@@ -198,7 +202,7 @@ class PuppetLint
198
202
  #
199
203
  # Returns nothing.
200
204
  def print_problems
201
- report @problems
205
+ report(@problems)
202
206
  end
203
207
 
204
208
  # Public: Define a new check.