1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
3module Reporting.Warning where
5import Data.Aeson ((.=))
6import qualified Data.Aeson as Json
9import qualified AST.Module.Name as ModuleName
10import qualified AST.Type as Type
11import qualified Reporting.Annotation as A
12import qualified Reporting.Report as Report
13import qualified Reporting.Render.Type as RenderType
14import qualified Reporting.Helpers as Help
15import Reporting.Helpers ((<>), text)
19-- ALL POSSIBLE WARNINGS
23 = UnusedImport ModuleName.Raw
24 | MissingTypeAnnotation Text Type.Canonical
31toReport :: RenderType.Localizer -> Warning -> Report.Report
32toReport localizer warning =
34 UnusedImport moduleName ->
38 ("Module `" <> ModuleName.toText moduleName <> "` is unused.")
39 (text "Best to remove it. Don't save code quality for later!")
41 MissingTypeAnnotation name inferredType ->
43 "missing type annotation"
45 ("Top-level value " <> Help.functionName name <> " does not have a type annotation.")
47 [ text "I inferred the type annotation so you can copy it into your code:"
48 , RenderType.annotation localizer name inferredType
57toJson :: RenderType.Localizer -> FilePath -> A.Located Warning -> Json.Value
58toJson localizer filePath (A.A region warning) =
60 (maybeRegion, additionalFields) =
61 Report.toJson [] (toReport localizer warning)
65 , "region" .= maybe region id maybeRegion
66 , "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