@@ -1,13 +1,19 @@
1{-# OPTIONS_GHC -Wall #-}
1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE OverloadedStrings #-}
3−module Reporting.Warning where
3+module Reporting.Warning
5import Data.Aeson ((.=))
11import Data.Aeson ((.=))
6import qualified Data.Aeson as Json
12import qualified Data.Aeson as Json
7import Data.Text (Text)
13import Data.Text (Text)
9−import qualified AST.Module.Name as ModuleName
10import qualified AST.Type as Type
15import qualified AST.Type as Type
16+import qualified Elm.Name as N
11import qualified Reporting.Annotation as A
17import qualified Reporting.Annotation as A
12import qualified Reporting.Report as Report
18import qualified Reporting.Report as Report
13import qualified Reporting.Render.Type as RenderType
19import qualified Reporting.Render.Type as RenderType
@@ -20,8 +26,12 @@ import Reporting.Helpers ((<>), text)
22data Warning
28data Warning
23− = UnusedImport ModuleName.Raw
29+ = UnusedImport N.Name
30+ | UnusedVariable Unused N.Name
24− | MissingTypeAnnotation Text Type.Canonical
31+ | MissingTypeAnnotation Text Type.Canonical
34+data Unused = Argument | Binding
@@ -35,8 +45,28 @@ toReport localizer warning =
35 Report.report
45 Report.report
36 "unused import"
46 "unused import"
38− ("Module `" <> ModuleName.toText moduleName <> "` is unused.")
48+ ("Nothing from the `" <> moduleName <> "` module is used in this file.")
39− (text "Best to remove it. Don't save code quality for later!")
49+ (text "I recommend removing unused imports.")
51+ UnusedVariable Argument name ->
55+ ("The `" <> name <> "` argument is unused.")
56+ ( Help.reflowParagraph $
57+ "Maybe this indicates there is a mistake around here? Switching the\
58+ \ argument to a _ will indicate that it is intentionally unused."
61+ UnusedVariable Binding name ->
65+ ("The `" <> name <> "` binding is unused.")
66+ ( Help.reflowParagraph $
67+ "Maybe this indicates there is a mistake around here? Or maybe it\
68+ \ just is not used anymore and should be removed?"
41 MissingTypeAnnotation name inferredType ->
71 MissingTypeAnnotation name inferredType ->
42 Report.report
72 Report.report