on master help sign in
Update warnings for unused arguments, bindings, etc.
commite92c8269d9dddb243d998f31b218b71ad12c2195 authorEvan Czaplicki <evancz@users.noreply.github.com> dateWed 1 Nov 2017, 00:38 (9 years ago) parent652b118
1 file changed+36−6
src/Reporting/Warning.hs+36−6
src/Reporting/Warning.hs+36−6
@@ -1,13 +1,19 @@
11{-# OPTIONS_GHC -Wall #-}
22{-# LANGUAGE OverloadedStrings #-}
3−module Reporting.Warning where
3+module Reporting.Warning
4+ ( Warning(..)
5+ , Unused(..)
6+ , toReport
7+ , toJson
8+ )
9+ where
410
511import Data.Aeson ((.=))
612import qualified Data.Aeson as Json
713import Data.Text (Text)
814
9−import qualified AST.Module.Name as ModuleName
1015import qualified AST.Type as Type
16+import qualified Elm.Name as N
1117import qualified Reporting.Annotation as A
1218import qualified Reporting.Report as Report
1319import qualified Reporting.Render.Type as RenderType
@@ -20,8 +26,12 @@ import Reporting.Helpers ((<>), text)
2026
2127
2228data Warning
23− = UnusedImport ModuleName.Raw
24− | MissingTypeAnnotation Text Type.Canonical
29+ = UnusedImport N.Name
30+ | UnusedVariable Unused N.Name
31+ | MissingTypeAnnotation Text Type.Canonical
32+
33+
34+data Unused = Argument | Binding
2535
2636
2737
@@ -35,8 +45,28 @@ toReport localizer warning =
3545 Report.report
3646 "unused import"
3747 Nothing
38− ("Module `" <> ModuleName.toText moduleName <> "` is unused.")
39− (text "Best to remove it. Don't save code quality for later!")
48+ ("Nothing from the `" <> moduleName <> "` module is used in this file.")
49+ (text "I recommend removing unused imports.")
50+
51+ UnusedVariable Argument name ->
52+ Report.report
53+ "unused argument"
54+ Nothing
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."
59+ )
60+
61+ UnusedVariable Binding name ->
62+ Report.report
63+ "unused binding"
64+ Nothing
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?"
69+ )
4070
4171 MissingTypeAnnotation name inferredType ->
4272 Report.report