1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
3module Reporting.Warning
11import Data.Aeson ((.=))
12import qualified Data.Aeson as Json
13import Data.Text (Text)
15import qualified AST.Canonical as Can
16import qualified Elm.Name as N
17import qualified Reporting.Annotation as A
18import qualified Reporting.Report as Report
19import qualified Reporting.Render.Type as RenderType
20import qualified Reporting.Helpers as Help
21import Reporting.Helpers ((<>), text)
25-- ALL POSSIBLE WARNINGS
30 | UnusedVariable Unused N.Name
31 | MissingTypeAnnotation Text Can.Type
34data Unused = Pattern | Binding
41toReport :: RenderType.Localizer -> Warning -> Report.Report
42toReport localizer warning =
44 UnusedImport moduleName ->
48 ("Nothing from the `" <> moduleName <> "` module is used in this file.")
49 (text "I recommend removing unused imports.")
51 UnusedVariable Pattern name ->
55 ("The `" <> name <> "` variable is unused.")
56 ( Help.reflowParagraph $
57 "Maybe this indicates there is a mistake around here? Switching `"
58 <> name <> "` to _ 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?"
71 MissingTypeAnnotation name inferredType ->
73 "missing type annotation"
75 ("Top-level value " <> Help.functionName name <> " does not have a type annotation.")
77 [ text "I inferred the type annotation so you can copy it into your code:"
78 , RenderType.annotation localizer name inferredType
87toJson :: RenderType.Localizer -> FilePath -> A.Located Warning -> Json.Value
88toJson localizer filePath (A.A region warning) =
90 (maybeRegion, additionalFields) =
91 Report.toJson [] (toReport localizer warning)
95 , "region" .= maybe region id maybeRegion
96 , "type" .= ("warning" :: Text)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list