puppet-lint 2.5.2 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +522 -0
  3. data/lib/puppet-lint/bin.rb +71 -6
  4. data/lib/puppet-lint/checkplugin.rb +43 -9
  5. data/lib/puppet-lint/checks.rb +16 -16
  6. data/lib/puppet-lint/configuration.rb +134 -134
  7. data/lib/puppet-lint/data.rb +28 -28
  8. data/lib/puppet-lint/lexer/string_slurper.rb +138 -140
  9. data/lib/puppet-lint/lexer/token.rb +188 -190
  10. data/lib/puppet-lint/lexer.rb +416 -417
  11. data/lib/puppet-lint/monkeypatches.rb +1 -1
  12. data/lib/puppet-lint/optparser.rb +5 -1
  13. data/lib/puppet-lint/plugins/check_classes/arrow_on_right_operand_line.rb +6 -4
  14. data/lib/puppet-lint/plugins/check_classes/autoloader_layout.rb +5 -3
  15. data/lib/puppet-lint/plugins/check_classes/class_inherits_from_params_class.rb +6 -4
  16. data/lib/puppet-lint/plugins/check_classes/code_on_top_scope.rb +5 -3
  17. data/lib/puppet-lint/plugins/check_classes/inherits_across_namespaces.rb +5 -3
  18. data/lib/puppet-lint/plugins/check_classes/names_containing_dash.rb +5 -3
  19. data/lib/puppet-lint/plugins/check_classes/names_containing_uppercase.rb +7 -5
  20. data/lib/puppet-lint/plugins/check_classes/nested_classes_or_defines.rb +5 -3
  21. data/lib/puppet-lint/plugins/check_classes/parameter_order.rb +7 -4
  22. data/lib/puppet-lint/plugins/check_classes/right_to_left_relationship.rb +5 -3
  23. data/lib/puppet-lint/plugins/check_classes/variable_scope.rb +15 -13
  24. data/lib/puppet-lint/plugins/check_comments/slash_comments.rb +9 -7
  25. data/lib/puppet-lint/plugins/check_comments/star_comments.rb +10 -8
  26. data/lib/puppet-lint/plugins/check_conditionals/case_without_default.rb +6 -4
  27. data/lib/puppet-lint/plugins/check_conditionals/selector_inside_resource.rb +5 -3
  28. data/lib/puppet-lint/plugins/check_documentation/documentation.rb +7 -3
  29. data/lib/puppet-lint/plugins/check_nodes/unquoted_node_name.rb +15 -11
  30. data/lib/puppet-lint/plugins/check_resources/duplicate_params.rb +5 -3
  31. data/lib/puppet-lint/plugins/check_resources/ensure_first_param.rb +8 -5
  32. data/lib/puppet-lint/plugins/check_resources/ensure_not_symlink_target.rb +11 -8
  33. data/lib/puppet-lint/plugins/check_resources/file_mode.rb +14 -9
  34. data/lib/puppet-lint/plugins/check_resources/unquoted_file_mode.rb +11 -6
  35. data/lib/puppet-lint/plugins/check_resources/unquoted_resource_title.rb +6 -4
  36. data/lib/puppet-lint/plugins/check_strings/double_quoted_strings.rb +12 -7
  37. data/lib/puppet-lint/plugins/check_strings/only_variable_string.rb +8 -6
  38. data/lib/puppet-lint/plugins/check_strings/puppet_url_without_modules.rb +14 -8
  39. data/lib/puppet-lint/plugins/check_strings/quoted_booleans.rb +11 -7
  40. data/lib/puppet-lint/plugins/check_strings/single_quote_string_with_variables.rb +11 -6
  41. data/lib/puppet-lint/plugins/check_strings/variables_not_enclosed.rb +12 -8
  42. data/lib/puppet-lint/plugins/check_variables/variable_contains_dash.rb +11 -7
  43. data/lib/puppet-lint/plugins/check_variables/variable_is_lowercase.rb +11 -7
  44. data/lib/puppet-lint/plugins/check_whitespace/140chars.rb +3 -8
  45. data/lib/puppet-lint/plugins/check_whitespace/2sp_soft_tabs.rb +10 -8
  46. data/lib/puppet-lint/plugins/check_whitespace/80chars.rb +3 -8
  47. data/lib/puppet-lint/plugins/check_whitespace/arrow_alignment.rb +10 -8
  48. data/lib/puppet-lint/plugins/check_whitespace/hard_tabs.rb +11 -7
  49. data/lib/puppet-lint/plugins/check_whitespace/line_length.rb +29 -0
  50. data/lib/puppet-lint/plugins/check_whitespace/trailing_whitespace.rb +13 -7
  51. data/lib/puppet-lint/plugins.rb +60 -61
  52. data/lib/puppet-lint/report/github.rb +17 -0
  53. data/lib/puppet-lint/report/sarif_template.json +63 -0
  54. data/lib/puppet-lint/tasks/puppet-lint.rb +84 -83
  55. data/lib/puppet-lint/tasks/release_test.rb +4 -1
  56. data/lib/puppet-lint/version.rb +1 -1
  57. data/lib/puppet-lint.rb +27 -12
  58. data/spec/acceptance/puppet_lint_spec.rb +46 -0
  59. data/spec/spec_helper.rb +92 -91
  60. data/spec/spec_helper_acceptance.rb +6 -0
  61. data/spec/spec_helper_acceptance_local.rb +38 -0
  62. data/spec/{puppet-lint → unit/puppet-lint}/bin_spec.rb +79 -35
  63. data/spec/{puppet-lint → unit/puppet-lint}/checks_spec.rb +36 -36
  64. data/spec/unit/puppet-lint/configuration_spec.rb +88 -0
  65. data/spec/{puppet-lint → unit/puppet-lint}/data_spec.rb +6 -3
  66. data/spec/{puppet-lint → unit/puppet-lint}/ignore_overrides_spec.rb +17 -17
  67. data/spec/{puppet-lint → unit/puppet-lint}/lexer/string_slurper_spec.rb +128 -128
  68. data/spec/{puppet-lint → unit/puppet-lint}/lexer/token_spec.rb +1 -1
  69. data/spec/{puppet-lint → unit/puppet-lint}/lexer_spec.rb +653 -671
  70. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/arrow_on_right_operand_line_spec.rb +16 -16
  71. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/autoloader_layout_spec.rb +13 -13
  72. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/class_inherits_from_params_class_spec.rb +3 -3
  73. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/code_on_top_scope_spec.rb +4 -4
  74. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/inherits_across_namespaces_spec.rb +4 -4
  75. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/name_contains_uppercase_spec.rb +10 -10
  76. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/names_containing_dash_spec.rb +7 -7
  77. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/nested_classes_or_defines_spec.rb +7 -7
  78. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/parameter_order_spec.rb +9 -9
  79. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/right_to_left_relationship_spec.rb +3 -3
  80. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/variable_scope_spec.rb +25 -25
  81. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_comments/slash_comments_spec.rb +7 -7
  82. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_comments/star_comments_spec.rb +13 -13
  83. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_conditionals/case_without_default_spec.rb +10 -10
  84. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_conditionals/selector_inside_resource_spec.rb +3 -3
  85. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_documentation/documentation_spec.rb +8 -8
  86. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_nodes/unquoted_node_name_spec.rb +24 -24
  87. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_resources/duplicate_params_spec.rb +9 -9
  88. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_resources/ensure_first_param_spec.rb +19 -19
  89. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_resources/ensure_not_symlink_target_spec.rb +10 -10
  90. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_resources/file_mode_spec.rb +40 -40
  91. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_resources/unquoted_file_mode_spec.rb +20 -20
  92. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_resources/unquoted_resource_title_spec.rb +24 -24
  93. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/double_quoted_strings_spec.rb +27 -27
  94. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/only_variable_string_spec.rb +18 -18
  95. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/puppet_url_without_modules_spec.rb +9 -9
  96. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/quoted_booleans_spec.rb +22 -22
  97. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/single_quote_string_with_variables_spec.rb +2 -2
  98. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/variables_not_enclosed_spec.rb +21 -21
  99. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_variables/variable_contains_dash_spec.rb +6 -6
  100. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_variables/variable_is_lowercase_spec.rb +7 -7
  101. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_whitespace/140chars_spec.rb +5 -5
  102. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_whitespace/2sp_soft_tabs_spec.rb +2 -2
  103. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_whitespace/80chars_spec.rb +6 -6
  104. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_whitespace/arrow_alignment_spec.rb +127 -127
  105. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_whitespace/hard_tabs_spec.rb +7 -7
  106. data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_whitespace/trailing_whitespace_spec.rb +15 -15
  107. data/spec/unit/puppet-lint/puppet-lint_spec.rb +18 -0
  108. metadata +63 -119
  109. data/CHANGELOG.md +0 -33
  110. data/HISTORY.md +0 -1130
  111. data/spec/puppet-lint/configuration_spec.rb +0 -66
  112. data/spec/puppet-lint_spec.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc870000b6b86a6ac88d750b7d9e5f8361919f1231e182d16da95149362fbbf2
4
- data.tar.gz: e87e9cb95e7551d3b9f8b468d6bae75a3757f7ed9064cc282802e53def68c78f
3
+ metadata.gz: 780fb18c627fc4498cfbd056762846a70b2240619c52a23121d522b56aaec062
4
+ data.tar.gz: 59068f03812ef0d9b622fa6b9440567ba4e12f33a5349c1ddc9c642ac7dd51a5
5
5
  SHA512:
6
- metadata.gz: 8de55ea678a000a3a977f181d2f7bb33671cde2d9c39efd0e3cbb1345176f02a9d159b054c6ac3e7a21e3d673814893ae3992ba3151704ea26f1ec2905b9ffc8
7
- data.tar.gz: 2b3ff2d9f878c065a048cf375e3e1844d2fbb70816c24fb14922b4aa3cf435fd9cb34d3313982c5d130ca8ca0fb7493189a2be8c1000ec3fa246c3b5dbd26a7b
6
+ metadata.gz: 32fb18937f47636f80535bcc8db5884aa63a6af9a86f148ee25a37b65890d13f275094ab2a81012a5ef7385d696195c59632d234eca805c94a2bc2d3b4d77905
7
+ data.tar.gz: 124a921b4ad50b3f923f7180d330a89f313f70c5b77d1dcf8060611a124171e1bf3ef06f8b3d4b27421cad4157c69699c12bc8acc8dd63461a61fb1aecacc14c
data/.rubocop.yml ADDED
@@ -0,0 +1,522 @@
1
+ ---
2
+ require:
3
+ - rubocop-performance
4
+ - rubocop-rspec
5
+ AllCops:
6
+ DisplayCopNames: true
7
+ TargetRubyVersion: '2.6'
8
+ SuggestExtensions: false
9
+ Include:
10
+ - "**/*.rb"
11
+ Exclude:
12
+ - bin/*
13
+ - ".vendor/**/*"
14
+ - "**/Gemfile"
15
+ - "**/Rakefile"
16
+ - pkg/**/*
17
+ - spec/fixtures/**/*
18
+ - vendor/**/*
19
+ - "**/Puppetfile"
20
+ - "**/Vagrantfile"
21
+ - "**/Guardfile"
22
+ Layout/LineLength:
23
+ Description: People have wide screens, use them.
24
+ Max: 200
25
+ RSpec/BeforeAfterAll:
26
+ Description: Beware of using after(:all) as it may cause state to leak between tests.
27
+ A necessary evil in acceptance testing.
28
+ Exclude:
29
+ - spec/acceptance/**/*.rb
30
+ RSpec/HookArgument:
31
+ Description: Prefer explicit :each argument, matching existing module's style
32
+ EnforcedStyle: each
33
+ RSpec/DescribeSymbol:
34
+ Exclude:
35
+ - spec/unit/facter/**/*.rb
36
+ Style/BlockDelimiters:
37
+ Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to
38
+ be consistent then.
39
+ EnforcedStyle: braces_for_chaining
40
+ Style/ClassAndModuleChildren:
41
+ Description: Compact style reduces the required amount of indentation.
42
+ EnforcedStyle: compact
43
+ Style/EmptyElse:
44
+ Description: Enforce against empty else clauses, but allow `nil` for clarity.
45
+ EnforcedStyle: empty
46
+ Style/FormatString:
47
+ Description: Following the main puppet project's style, prefer the % format format.
48
+ EnforcedStyle: percent
49
+ Style/FormatStringToken:
50
+ Description: Following the main puppet project's style, prefer the simpler template
51
+ tokens over annotated ones.
52
+ EnforcedStyle: template
53
+ Style/Lambda:
54
+ Description: Prefer the keyword for easier discoverability.
55
+ EnforcedStyle: literal
56
+ Style/RegexpLiteral:
57
+ Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168
58
+ EnforcedStyle: percent_r
59
+ Style/TernaryParentheses:
60
+ Description: Checks for use of parentheses around ternary conditions. Enforce parentheses
61
+ on complex expressions for better readability, but seriously consider breaking
62
+ it up.
63
+ EnforcedStyle: require_parentheses_when_complex
64
+ Style/TrailingCommaInArguments:
65
+ Description: Prefer always trailing comma on multiline argument lists. This makes
66
+ diffs, and re-ordering nicer.
67
+ EnforcedStyleForMultiline: comma
68
+ Style/TrailingCommaInArrayLiteral:
69
+ Description: Prefer always trailing comma on multiline literals. This makes diffs,
70
+ and re-ordering nicer.
71
+ EnforcedStyleForMultiline: comma
72
+ Style/SymbolArray:
73
+ Description: Using percent style obscures symbolic intent of array's contents.
74
+ EnforcedStyle: brackets
75
+ RSpec/MessageSpies:
76
+ EnforcedStyle: receive
77
+ Style/Documentation:
78
+ Exclude:
79
+ - lib/puppet/parser/functions/**/*
80
+ - spec/**/*
81
+ Style/WordArray:
82
+ EnforcedStyle: brackets
83
+ Performance/AncestorsInclude:
84
+ Enabled: true
85
+ Performance/BigDecimalWithNumericArgument:
86
+ Enabled: true
87
+ Performance/BlockGivenWithExplicitBlock:
88
+ Enabled: true
89
+ Performance/CaseWhenSplat:
90
+ Enabled: true
91
+ Performance/ConstantRegexp:
92
+ Enabled: true
93
+ Performance/MethodObjectAsBlock:
94
+ Enabled: true
95
+ Performance/RedundantSortBlock:
96
+ Enabled: true
97
+ Performance/RedundantStringChars:
98
+ Enabled: true
99
+ Performance/ReverseFirst:
100
+ Enabled: true
101
+ Performance/SortReverse:
102
+ Enabled: true
103
+ Performance/Squeeze:
104
+ Enabled: true
105
+ Performance/StringInclude:
106
+ Enabled: true
107
+ Performance/Sum:
108
+ Enabled: true
109
+ Style/CollectionMethods:
110
+ Enabled: true
111
+ Style/MethodCalledOnDoEndBlock:
112
+ Enabled: true
113
+ Style/StringMethods:
114
+ Enabled: true
115
+ Bundler/InsecureProtocolSource:
116
+ Enabled: false
117
+ Gemspec/DuplicatedAssignment:
118
+ Enabled: false
119
+ Gemspec/OrderedDependencies:
120
+ Enabled: false
121
+ Gemspec/RequiredRubyVersion:
122
+ Enabled: false
123
+ Gemspec/RubyVersionGlobalsUsage:
124
+ Enabled: false
125
+ Layout/ArgumentAlignment:
126
+ Enabled: false
127
+ Layout/BeginEndAlignment:
128
+ Enabled: false
129
+ Layout/ClosingHeredocIndentation:
130
+ Enabled: false
131
+ Layout/EmptyComment:
132
+ Enabled: false
133
+ Layout/EmptyLineAfterGuardClause:
134
+ Enabled: false
135
+ Layout/EmptyLinesAroundArguments:
136
+ Enabled: false
137
+ Layout/EmptyLinesAroundAttributeAccessor:
138
+ Enabled: false
139
+ Layout/EndOfLine:
140
+ Enabled: false
141
+ Layout/FirstArgumentIndentation:
142
+ Enabled: false
143
+ Layout/HashAlignment:
144
+ Enabled: false
145
+ Layout/HeredocIndentation:
146
+ Enabled: false
147
+ Layout/LeadingEmptyLines:
148
+ Enabled: false
149
+ Layout/SpaceAroundMethodCallOperator:
150
+ Enabled: false
151
+ Layout/SpaceInsideArrayLiteralBrackets:
152
+ Enabled: false
153
+ Layout/SpaceInsideReferenceBrackets:
154
+ Enabled: false
155
+ Lint/BigDecimalNew:
156
+ Enabled: false
157
+ Lint/BooleanSymbol:
158
+ Enabled: false
159
+ Lint/ConstantDefinitionInBlock:
160
+ Enabled: false
161
+ Lint/DeprecatedOpenSSLConstant:
162
+ Enabled: false
163
+ Lint/DisjunctiveAssignmentInConstructor:
164
+ Enabled: false
165
+ Lint/DuplicateElsifCondition:
166
+ Enabled: false
167
+ Lint/DuplicateRequire:
168
+ Enabled: false
169
+ Lint/DuplicateRescueException:
170
+ Enabled: false
171
+ Lint/EmptyConditionalBody:
172
+ Enabled: false
173
+ Lint/EmptyFile:
174
+ Enabled: false
175
+ Lint/ErbNewArguments:
176
+ Enabled: false
177
+ Lint/FloatComparison:
178
+ Enabled: false
179
+ Lint/HashCompareByIdentity:
180
+ Enabled: false
181
+ Lint/IdentityComparison:
182
+ Enabled: false
183
+ Lint/InterpolationCheck:
184
+ Enabled: false
185
+ Lint/MissingCopEnableDirective:
186
+ Enabled: false
187
+ Lint/MixedRegexpCaptureTypes:
188
+ Enabled: false
189
+ Lint/NestedPercentLiteral:
190
+ Enabled: false
191
+ Lint/NonDeterministicRequireOrder:
192
+ Enabled: false
193
+ Lint/OrderedMagicComments:
194
+ Enabled: false
195
+ Lint/OutOfRangeRegexpRef:
196
+ Enabled: false
197
+ Lint/RaiseException:
198
+ Enabled: false
199
+ Lint/RedundantCopEnableDirective:
200
+ Enabled: false
201
+ Lint/RedundantRequireStatement:
202
+ Enabled: false
203
+ Lint/RedundantSafeNavigation:
204
+ Enabled: false
205
+ Lint/RedundantWithIndex:
206
+ Enabled: false
207
+ Lint/RedundantWithObject:
208
+ Enabled: false
209
+ Lint/RegexpAsCondition:
210
+ Enabled: false
211
+ Lint/ReturnInVoidContext:
212
+ Enabled: false
213
+ Lint/SafeNavigationConsistency:
214
+ Enabled: false
215
+ Lint/SafeNavigationWithEmpty:
216
+ Enabled: false
217
+ Lint/SelfAssignment:
218
+ Enabled: false
219
+ Lint/SendWithMixinArgument:
220
+ Enabled: false
221
+ Lint/ShadowedArgument:
222
+ Enabled: false
223
+ Lint/StructNewOverride:
224
+ Enabled: false
225
+ Lint/ToJSON:
226
+ Enabled: false
227
+ Lint/TopLevelReturnWithArgument:
228
+ Enabled: false
229
+ Lint/TrailingCommaInAttributeDeclaration:
230
+ Enabled: false
231
+ Lint/UnreachableLoop:
232
+ Enabled: false
233
+ Lint/UriEscapeUnescape:
234
+ Enabled: false
235
+ Lint/UriRegexp:
236
+ Enabled: false
237
+ Lint/UselessMethodDefinition:
238
+ Enabled: false
239
+ Lint/UselessTimes:
240
+ Enabled: false
241
+ Metrics/AbcSize:
242
+ Enabled: false
243
+ Metrics/BlockLength:
244
+ Enabled: false
245
+ Metrics/BlockNesting:
246
+ Enabled: false
247
+ Metrics/ClassLength:
248
+ Enabled: false
249
+ Metrics/CyclomaticComplexity:
250
+ Enabled: false
251
+ Metrics/MethodLength:
252
+ Enabled: false
253
+ Metrics/ModuleLength:
254
+ Enabled: false
255
+ Metrics/ParameterLists:
256
+ Enabled: false
257
+ Metrics/PerceivedComplexity:
258
+ Enabled: false
259
+ Migration/DepartmentName:
260
+ Enabled: false
261
+ Naming/AccessorMethodName:
262
+ Enabled: false
263
+ Naming/BlockParameterName:
264
+ Enabled: false
265
+ Naming/HeredocDelimiterCase:
266
+ Enabled: false
267
+ Naming/HeredocDelimiterNaming:
268
+ Enabled: false
269
+ Naming/MemoizedInstanceVariableName:
270
+ Enabled: false
271
+ Naming/MethodParameterName:
272
+ Enabled: false
273
+ Naming/RescuedExceptionsVariableName:
274
+ Enabled: false
275
+ Naming/VariableNumber:
276
+ Enabled: false
277
+ Performance/BindCall:
278
+ Enabled: false
279
+ Performance/DeletePrefix:
280
+ Enabled: false
281
+ Performance/DeleteSuffix:
282
+ Enabled: false
283
+ Performance/InefficientHashSearch:
284
+ Enabled: false
285
+ Performance/UnfreezeString:
286
+ Enabled: false
287
+ Performance/UriDefaultParser:
288
+ Enabled: false
289
+ RSpec/Be:
290
+ Enabled: false
291
+ RSpec/Capybara/CurrentPathExpectation:
292
+ Enabled: false
293
+ RSpec/Capybara/FeatureMethods:
294
+ Enabled: false
295
+ RSpec/Capybara/VisibilityMatcher:
296
+ Enabled: false
297
+ RSpec/ContextMethod:
298
+ Enabled: false
299
+ RSpec/ContextWording:
300
+ Enabled: false
301
+ RSpec/DescribeClass:
302
+ Enabled: false
303
+ RSpec/EmptyHook:
304
+ Enabled: false
305
+ RSpec/EmptyLineAfterExample:
306
+ Enabled: false
307
+ RSpec/EmptyLineAfterExampleGroup:
308
+ Enabled: false
309
+ RSpec/EmptyLineAfterHook:
310
+ Enabled: false
311
+ RSpec/ExampleLength:
312
+ Enabled: false
313
+ RSpec/ExampleWithoutDescription:
314
+ Enabled: false
315
+ RSpec/ExpectChange:
316
+ Enabled: false
317
+ RSpec/ExpectInHook:
318
+ Enabled: false
319
+ RSpec/FactoryBot/AttributeDefinedStatically:
320
+ Enabled: false
321
+ RSpec/FactoryBot/CreateList:
322
+ Enabled: false
323
+ RSpec/FactoryBot/FactoryClassName:
324
+ Enabled: false
325
+ RSpec/HooksBeforeExamples:
326
+ Enabled: false
327
+ RSpec/ImplicitBlockExpectation:
328
+ Enabled: false
329
+ RSpec/ImplicitSubject:
330
+ Enabled: false
331
+ RSpec/LeakyConstantDeclaration:
332
+ Enabled: false
333
+ RSpec/LetBeforeExamples:
334
+ Enabled: false
335
+ RSpec/MissingExampleGroupArgument:
336
+ Enabled: false
337
+ RSpec/MultipleExpectations:
338
+ Enabled: false
339
+ RSpec/MultipleMemoizedHelpers:
340
+ Enabled: false
341
+ RSpec/MultipleSubjects:
342
+ Enabled: false
343
+ RSpec/NestedGroups:
344
+ Enabled: false
345
+ RSpec/PredicateMatcher:
346
+ Enabled: false
347
+ RSpec/ReceiveCounts:
348
+ Enabled: false
349
+ RSpec/ReceiveNever:
350
+ Enabled: false
351
+ RSpec/RepeatedExampleGroupBody:
352
+ Enabled: false
353
+ RSpec/RepeatedExampleGroupDescription:
354
+ Enabled: false
355
+ RSpec/RepeatedIncludeExample:
356
+ Enabled: false
357
+ RSpec/ReturnFromStub:
358
+ Enabled: false
359
+ RSpec/SharedExamples:
360
+ Enabled: false
361
+ RSpec/StubbedMock:
362
+ Enabled: false
363
+ RSpec/UnspecifiedException:
364
+ Enabled: false
365
+ RSpec/VariableDefinition:
366
+ Enabled: false
367
+ RSpec/VoidExpect:
368
+ Enabled: false
369
+ RSpec/Yield:
370
+ Enabled: false
371
+ Security/Open:
372
+ Enabled: false
373
+ Style/AccessModifierDeclarations:
374
+ Enabled: false
375
+ Style/AccessorGrouping:
376
+ Enabled: false
377
+ Style/AsciiComments:
378
+ Enabled: false
379
+ Style/BisectedAttrAccessor:
380
+ Enabled: false
381
+ Style/CaseLikeIf:
382
+ Enabled: false
383
+ Style/ClassEqualityComparison:
384
+ Enabled: false
385
+ Style/ColonMethodDefinition:
386
+ Enabled: false
387
+ Style/CombinableLoops:
388
+ Enabled: false
389
+ Style/CommentedKeyword:
390
+ Enabled: false
391
+ Style/Dir:
392
+ Enabled: false
393
+ Style/DoubleCopDisableDirective:
394
+ Enabled: false
395
+ Style/EmptyBlockParameter:
396
+ Enabled: false
397
+ Style/EmptyLambdaParameter:
398
+ Enabled: false
399
+ Style/Encoding:
400
+ Enabled: false
401
+ Style/EvalWithLocation:
402
+ Enabled: false
403
+ Style/ExpandPathArguments:
404
+ Enabled: false
405
+ Style/ExplicitBlockArgument:
406
+ Enabled: false
407
+ Style/ExponentialNotation:
408
+ Enabled: false
409
+ Style/FloatDivision:
410
+ Enabled: false
411
+ Style/FrozenStringLiteralComment:
412
+ Enabled: false
413
+ Style/GlobalStdStream:
414
+ Enabled: false
415
+ Style/HashAsLastArrayItem:
416
+ Enabled: false
417
+ Style/HashLikeCase:
418
+ Enabled: false
419
+ Style/HashTransformKeys:
420
+ Enabled: false
421
+ Style/HashTransformValues:
422
+ Enabled: false
423
+ Style/IfUnlessModifier:
424
+ Enabled: false
425
+ Style/KeywordParametersOrder:
426
+ Enabled: false
427
+ Style/MinMax:
428
+ Enabled: false
429
+ Style/MixinUsage:
430
+ Enabled: false
431
+ Style/MultilineWhenThen:
432
+ Enabled: false
433
+ Style/NegatedUnless:
434
+ Enabled: false
435
+ Style/NumericPredicate:
436
+ Enabled: false
437
+ Style/OptionalBooleanParameter:
438
+ Enabled: false
439
+ Style/OrAssignment:
440
+ Enabled: false
441
+ Style/RandomWithOffset:
442
+ Enabled: false
443
+ Style/RedundantAssignment:
444
+ Enabled: false
445
+ Style/RedundantCondition:
446
+ Enabled: false
447
+ Style/RedundantConditional:
448
+ Enabled: false
449
+ Style/RedundantFetchBlock:
450
+ Enabled: false
451
+ Style/RedundantFileExtensionInRequire:
452
+ Enabled: false
453
+ Style/RedundantRegexpCharacterClass:
454
+ Enabled: false
455
+ Style/RedundantRegexpEscape:
456
+ Enabled: false
457
+ Style/RedundantSelfAssignment:
458
+ Enabled: false
459
+ Style/RedundantSort:
460
+ Enabled: false
461
+ Style/RescueStandardError:
462
+ Enabled: false
463
+ Style/SingleArgumentDig:
464
+ Enabled: false
465
+ Style/SlicingWithRange:
466
+ Enabled: false
467
+ Style/SoleNestedConditional:
468
+ Enabled: false
469
+ Style/StderrPuts:
470
+ Enabled: false
471
+ Style/StringConcatenation:
472
+ Enabled: false
473
+ Style/Strip:
474
+ Enabled: false
475
+ Style/SymbolProc:
476
+ Enabled: false
477
+ Style/TrailingBodyOnClass:
478
+ Enabled: false
479
+ Style/TrailingBodyOnMethodDefinition:
480
+ Enabled: false
481
+ Style/TrailingBodyOnModule:
482
+ Enabled: false
483
+ Style/TrailingCommaInHashLiteral:
484
+ Enabled: false
485
+ Style/TrailingMethodEndStatement:
486
+ Enabled: false
487
+ Style/UnpackFirst:
488
+ Enabled: false
489
+ Lint/DuplicateBranch:
490
+ Enabled: false
491
+ Lint/DuplicateRegexpCharacterClassElement:
492
+ Enabled: false
493
+ Lint/EmptyBlock:
494
+ Enabled: false
495
+ Lint/EmptyClass:
496
+ Enabled: false
497
+ Lint/NoReturnInBeginEndBlocks:
498
+ Enabled: false
499
+ Lint/ToEnumArguments:
500
+ Enabled: false
501
+ Lint/UnexpectedBlockArity:
502
+ Enabled: false
503
+ Lint/UnmodifiedReduceAccumulator:
504
+ Enabled: false
505
+ Performance/CollectionLiteralInLoop:
506
+ Enabled: false
507
+ Style/ArgumentsForwarding:
508
+ Enabled: false
509
+ Style/CollectionCompact:
510
+ Enabled: false
511
+ Style/DocumentDynamicEvalDefinition:
512
+ Enabled: false
513
+ Style/NegatedIfElseCondition:
514
+ Enabled: false
515
+ Style/NilLambda:
516
+ Enabled: false
517
+ Style/RedundantArgument:
518
+ Enabled: false
519
+ Style/SwapValues:
520
+ Enabled: false
521
+ RSpec/FilePath:
522
+ Enabled: false
@@ -1,3 +1,5 @@
1
+ require 'pathname'
2
+ require 'uri'
1
3
  require 'puppet-lint/optparser'
2
4
 
3
5
  # Internal: The logic of the puppet-lint bin script, contained in a class for
@@ -46,6 +48,21 @@ class PuppetLint::Bin
46
48
 
47
49
  begin
48
50
  path = @args[0]
51
+ full_path = File.expand_path(path, ENV['PWD'])
52
+ full_base_path = if File.directory?(full_path)
53
+ full_path
54
+ else
55
+ File.dirname(full_path)
56
+ end
57
+
58
+ full_base_path_uri = if full_base_path.start_with?('/')
59
+ 'file://' + full_base_path
60
+ else
61
+ 'file:///' + full_base_path
62
+ end
63
+
64
+ full_base_path_uri += '/' unless full_base_path_uri.end_with?('/')
65
+
49
66
  path = path.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
50
67
  path = if File.directory?(path)
51
68
  Dir.glob("#{path}/**/*.pp")
@@ -57,15 +74,14 @@ class PuppetLint::Bin
57
74
 
58
75
  return_val = 0
59
76
  ignore_paths = PuppetLint.configuration.ignore_paths
77
+ all_problems = []
60
78
 
61
- puts '[' if PuppetLint.configuration.json
62
79
  path.each do |f|
63
80
  next if ignore_paths.any? { |p| File.fnmatch(p, f) }
64
81
  l = PuppetLint.new
65
82
  l.file = f
66
83
  l.run
67
- l.print_problems
68
- puts ',' if f != path.last && PuppetLint.configuration.json
84
+ all_problems << l.print_problems
69
85
 
70
86
  if l.errors? || (l.warnings? && PuppetLint.configuration.fail_on_warnings)
71
87
  return_val = 1
@@ -76,13 +92,62 @@ class PuppetLint::Bin
76
92
  fd.write(l.manifest)
77
93
  end
78
94
  end
79
- puts ']' if PuppetLint.configuration.json
80
95
 
81
- return return_val
96
+ if PuppetLint.configuration.sarif
97
+ report_sarif(all_problems, full_base_path, full_base_path_uri)
98
+ elsif PuppetLint.configuration.json
99
+ all_problems.each do |problems|
100
+ problems.each do |problem|
101
+ problem.delete_if { |key, _| [:description, :help_uri].include?(key) }
102
+ end
103
+ end
104
+ puts JSON.pretty_generate(all_problems)
105
+ end
106
+
107
+ return_val
82
108
  rescue PuppetLint::NoCodeError
83
109
  puts 'puppet-lint: no file specified or specified file does not exist'
84
110
  puts "puppet-lint: try 'puppet-lint --help' for more information"
85
- return 1
111
+ 1
112
+ end
113
+ end
114
+
115
+ # Internal: Print the reported problems in SARIF format to stdout.
116
+ #
117
+ # problems - An Array of problem Hashes as returned by
118
+ # PuppetLint::Checks#run.
119
+ #
120
+ # Returns nothing.
121
+ def report_sarif(problems, base_path, base_path_uri)
122
+ sarif_file = File.read(File.join(__dir__, 'report', 'sarif_template.json'))
123
+ sarif = JSON.parse(sarif_file)
124
+ sarif['runs'][0]['originalUriBaseIds']['ROOTPATH']['uri'] = base_path_uri
125
+ rules = sarif['runs'][0]['tool']['driver']['rules'] = []
126
+ results = sarif['runs'][0]['results'] = []
127
+ problems.each do |messages|
128
+ messages.each do |message|
129
+ relative_path = Pathname.new(message[:fullpath]).relative_path_from(Pathname.new(base_path))
130
+ rules = sarif['runs'][0]['tool']['driver']['rules']
131
+ rule_exists = rules.any? { |r| r['id'] == message[:check] }
132
+ unless rule_exists
133
+ new_rule = { 'id' => message[:check] }
134
+ new_rule['fullDescription'] = { 'text' => message[:description] } unless message[:description].nil?
135
+ new_rule['fullDescription'] = { 'text' => 'Check for any syntax error and record an error of each instance found.' } if new_rule['fullDescription'].nil? && message[:check] == :syntax
136
+ new_rule['defaultConfiguration'] = { 'level' => message[:KIND].downcase } if ['error', 'warning'].include?(message[:KIND].downcase)
137
+ new_rule['helpUri'] = message[:help_uri] unless message[:help_uri].nil?
138
+ rules << new_rule
139
+ end
140
+ rule_index = rules.index { |r| r['id'] == message[:check] }
141
+ result = {
142
+ 'ruleId' => message[:check],
143
+ 'ruleIndex' => rule_index,
144
+ 'message' => { 'text' => message[:message] },
145
+ 'locations' => [{ 'physicalLocation' => { 'artifactLocation' => { 'uri' => relative_path, 'uriBaseId' => 'ROOTPATH' },
146
+ 'region' => { 'startLine' => message[:line], 'startColumn' => message[:column] } } }],
147
+ }
148
+ results << result
149
+ end
86
150
  end
151
+ puts JSON.pretty_generate(sarif)
87
152
  end
88
153
  end