@@ -291,18 +291,34 @@ defmodule Module.ParallelChecker do
291
291
## Warning helpers
292
292
293
293
defp group_warnings ( warnings ) do
294
- warnings
295
- |> Enum . reduce ( % { } , fn { module , warning , location } , acc ->
296
- locations = MapSet . new ( [ location ] )
297
- Map . update ( acc , { module , warning } , locations , & MapSet . put ( & 1 , location ) )
298
- end )
299
- |> Enum . map ( fn { { module , warning } , locations } -> { module , warning , Enum . sort ( locations ) } end )
300
- |> Enum . sort ( )
294
+ { ungrouped , grouped } =
295
+ Enum . reduce ( warnings , { [ ] , % { } } , fn { module , warning , location } , { ungrouped , grouped } ->
296
+ % { message: _ } = diagnostic = module . format_diagnostic ( warning )
297
+
298
+ if Map . get ( diagnostic , :group , false ) do
299
+ locations = MapSet . new ( [ location ] )
300
+
301
+ grouped =
302
+ Map . update ( grouped , warning , { locations , diagnostic } , fn
303
+ { locations , diagnostic } -> { MapSet . put ( locations , location ) , diagnostic }
304
+ end )
305
+
306
+ { ungrouped , grouped }
307
+ else
308
+ { [ { [ location ] , diagnostic } | ungrouped ] , grouped }
309
+ end
310
+ end )
311
+
312
+ grouped =
313
+ Enum . map ( grouped , fn { _warning , { locations , diagnostic } } ->
314
+ { Enum . sort ( locations ) , diagnostic }
315
+ end )
316
+
317
+ Enum . sort ( ungrouped ++ grouped )
301
318
end
302
319
303
320
defp emit_warnings ( warnings , log? ) do
304
- Enum . flat_map ( warnings , fn { module , warning , locations } ->
305
- % { message: _ } = diagnostic = module . format_diagnostic ( warning )
321
+ Enum . flat_map ( warnings , fn { locations , diagnostic } ->
306
322
diagnostics = Enum . map ( locations , & to_diagnostic ( diagnostic , & 1 ) )
307
323
log? and print_diagnostics ( diagnostics )
308
324
diagnostics
0 commit comments