1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
3module Reporting.Warning where
5import Data.Aeson ((.=))
6import qualified Data.Aeson as Json
7import Text.PrettyPrint.ANSI.Leijen (text)
9import qualified AST.Module.Name as ModuleName
10import qualified AST.Type as Type
11import qualified Reporting.Annotation as A
12import qualified Reporting.Error.Helpers as Help
13import qualified Reporting.Report as Report
14import qualified Reporting.Render.Type as RenderType
18-- ALL POSSIBLE WARNINGS
22 = UnusedImport ModuleName.Raw
23 | MissingTypeAnnotation String Type.Canonical
30toReport :: RenderType.Localizer -> Warning -> Report.Report
31toReport localizer warning =
33 UnusedImport moduleName ->
37 ("Module `" ++ ModuleName.toString moduleName ++ "` is unused.")
38 (text "Best to remove it. Don't save code quality for later!")
40 MissingTypeAnnotation name inferredType ->
42 "missing type annotation"
44 ("Top-level value " ++ Help.functionName name ++ " does not have a type annotation.")
46 [ text "I inferred the type annotation so you can copy it into your code:"
47 , RenderType.annotation localizer name inferredType
56toJson :: RenderType.Localizer -> FilePath -> A.Located Warning -> Json.Value
57toJson localizer filePath (A.A region warning) =
59 (maybeRegion, additionalFields) =
60 Report.toJson [] (toReport localizer warning)
64 , "region" .= maybe region id maybeRegion
65 , "type" .= ("warning" :: String)
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