@@ -124,6 +124,7 @@ def format_message(message)
124
124
puts format % message
125
125
126
126
puts " #{ message [ :reason ] } " if message [ :kind ] == :ignored && !message [ :reason ] . nil?
127
+ print_context ( message )
127
128
end
128
129
129
130
# Internal: Format a problem message and print it to STDOUT so GitHub Actions
@@ -154,7 +155,8 @@ def get_context(message)
154
155
def print_context ( message )
155
156
return if message [ :check ] == 'documentation'
156
157
return if message [ :kind ] == :fixed
157
- line = get_context ( message )
158
+ line = message [ :context ]
159
+ return unless line
158
160
offset = line . index ( %r{\S } ) || 1
159
161
puts "\n #{ line . strip } "
160
162
printf ( "%#{ message [ :column ] + 2 - offset } s\n \n " , '^' )
@@ -175,16 +177,16 @@ def report(problems)
175
177
176
178
next unless message [ :kind ] == :fixed || [ message [ :kind ] , :all ] . include? ( configuration . error_level )
177
179
180
+ message [ :context ] = get_context ( message ) if configuration . with_context
181
+
178
182
if configuration . json || configuration . sarif || configuration . codeclimate_report_file
179
- message [ 'context' ] = get_context ( message ) if configuration . with_context
180
183
json << message
181
184
end
182
185
183
- next if configuration . json || configuration . sarif
184
-
185
- format_message ( message )
186
- print_context ( message ) if configuration . with_context
187
- print_github_annotation ( message ) if configuration . github_actions
186
+ unless configuration . json || configuration . sarif
187
+ format_message ( message )
188
+ print_github_annotation ( message ) if configuration . github_actions
189
+ end
188
190
end
189
191
$stderr. puts 'Try running `puppet parser validate <file>`' if problems . any? { |p | p [ :check ] == :syntax }
190
192
json
0 commit comments