mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Improve linting
This commit is contained in:
parent
565aa23b8f
commit
a7ee7074f9
@ -120,19 +120,31 @@ let detect_unused_enum_constructors (p : program) : unit =
|
||||
in
|
||||
EnumName.Map.iter
|
||||
(fun e_name constructors ->
|
||||
EnumConstructor.Map.iter
|
||||
(fun constructor _ ->
|
||||
if not (EnumConstructor.Set.mem constructor enum_constructors_used)
|
||||
then
|
||||
Errors.format_spanned_warning
|
||||
(snd (EnumConstructor.get_info constructor))
|
||||
"The constructor %a of enumeration %a is never used; maybe it's \
|
||||
unnecessary?"
|
||||
(Cli.format_with_style [ANSITerminal.yellow])
|
||||
(Format.asprintf "\"%a\"" EnumConstructor.format_t constructor)
|
||||
(Cli.format_with_style [ANSITerminal.yellow])
|
||||
(Format.asprintf "\"%a\"" EnumName.format_t e_name))
|
||||
constructors)
|
||||
if
|
||||
EnumConstructor.Map.for_all
|
||||
(fun cons _ ->
|
||||
not (EnumConstructor.Set.mem cons enum_constructors_used))
|
||||
constructors
|
||||
then
|
||||
Errors.format_spanned_warning
|
||||
(snd (EnumName.get_info e_name))
|
||||
"The enumeration %a is never used; maybe it's unnecessary?"
|
||||
(Cli.format_with_style [ANSITerminal.yellow])
|
||||
(Format.asprintf "\"%a\"" EnumName.format_t e_name)
|
||||
else
|
||||
EnumConstructor.Map.iter
|
||||
(fun constructor _ ->
|
||||
if not (EnumConstructor.Set.mem constructor enum_constructors_used)
|
||||
then
|
||||
Errors.format_spanned_warning
|
||||
(snd (EnumConstructor.get_info constructor))
|
||||
"The constructor %a of enumeration %a is never used; maybe \
|
||||
it's unnecessary?"
|
||||
(Cli.format_with_style [ANSITerminal.yellow])
|
||||
(Format.asprintf "\"%a\"" EnumConstructor.format_t constructor)
|
||||
(Cli.format_with_style [ANSITerminal.yellow])
|
||||
(Format.asprintf "\"%a\"" EnumName.format_t e_name))
|
||||
constructors)
|
||||
p.program_ctx.ctx_enums
|
||||
|
||||
let lint_program (p : program) : unit =
|
||||
|
Loading…
Reference in New Issue
Block a user