Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
walint
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
hub
walint
Commits
24a0763b
Commit
24a0763b
authored
3 years ago
by
stuebinm
Browse files
Options
Downloads
Patches
Plain Diff
add some simple config options
parent
34e66b3a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/LintConfig.hs
+30
-9
30 additions, 9 deletions
lib/LintConfig.hs
with
30 additions
and
9 deletions
lib/LintConfig.hs
+
30
−
9
View file @
24a0763b
...
...
@@ -13,13 +13,14 @@ module LintConfig where
import
Control.Monad.Identity
(
Identity
)
import
Data.Aeson
(
FromJSON
(
parseJSON
),
defaultOptions
,
eitherDecode
)
eitherDecode
,
Options
(
..
)
)
import
Data.Aeson.Types
(
genericParseJSON
)
import
qualified
Data.ByteString.Char8
as
C8
import
qualified
Data.ByteString.Lazy
as
LB
import
Data.Text
(
Text
)
import
GHC.Generics
(
Generic
(
Rep
,
from
,
to
),
K1
(
..
),
M1
(
..
),
(
:*:
)
(
..
))
import
Types
(
Level
)
import
WithCli
(
Proxy
(
..
))
import
WithCli.Pure
(
Argument
(
argumentType
,
parseArgument
))
...
...
@@ -28,26 +29,46 @@ type family HKD f a where
HKD
Identity
a
=
a
HKD
f
a
=
f
a
data
LintConfig
f
=
LintConfig
{
assemblies
::
HKD
f
[
Text
]
,
scriptInject
::
HKD
f
(
Maybe
Text
)
{
configScriptInject
::
HKD
f
(
Maybe
Text
)
,
configAssemblyTag
::
HKD
f
Text
,
configMaxWarnLevel
::
HKD
f
Level
}
deriving
(
Generic
)
type
LintConfig'
=
LintConfig
Identity
deriving
instance
(
Show
(
HKD
a
(
Maybe
Text
)),
Show
(
HKD
a
[
Text
]))
-- TODO: should probably find a way to write these constraints nicer ...
deriving
instance
(
Show
(
HKD
a
(
Maybe
Text
))
,
Show
(
HKD
a
Text
)
,
Show
(
HKD
a
Level
)
,
Show
(
HKD
a
[
Text
])
)
=>
Show
(
LintConfig
a
)
instance
(
FromJSON
(
HKD
a
(
Maybe
Text
)),
FromJSON
(
HKD
a
[
Text
]))
=>
FromJSON
(
LintConfig
a
)
where
parseJSON
=
genericParseJSON
defaultOptions
aesonOptions
::
Options
aesonOptions
=
defaultOptions
{
omitNothingFields
=
True
,
rejectUnknownFields
=
True
,
fieldLabelModifier
=
drop
6
}
instance
(
FromJSON
(
HKD
a
(
Maybe
Text
))
,
FromJSON
(
HKD
a
[
Text
])
,
FromJSON
(
HKD
a
Text
)
,
FromJSON
(
HKD
a
Level
)
)
=>
FromJSON
(
LintConfig
a
)
where
parseJSON
=
genericParseJSON
aesonOptions
-- need to define this one extra, since Aeson will not make
-- Maybe fields optional if the type isn't given explicitly.
--
-- Whoever said instances had confusing semantics?
instance
{-# Overlapping #-}
FromJSON
(
LintConfig
Maybe
)
where
parseJSON
=
genericParseJSON
default
Options
parseJSON
=
genericParseJSON
aeson
Options
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment