module Hadolint.Config.Configuration
( Configuration (..),
PartialConfiguration (..),
applyPartialConfiguration,
)
where
import Data.Maybe (fromMaybe)
import Control.Applicative
import Data.Coerce (coerce)
import Data.Default
import Data.Text (Text)
import Data.YAML ((.:?), (.!=))
import GHC.Generics (Generic)
import Hadolint.Formatter.Format (OutputFormat (..))
import Hadolint.Rule (RuleCode (..), DLSeverity (..), LabelSchema)
import Language.Docker
import Prettyprinter
import qualified Data.Map as Map
import qualified Data.Set as Set
import qualified Data.YAML as Yaml
data Configuration =
Configuration
{ Configuration -> Bool
noFail :: Bool,
Configuration -> Bool
noColor :: Bool,
Configuration -> Bool
verbose :: Bool,
Configuration -> OutputFormat
format :: OutputFormat,
Configuration -> [RuleCode]
errorRules :: [RuleCode],
Configuration -> [RuleCode]
warningRules :: [RuleCode],
Configuration -> [RuleCode]
infoRules :: [RuleCode],
Configuration -> [RuleCode]
styleRules :: [RuleCode],
Configuration -> [RuleCode]
ignoreRules :: [RuleCode],
Configuration -> Set Registry
allowedRegistries :: Set.Set Registry,
Configuration -> LabelSchema
labelSchema :: LabelSchema,
Configuration -> Bool
strictLabels :: Bool,
Configuration -> Bool
disableIgnorePragma :: Bool,
Configuration -> DLSeverity
failureThreshold :: DLSeverity
}
deriving (Configuration -> Configuration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Configuration -> Configuration -> Bool
$c/= :: Configuration -> Configuration -> Bool
== :: Configuration -> Configuration -> Bool
$c== :: Configuration -> Configuration -> Bool
Eq, Int -> Configuration -> ShowS
[Configuration] -> ShowS
Configuration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Configuration] -> ShowS
$cshowList :: [Configuration] -> ShowS
show :: Configuration -> String
$cshow :: Configuration -> String
showsPrec :: Int -> Configuration -> ShowS
$cshowsPrec :: Int -> Configuration -> ShowS
Show)
instance Default Configuration where
def :: Configuration
def =
Bool
-> Bool
-> Bool
-> OutputFormat
-> [RuleCode]
-> [RuleCode]
-> [RuleCode]
-> [RuleCode]
-> [RuleCode]
-> Set Registry
-> LabelSchema
-> Bool
-> Bool
-> DLSeverity
-> Configuration
Configuration
Bool
False
Bool
False
Bool
False
forall a. Default a => a
def
forall a. Monoid a => a
mempty
forall a. Monoid a => a
mempty
forall a. Monoid a => a
mempty
forall a. Monoid a => a
mempty
forall a. Monoid a => a
mempty
forall a. Monoid a => a
mempty
forall a. Monoid a => a
mempty
Bool
False
Bool
False
forall a. Default a => a
def
applyPartialConfiguration ::
Configuration -> PartialConfiguration -> Configuration
applyPartialConfiguration :: Configuration -> PartialConfiguration -> Configuration
applyPartialConfiguration Configuration
config PartialConfiguration
partial =
Bool
-> Bool
-> Bool
-> OutputFormat
-> [RuleCode]
-> [RuleCode]
-> [RuleCode]
-> [RuleCode]
-> [RuleCode]
-> Set Registry
-> LabelSchema
-> Bool
-> Bool
-> DLSeverity
-> Configuration
Configuration
(forall a. a -> Maybe a -> a
fromMaybe (Configuration -> Bool
noFail Configuration
config) (PartialConfiguration -> Maybe Bool
partialNoFail PartialConfiguration
partial))
(forall a. a -> Maybe a -> a
fromMaybe (Configuration -> Bool
noColor Configuration
config) (PartialConfiguration -> Maybe Bool
partialNoColor PartialConfiguration
partial))
(forall a. a -> Maybe a -> a
fromMaybe (Configuration -> Bool
verbose Configuration
config) (PartialConfiguration -> Maybe Bool
partialVerbose PartialConfiguration
partial))
(forall a. a -> Maybe a -> a
fromMaybe (Configuration -> OutputFormat
format Configuration
config) (PartialConfiguration -> Maybe OutputFormat
partialFormat PartialConfiguration
partial))
(Configuration -> [RuleCode]
errorRules Configuration
config forall a. Semigroup a => a -> a -> a
<> PartialConfiguration -> [RuleCode]
partialErrorRules PartialConfiguration
partial)
(Configuration -> [RuleCode]
warningRules Configuration
config forall a. Semigroup a => a -> a -> a
<> PartialConfiguration -> [RuleCode]
partialWarningRules PartialConfiguration
partial)
(Configuration -> [RuleCode]
infoRules Configuration
config forall a. Semigroup a => a -> a -> a
<> PartialConfiguration -> [RuleCode]
partialInfoRules PartialConfiguration
partial)
(Configuration -> [RuleCode]
styleRules Configuration
config forall a. Semigroup a => a -> a -> a
<> PartialConfiguration -> [RuleCode]
partialStyleRules PartialConfiguration
partial)
(Configuration -> [RuleCode]
ignoreRules Configuration
config forall a. Semigroup a => a -> a -> a
<> PartialConfiguration -> [RuleCode]
partialIgnoreRules PartialConfiguration
partial)
(Configuration -> Set Registry
allowedRegistries Configuration
config forall a. Semigroup a => a -> a -> a
<> PartialConfiguration -> Set Registry
partialAllowedRegistries PartialConfiguration
partial)
(Configuration -> LabelSchema
labelSchema Configuration
config forall a. Semigroup a => a -> a -> a
<> PartialConfiguration -> LabelSchema
partialLabelSchema PartialConfiguration
partial)
(forall a. a -> Maybe a -> a
fromMaybe (Configuration -> Bool
strictLabels Configuration
config) (PartialConfiguration -> Maybe Bool
partialStrictLabels PartialConfiguration
partial))
(forall a. a -> Maybe a -> a
fromMaybe (Configuration -> Bool
disableIgnorePragma Configuration
config) (PartialConfiguration -> Maybe Bool
partialDisableIgnorePragma PartialConfiguration
partial))
(forall a. a -> Maybe a -> a
fromMaybe (Configuration -> DLSeverity
failureThreshold Configuration
config) (PartialConfiguration -> Maybe DLSeverity
partialFailureThreshold PartialConfiguration
partial))
instance Pretty Configuration where
pretty :: forall ann. Configuration -> Doc ann
pretty Configuration
c =
forall ann. Int -> Doc ann -> Doc ann
nest Int
2
( forall ann. [Doc ann] -> Doc ann
vsep
[ Doc ann
"Configuration:",
Doc ann
"no fail:" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty (Configuration -> Bool
noFail Configuration
c),
Doc ann
"no color:" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty (Configuration -> Bool
noColor Configuration
c),
Doc ann
"output format:" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty (Configuration -> OutputFormat
format Configuration
c),
Doc ann
"failure threshold:" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty (Configuration -> DLSeverity
failureThreshold Configuration
c),
forall ann. String -> [RuleCode] -> Doc ann
prettyPrintRulelist String
"error" (Configuration -> [RuleCode]
errorRules Configuration
c),
forall ann. String -> [RuleCode] -> Doc ann
prettyPrintRulelist String
"warning" (Configuration -> [RuleCode]
warningRules Configuration
c),
forall ann. String -> [RuleCode] -> Doc ann
prettyPrintRulelist String
"info" (Configuration -> [RuleCode]
infoRules Configuration
c),
forall ann. String -> [RuleCode] -> Doc ann
prettyPrintRulelist String
"style" (Configuration -> [RuleCode]
styleRules Configuration
c),
forall ann. String -> [RuleCode] -> Doc ann
prettyPrintRulelist String
"ignore" (Configuration -> [RuleCode]
ignoreRules Configuration
c),
Doc ann
"strict labels:" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty (Configuration -> Bool
strictLabels Configuration
c),
forall ann. LabelSchema -> Doc ann
prettyPrintLabelSchema (Configuration -> LabelSchema
labelSchema Configuration
c),
Doc ann
"disable ignore pragma:" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty (Configuration -> Bool
disableIgnorePragma Configuration
c),
forall ann. Set Registry -> Doc ann
prettyPrintRegistries (Configuration -> Set Registry
allowedRegistries Configuration
c)
]
)
prettyPrintRulelist :: String -> [RuleCode] -> Doc ann
prettyPrintRulelist :: forall ann. String -> [RuleCode] -> Doc ann
prettyPrintRulelist String
name [RuleCode]
lst =
forall ann. Int -> Doc ann -> Doc ann
nest Int
2 ((Doc ann
"override" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty String
name forall a. Semigroup a => a -> a -> a
<> Doc ann
":\n") forall a. Semigroup a => a -> a -> a
<> forall a ann. (a -> Doc ann) -> [a] -> Doc ann
prettyPrintList forall a ann. Pretty a => a -> Doc ann
pretty [RuleCode]
lst)
prettyPrintRegistries :: Set.Set Registry -> Doc ann
prettyPrintRegistries :: forall ann. Set Registry -> Doc ann
prettyPrintRegistries Set Registry
regs =
forall ann. Int -> Doc ann -> Doc ann
nest Int
2 ( Doc ann
"allowed registries:\n"
forall a. Semigroup a => a -> a -> a
<> forall a ann. (a -> Doc ann) -> [a] -> Doc ann
prettyPrintList
(\Registry
r -> Doc ann
"-" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty (Registry -> Text
unRegistry Registry
r))
(forall a. Set a -> [a]
Set.toList Set Registry
regs)
)
prettyPrintLabelSchema :: LabelSchema -> Doc ann
prettyPrintLabelSchema :: forall ann. LabelSchema -> Doc ann
prettyPrintLabelSchema LabelSchema
ls =
forall ann. Int -> Doc ann -> Doc ann
nest Int
2 ( Doc ann
"label schema:\n"
forall a. Semigroup a => a -> a -> a
<> forall a ann. (a -> Doc ann) -> [a] -> Doc ann
prettyPrintList
(\(Text
n, LabelType
t) -> forall a ann. Pretty a => a -> Doc ann
pretty Text
n forall a. Semigroup a => a -> a -> a
<> Doc ann
":" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty LabelType
t)
(forall k a. Map k a -> [(k, a)]
Map.toList LabelSchema
ls)
)
prettyPrintList :: (a -> Doc ann) -> [a] -> Doc ann
prettyPrintList :: forall a ann. (a -> Doc ann) -> [a] -> Doc ann
prettyPrintList a -> Doc ann
_ [] = Doc ann
"none"
prettyPrintList a -> Doc ann
prnt [a]
lst = forall ann. [Doc ann] -> Doc ann
vsep (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\a
i -> Doc ann
"-" forall ann. Doc ann -> Doc ann -> Doc ann
<+> a -> Doc ann
prnt a
i) [a]
lst)
data PartialConfiguration =
PartialConfiguration
{ PartialConfiguration -> Maybe Bool
partialNoFail :: Maybe Bool,
PartialConfiguration -> Maybe Bool
partialNoColor :: Maybe Bool,
PartialConfiguration -> Maybe Bool
partialVerbose :: Maybe Bool,
PartialConfiguration -> Maybe OutputFormat
partialFormat :: Maybe OutputFormat,
PartialConfiguration -> [RuleCode]
partialErrorRules :: [RuleCode],
PartialConfiguration -> [RuleCode]
partialWarningRules :: [RuleCode],
PartialConfiguration -> [RuleCode]
partialInfoRules :: [RuleCode],
PartialConfiguration -> [RuleCode]
partialStyleRules :: [RuleCode],
PartialConfiguration -> [RuleCode]
partialIgnoreRules :: [RuleCode],
PartialConfiguration -> Set Registry
partialAllowedRegistries :: Set.Set Registry,
PartialConfiguration -> LabelSchema
partialLabelSchema :: LabelSchema,
PartialConfiguration -> Maybe Bool
partialStrictLabels :: Maybe Bool,
PartialConfiguration -> Maybe Bool
partialDisableIgnorePragma :: Maybe Bool,
PartialConfiguration -> Maybe DLSeverity
partialFailureThreshold :: Maybe DLSeverity
}
deriving (PartialConfiguration -> PartialConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PartialConfiguration -> PartialConfiguration -> Bool
$c/= :: PartialConfiguration -> PartialConfiguration -> Bool
== :: PartialConfiguration -> PartialConfiguration -> Bool
$c== :: PartialConfiguration -> PartialConfiguration -> Bool
Eq, Int -> PartialConfiguration -> ShowS
[PartialConfiguration] -> ShowS
PartialConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PartialConfiguration] -> ShowS
$cshowList :: [PartialConfiguration] -> ShowS
show :: PartialConfiguration -> String
$cshow :: PartialConfiguration -> String
showsPrec :: Int -> PartialConfiguration -> ShowS
$cshowsPrec :: Int -> PartialConfiguration -> ShowS
Show)
instance Semigroup PartialConfiguration where
PartialConfiguration Maybe Bool
a1 Maybe Bool
a2 Maybe Bool
a3 Maybe OutputFormat
a4 [RuleCode]
a5 [RuleCode]
a6 [RuleCode]
a7 [RuleCode]
a8 [RuleCode]
a9 Set Registry
a10 LabelSchema
a11 Maybe Bool
a12 Maybe Bool
a13 Maybe DLSeverity
a14
<> :: PartialConfiguration
-> PartialConfiguration -> PartialConfiguration
<> PartialConfiguration Maybe Bool
b1 Maybe Bool
b2 Maybe Bool
b3 Maybe OutputFormat
b4 [RuleCode]
b5 [RuleCode]
b6 [RuleCode]
b7 [RuleCode]
b8 [RuleCode]
b9 Set Registry
b10 LabelSchema
b11 Maybe Bool
b12 Maybe Bool
b13 Maybe DLSeverity
b14 =
Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe OutputFormat
-> [RuleCode]
-> [RuleCode]
-> [RuleCode]
-> [RuleCode]
-> [RuleCode]
-> Set Registry
-> LabelSchema
-> Maybe Bool
-> Maybe Bool
-> Maybe DLSeverity
-> PartialConfiguration
PartialConfiguration
(Maybe Bool
b1 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe Bool
a1)
(Maybe Bool
b2 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe Bool
a2)
(Maybe Bool
b3 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe Bool
a3)
(Maybe OutputFormat
a4 forall a. Semigroup a => a -> a -> a
<> Maybe OutputFormat
b4)
([RuleCode]
a5 forall a. Semigroup a => a -> a -> a
<> [RuleCode]
b5)
([RuleCode]
a6 forall a. Semigroup a => a -> a -> a
<> [RuleCode]
b6)
([RuleCode]
a7 forall a. Semigroup a => a -> a -> a
<> [RuleCode]
b7)
([RuleCode]
a8 forall a. Semigroup a => a -> a -> a
<> [RuleCode]
b8)
([RuleCode]
a9 forall a. Semigroup a => a -> a -> a
<> [RuleCode]
b9)
(Set Registry
a10 forall a. Semigroup a => a -> a -> a
<> Set Registry
b10)
(LabelSchema
a11 forall a. Semigroup a => a -> a -> a
<> LabelSchema
b11)
(Maybe Bool
b12 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe Bool
a12)
(Maybe Bool
b13 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe Bool
a13)
(Maybe DLSeverity
a14 forall a. Semigroup a => a -> a -> a
<> Maybe DLSeverity
b14)
instance Monoid PartialConfiguration where
mempty :: PartialConfiguration
mempty =
Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe OutputFormat
-> [RuleCode]
-> [RuleCode]
-> [RuleCode]
-> [RuleCode]
-> [RuleCode]
-> Set Registry
-> LabelSchema
-> Maybe Bool
-> Maybe Bool
-> Maybe DLSeverity
-> PartialConfiguration
PartialConfiguration
forall a. Maybe a
Nothing
forall a. Maybe a
Nothing
forall a. Maybe a
Nothing
forall a. Monoid a => a
mempty
forall a. Monoid a => a
mempty
forall a. Monoid a => a
mempty
forall a. Monoid a => a
mempty
forall a. Monoid a => a
mempty
forall a. Monoid a => a
mempty
forall a. Monoid a => a
mempty
forall a. Monoid a => a
mempty
forall a. Maybe a
Nothing
forall a. Maybe a
Nothing
forall a. Monoid a => a
mempty
instance Default PartialConfiguration where
def :: PartialConfiguration
def = forall a. Monoid a => a
mempty
instance Yaml.FromYAML PartialConfiguration where
parseYAML :: Node Pos -> Parser PartialConfiguration
parseYAML = forall a.
String -> (Mapping Pos -> Parser a) -> Node Pos -> Parser a
Yaml.withMap String
"Configuration" forall a b. (a -> b) -> a -> b
$ \Mapping Pos
m -> do
Maybe Bool
partialNoFail <- Mapping Pos
m forall a. FromYAML a => Mapping Pos -> Text -> Parser (Maybe a)
.:? Text
"no-fail" forall a. Parser (Maybe a) -> a -> Parser a
.!= forall a. Maybe a
Nothing
Maybe Bool
partialNoColor <- Mapping Pos
m forall a. FromYAML a => Mapping Pos -> Text -> Parser (Maybe a)
.:? Text
"no-color" forall a. Parser (Maybe a) -> a -> Parser a
.!= forall a. Maybe a
Nothing
Maybe Bool
partialVerbose <- Mapping Pos
m forall a. FromYAML a => Mapping Pos -> Text -> Parser (Maybe a)
.:? Text
"verbose" forall a. Parser (Maybe a) -> a -> Parser a
.!= forall a. Maybe a
Nothing
Maybe OutputFormat
partialFormat <- Mapping Pos
m forall a. FromYAML a => Mapping Pos -> Text -> Parser (Maybe a)
.:? Text
"format"
OverrideConfig
override <- Mapping Pos
m forall a. FromYAML a => Mapping Pos -> Text -> Parser (Maybe a)
.:? Text
"override" forall a. Parser (Maybe a) -> a -> Parser a
.!= forall a. Monoid a => a
mempty
[Text]
ignored <- Mapping Pos
m forall a. FromYAML a => Mapping Pos -> Text -> Parser (Maybe a)
.:? Text
"ignored" forall a. Parser (Maybe a) -> a -> Parser a
.!= forall a. Monoid a => a
mempty
[Text]
trusted <- Mapping Pos
m forall a. FromYAML a => Mapping Pos -> Text -> Parser (Maybe a)
.:? Text
"trustedRegistries" forall a. Parser (Maybe a) -> a -> Parser a
.!= forall a. Monoid a => a
mempty
LabelSchema
partialLabelSchema <- Mapping Pos
m forall a. FromYAML a => Mapping Pos -> Text -> Parser (Maybe a)
.:? Text
"label-schema" forall a. Parser (Maybe a) -> a -> Parser a
.!= forall a. Monoid a => a
mempty
Maybe Bool
partialStrictLabels <- Mapping Pos
m forall a. FromYAML a => Mapping Pos -> Text -> Parser (Maybe a)
.:? Text
"strict-labels" forall a. Parser (Maybe a) -> a -> Parser a
.!= forall a. Maybe a
Nothing
Maybe Bool
partialDisableIgnorePragma <- Mapping Pos
m forall a. FromYAML a => Mapping Pos -> Text -> Parser (Maybe a)
.:? Text
"disable-ignore-pragma" forall a. Parser (Maybe a) -> a -> Parser a
.!= forall a. Maybe a
Nothing
let partialIgnoreRules :: [RuleCode]
partialIgnoreRules = coerce :: forall a b. Coercible a b => a -> b
coerce ([Text]
ignored :: [Text])
partialErrorRules :: [RuleCode]
partialErrorRules = OverrideConfig -> [RuleCode]
overrideErrorRules OverrideConfig
override
partialWarningRules :: [RuleCode]
partialWarningRules = OverrideConfig -> [RuleCode]
overrideWarningRules OverrideConfig
override
partialInfoRules :: [RuleCode]
partialInfoRules = OverrideConfig -> [RuleCode]
overrideInfoRules OverrideConfig
override
partialStyleRules :: [RuleCode]
partialStyleRules = OverrideConfig -> [RuleCode]
overrideStyleRules OverrideConfig
override
partialAllowedRegistries :: Set Registry
partialAllowedRegistries = forall a. Ord a => [a] -> Set a
Set.fromList (coerce :: forall a b. Coercible a b => a -> b
coerce ([Text]
trusted :: [Text]))
Maybe DLSeverity
partialFailureThreshold <- Mapping Pos
m forall a. FromYAML a => Mapping Pos -> Text -> Parser (Maybe a)
.:? Text
"failure-threshold"
forall (m :: * -> *) a. Monad m => a -> m a
return PartialConfiguration {[RuleCode]
Maybe Bool
Maybe DLSeverity
Maybe OutputFormat
Set Registry
LabelSchema
partialFailureThreshold :: Maybe DLSeverity
partialAllowedRegistries :: Set Registry
partialStyleRules :: [RuleCode]
partialInfoRules :: [RuleCode]
partialWarningRules :: [RuleCode]
partialErrorRules :: [RuleCode]
partialIgnoreRules :: [RuleCode]
partialDisableIgnorePragma :: Maybe Bool
partialStrictLabels :: Maybe Bool
partialLabelSchema :: LabelSchema
partialFormat :: Maybe OutputFormat
partialVerbose :: Maybe Bool
partialNoColor :: Maybe Bool
partialNoFail :: Maybe Bool
partialFailureThreshold :: Maybe DLSeverity
partialDisableIgnorePragma :: Maybe Bool
partialStrictLabels :: Maybe Bool
partialLabelSchema :: LabelSchema
partialAllowedRegistries :: Set Registry
partialIgnoreRules :: [RuleCode]
partialStyleRules :: [RuleCode]
partialInfoRules :: [RuleCode]
partialWarningRules :: [RuleCode]
partialErrorRules :: [RuleCode]
partialFormat :: Maybe OutputFormat
partialVerbose :: Maybe Bool
partialNoColor :: Maybe Bool
partialNoFail :: Maybe Bool
..}
data OverrideConfig = OverrideConfig
{ OverrideConfig -> [RuleCode]
overrideErrorRules :: [RuleCode],
OverrideConfig -> [RuleCode]
overrideWarningRules :: [RuleCode],
OverrideConfig -> [RuleCode]
overrideInfoRules :: [RuleCode],
OverrideConfig -> [RuleCode]
overrideStyleRules :: [RuleCode]
}
deriving (Int -> OverrideConfig -> ShowS
[OverrideConfig] -> ShowS
OverrideConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OverrideConfig] -> ShowS
$cshowList :: [OverrideConfig] -> ShowS
show :: OverrideConfig -> String
$cshow :: OverrideConfig -> String
showsPrec :: Int -> OverrideConfig -> ShowS
$cshowsPrec :: Int -> OverrideConfig -> ShowS
Show, OverrideConfig -> OverrideConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OverrideConfig -> OverrideConfig -> Bool
$c/= :: OverrideConfig -> OverrideConfig -> Bool
== :: OverrideConfig -> OverrideConfig -> Bool
$c== :: OverrideConfig -> OverrideConfig -> Bool
Eq, forall x. Rep OverrideConfig x -> OverrideConfig
forall x. OverrideConfig -> Rep OverrideConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OverrideConfig x -> OverrideConfig
$cfrom :: forall x. OverrideConfig -> Rep OverrideConfig x
Generic)
instance Semigroup OverrideConfig where
OverrideConfig [RuleCode]
a1 [RuleCode]
a2 [RuleCode]
a3 [RuleCode]
a4 <> :: OverrideConfig -> OverrideConfig -> OverrideConfig
<> OverrideConfig [RuleCode]
b1 [RuleCode]
b2 [RuleCode]
b3 [RuleCode]
b4 =
[RuleCode]
-> [RuleCode] -> [RuleCode] -> [RuleCode] -> OverrideConfig
OverrideConfig ([RuleCode]
a1 forall a. Semigroup a => a -> a -> a
<> [RuleCode]
b1) ([RuleCode]
a2 forall a. Semigroup a => a -> a -> a
<> [RuleCode]
b2) ([RuleCode]
a3 forall a. Semigroup a => a -> a -> a
<> [RuleCode]
b3) ([RuleCode]
a4 forall a. Semigroup a => a -> a -> a
<> [RuleCode]
b4)
instance Monoid OverrideConfig where
mempty :: OverrideConfig
mempty = [RuleCode]
-> [RuleCode] -> [RuleCode] -> [RuleCode] -> OverrideConfig
OverrideConfig forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty
instance Yaml.FromYAML OverrideConfig where
parseYAML :: Node Pos -> Parser OverrideConfig
parseYAML = forall a.
String -> (Mapping Pos -> Parser a) -> Node Pos -> Parser a
Yaml.withMap String
"OverrideConfig" forall a b. (a -> b) -> a -> b
$ \Mapping Pos
m -> do
[Text]
err <- Mapping Pos
m forall a. FromYAML a => Mapping Pos -> Text -> Parser (Maybe a)
.:? Text
"error" forall a. Parser (Maybe a) -> a -> Parser a
.!= forall a. Monoid a => a
mempty
[Text]
wrn <- Mapping Pos
m forall a. FromYAML a => Mapping Pos -> Text -> Parser (Maybe a)
.:? Text
"warning" forall a. Parser (Maybe a) -> a -> Parser a
.!= forall a. Monoid a => a
mempty
[Text]
inf <- Mapping Pos
m forall a. FromYAML a => Mapping Pos -> Text -> Parser (Maybe a)
.:? Text
"info" forall a. Parser (Maybe a) -> a -> Parser a
.!= forall a. Monoid a => a
mempty
[Text]
sty <- Mapping Pos
m forall a. FromYAML a => Mapping Pos -> Text -> Parser (Maybe a)
.:? Text
"style" forall a. Parser (Maybe a) -> a -> Parser a
.!= forall a. Monoid a => a
mempty
let overrideErrorRules :: [RuleCode]
overrideErrorRules = coerce :: forall a b. Coercible a b => a -> b
coerce ([Text]
err :: [Text])
overrideWarningRules :: [RuleCode]
overrideWarningRules = coerce :: forall a b. Coercible a b => a -> b
coerce ([Text]
wrn :: [Text])
overrideInfoRules :: [RuleCode]
overrideInfoRules = coerce :: forall a b. Coercible a b => a -> b
coerce ([Text]
inf :: [Text])
overrideStyleRules :: [RuleCode]
overrideStyleRules = coerce :: forall a b. Coercible a b => a -> b
coerce ([Text]
sty:: [Text])
forall (m :: * -> *) a. Monad m => a -> m a
return OverrideConfig {[RuleCode]
overrideStyleRules :: [RuleCode]
overrideInfoRules :: [RuleCode]
overrideWarningRules :: [RuleCode]
overrideErrorRules :: [RuleCode]
overrideStyleRules :: [RuleCode]
overrideInfoRules :: [RuleCode]
overrideWarningRules :: [RuleCode]
overrideErrorRules :: [RuleCode]
..}