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
887540e3
Commit
887540e3
authored
3 years ago
by
stuebinm
Browse files
Options
Downloads
Patches
Plain Diff
don't print doubled lints twice
parent
73feaafc
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/CheckMap.hs
+7
-8
7 additions, 8 deletions
lib/CheckMap.hs
lib/LintWriter.hs
+4
-3
4 additions, 3 deletions
lib/LintWriter.hs
with
11 additions
and
11 deletions
lib/CheckMap.hs
+
7
−
8
View file @
887540e3
...
...
@@ -30,8 +30,7 @@ import Properties (checkLayer, checkMap, checkTileset)
import
Tiled
(
Layer
(
layerLayers
,
layerName
),
LoadResult
(
..
),
Tiledmap
(
tiledmapLayers
,
tiledmapTilesets
),
Tileset
,
loadTiledmap
)
import
TiledAbstract
(
HasName
(
..
))
loadTiledmap
)
import
Types
(
Dep
,
Hint
(
Hint
,
hintLevel
,
hintMsg
),
Level
(
..
),
lintsToHints
)
import
Util
(
PrettyPrint
(
prettyprint
),
prettyprint
)
...
...
@@ -40,9 +39,9 @@ import Util (PrettyPrint (prettyprint), prettyprint)
-- | What this linter produces: lints for a single map
data
MapResult
=
MapResult
{
mapresultLayer
::
Map
Hint
[
Layer
]
{
mapresultLayer
::
Map
Hint
[
Text
]
-- ^ lints that occurred in one or more layers
,
mapresultTileset
::
Map
Hint
[
T
iles
et
]
,
mapresultTileset
::
Map
Hint
[
Te
x
t
]
-- ^ lints that occurred in one or more tilesets
,
mapresultDepends
::
[
Dep
]
-- ^ (external and local) dependencies of this map
...
...
@@ -58,8 +57,8 @@ data MapResult = MapResult
instance
ToJSON
MapResult
where
toJSON
res
=
A
.
object
[
"layer"
.=
CollectedLints
(
fmap
getName
<$>
mapresultLayer
res
)
,
"tileset"
.=
CollectedLints
(
fmap
getName
<$>
mapresultTileset
res
)
[
"layer"
.=
CollectedLints
(
mapresultLayer
res
)
,
"tileset"
.=
CollectedLints
(
mapresultTileset
res
)
,
"general"
.=
mapresultGeneral
res
,
"offers"
.=
mapresultProvides
res
]
...
...
@@ -178,7 +177,7 @@ instance PrettyPrint (Level, MapResult) where
-- | pretty-prints a collection of Hints, printing each
-- Hint only once, then a list of its occurences line-wrapped
-- to fit onto a decent-sized terminal
prettyLints
::
HasName
a
=>
(
MapResult
->
Map
Hint
[
a
])
->
[
Text
]
prettyLints
::
(
MapResult
->
Map
Hint
[
Text
])
->
[
Text
]
prettyLints
getter
=
fmap
(
\
(
h
,
cs
)
->
prettyprint
h
<>
"
\n
(in "
...
...
@@ -188,7 +187,7 @@ instance PrettyPrint (Level, MapResult) where
_
|
l
<
70
->
(
l
+
2
+
T
.
length
c
,
a
<>
", "
<>
c
)
_
->
(
6
+
T
.
length
c
,
a
<>
",
\n
"
<>
c
)
)
(
0
,
""
)
(
fmap
getName
cs
)
)
(
0
,
""
)
cs
)
<>
")
\n
"
)
(
toList
.
getter
$
mapResult
)
...
...
This diff is collapsed.
Click to expand it.
lib/LintWriter.hs
+
4
−
3
View file @
887540e3
...
...
@@ -52,8 +52,9 @@ import Control.Monad.Writer.Lazy (lift)
import
Data.Bifunctor
(
Bifunctor
(
second
))
import
Data.Map
(
Map
,
fromListWith
)
import
Data.Maybe
(
mapMaybe
)
import
qualified
Data.Set
as
S
import
LintConfig
(
LintConfig
'
)
import
TiledAbstract
(
HasName
)
import
TiledAbstract
(
HasName
(
getName
)
)
import
Types
(
Dep
,
Hint
,
Level
(
..
),
Lint
(
..
),
hint
,
lintsToHints
)
...
...
@@ -106,9 +107,9 @@ zoom embed extract operation = do
-- | "invert" a linter's result, grouping lints by their messages
invertLintResult
::
HasName
ctxt
=>
LintResult
ctxt
->
Map
Hint
[
ct
xt
]
invertLintResult
::
HasName
ctxt
=>
LintResult
ctxt
->
Map
Hint
[
Te
xt
]
invertLintResult
(
LinterState
(
lints
,
ctxt
))
=
fromListWith
(
<>
)
$
(,
[
ctxt
])
<$>
lintsToHints
lints
fmap
(
S
.
toList
.
S
.
fromList
.
fmap
getName
)
.
fromListWith
(
<>
)
$
(,
[
ctxt
])
<$>
lintsToHints
lints
resultToDeps
::
LintResult
a
->
[
Dep
]
resultToDeps
(
LinterState
(
lints
,
_
))
=
mapMaybe
lintToDep
lints
...
...
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