11{-# LANGUAGE DeriveGeneric #-}
2+ {-# LANGUAGE OverloadedStrings #-}
23{-# LANGUAGE RecordWildCards #-}
34
45module CC.Types where
@@ -7,7 +8,6 @@ import Data.Aeson (ToJSON(..), (.=), genericToJSON, object)
78import Data.Aeson.Types (Pair , Value (Null ), defaultOptions , fieldLabelModifier )
89import Data.Char (isUpper , toLower )
910import GHC.Generics (Generic )
10- import Data.Text (pack )
1111
1212-- | Issues must be associated with one or more categories.
1313data Category = BugRisk
@@ -20,13 +20,13 @@ data Category = BugRisk
2020 deriving Show
2121
2222instance ToJSON Category where
23- toJSON BugRisk = toJSON " Bug Risk"
23+ toJSON BugRisk = " Bug Risk"
2424 toJSON x = toJSON $ show x
2525
2626-- | Line and column numbers are 1-based.
2727data LineColumn = LineColumn {
28- _line :: Int
29- , _column :: Int
28+ _line :: Integer
29+ , _column :: Integer
3030} deriving (Generic , Show )
3131
3232instance ToJSON LineColumn where
@@ -36,18 +36,18 @@ instance ToJSON LineColumn where
3636-- expressed in two ways.
3737data Position = Coords LineColumn
3838 -- ^ Line and column coordinates.
39- | Offset Int
39+ | Offset Integer
4040 -- ^ Absolute character offsets, for the entire source buffer.
4141 deriving Show
4242
4343instance ToJSON Position where
4444 toJSON (Coords x) = toJSON x
45- toJSON (Offset x) = toJSON $ object [ (pack " offset" ) .= x ]
45+ toJSON (Offset x) = object [ " offset" .= x ]
4646
4747-- | Line-based locations emit a beginning and end line number for the issue,
4848-- whereas position-based locations allow more precision.
4949data BeginEnd = PositionBased Position Position
50- | LineBased Int Int
50+ | LineBased Integer Integer
5151 deriving Show
5252
5353instance ToJSON BeginEnd where
@@ -56,18 +56,18 @@ instance ToJSON BeginEnd where
5656 LineBased x y -> f x y
5757 where
5858 f :: (ToJSON a ) => a -> a -> [Pair ]
59- f x y = [ (pack " begin" ) .= x, (pack " end" ) .= y ]
59+ f x y = [ " begin" .= x, " end" .= y ]
6060
6161-- | Locations refer to ranges of a source code file.
6262data Location = Location FilePath BeginEnd deriving Show
6363
6464instance ToJSON Location where
6565 toJSON (Location x y) = object $ case y of
66- PositionBased _ _ -> [ f x, (pack " positions" ) .= y ]
67- LineBased _ _ -> [ f x, (pack " lines" ) .= y ]
66+ PositionBased _ _ -> [ f x, " positions" .= y ]
67+ LineBased _ _ -> [ f x, " lines" .= y ]
6868 where
6969 f :: FilePath -> Pair
70- f = (.=) (pack " path" )
70+ f = (.=) " path"
7171
7272-- | An issue represents a single instance of a real or potential code problem,
7373-- detected by a static analysis Engine.
@@ -76,21 +76,21 @@ data Issue = Issue {
7676 , _description :: String
7777 , _categories :: [Category ]
7878 , _location :: Location
79- , _remediation_points :: Maybe Int
79+ , _remediation_points :: Maybe Integer
8080 , _content :: Maybe String
8181 , _other_locations :: Maybe [Location ]
8282} deriving Show
8383
8484instance ToJSON Issue where
8585 toJSON Issue {.. } = object . withoutNulls $ [
86- pack " type" .= (" issue" :: String )
87- , pack " check_name" .= _check_name
88- , pack " description" .= _description
89- , pack " categories" .= _categories
90- , pack " location" .= _location
91- , pack " remediation_points" .= _remediation_points
92- , pack " content" .= _content
93- , pack " other_locations" .= _other_locations
86+ " type" .= (" issue" :: String )
87+ , " check_name" .= _check_name
88+ , " description" .= _description
89+ , " categories" .= _categories
90+ , " location" .= _location
91+ , " remediation_points" .= _remediation_points
92+ , " content" .= _content
93+ , " other_locations" .= _other_locations
9494 ]
9595 where
9696 withoutNulls :: [(a , Value )] -> [(a , Value )]
0 commit comments