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
e103c8e1
Commit
e103c8e1
authored
3 years ago
by
stuebinm
Browse files
Options
Downloads
Patches
Plain Diff
simple graphviz visualisation of a repository
might be useful to have
parent
1c90b431
No related branches found
No related tags found
No related merge requests found
Pipeline
#9939
passed
3 years ago
Stage: build
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/CheckDir.hs
+7
-3
7 additions, 3 deletions
lib/CheckDir.hs
lib/Dirgraph.hs
+20
-2
20 additions, 2 deletions
lib/Dirgraph.hs
walint.cabal
+2
-1
2 additions, 1 deletion
walint.cabal
with
29 additions
and
6 deletions
lib/CheckDir.hs
+
7
−
3
View file @
e103c8e1
...
...
@@ -23,7 +23,7 @@ import Data.Map.Strict (mapKeys, (\\))
import
Data.Maybe
(
mapMaybe
)
import
Data.Text
(
Text
)
import
qualified
Data.Text
as
T
import
Dirgraph
(
invertGraph
,
resultToGraph
,
import
Dirgraph
(
graphToDot
,
invertGraph
,
resultToGraph
,
unreachableFrom
)
import
GHC.Generics
(
Generic
)
import
LintConfig
(
LintConfig
'
,
configMaxLintLevel
)
...
...
@@ -32,6 +32,7 @@ import System.Directory.Extra (doesFileExist)
import
System.FilePath
(
splitPath
,
(
</>
))
import
qualified
System.FilePath
as
FP
import
System.FilePath.Posix
(
takeDirectory
)
import
Text.Dot
(
Dot
,
showDot
)
import
Types
(
Dep
(
Local
,
LocalMap
),
Hint
(
Hint
),
Level
(
..
),
hintLevel
)
import
Util
(
PrettyPrint
(
prettyprint
))
...
...
@@ -53,6 +54,7 @@ data DirResult = DirResult
-- ^ all dependencies to things outside this repository
,
dirresultMissingAssets
::
[
MissingAsset
]
-- ^ entrypoints of maps which are referred to but missing
,
dirresultGraph
::
Dot
()
}
deriving
(
Generic
)
data
MissingDep
=
MissingDep
...
...
@@ -96,6 +98,7 @@ instance ToJSON DirResult where
[
"missingDeps"
.=
dirresultDeps
res
,
"missingAssets"
.=
dirresultMissingAssets
res
,
"mapLints"
.=
dirresultMaps
res
,
"exitGraph"
.=
showDot
(
dirresultGraph
res
)
]
,
"resultText"
.=
prettyprint
(
Suggestion
,
res
)
,
"severity"
.=
maximumLintLevel
res
...
...
@@ -145,12 +148,12 @@ recursiveCheckDir
recursiveCheckDir
config
prefix
root
=
do
maps
<-
recursiveCheckDir'
config
prefix
[
root
]
mempty
let
exitGraph
=
resultToGraph
maps
-- maps that don't have (local) ways back to the main entrypoint
let
nowayback
=
unreachableFrom
root
.
invertGraph
.
resultToGraph
$
maps
$
exitGraph
-- inject warnings for maps that have no way back to the entrypoint
let
maps'
=
flip
mapWithKey
maps
$
\
path
res
->
...
...
@@ -165,6 +168,7 @@ recursiveCheckDir config prefix root = do
pure
$
DirResult
{
dirresultDeps
=
missingDeps
root
maps'
,
dirresultMissingAssets
=
mAssets
,
dirresultMaps
=
maps'
,
dirresultGraph
=
graphToDot
exitGraph
}
...
...
This diff is collapsed.
Click to expand it.
lib/Dirgraph.hs
+
20
−
2
View file @
e103c8e1
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TupleSections #-}
-- | Simple directed graphs, for dependency checking
module
Dirgraph
where
import
CheckMap
(
MapResult
(
mapresultDepends
))
import
Data.Map.Strict
(
Map
,
mapMaybeWithKey
,
mapWithKey
)
import
Control.Monad
(
forM_
)
import
Data.Functor
((
<&>
))
import
Data.Map.Strict
(
Map
,
mapMaybeWithKey
,
mapWithKey
,
traverseWithKey
)
import
qualified
Data.Map.Strict
as
M
import
Data.Set
(
Set
,
(
\\
))
import
qualified
Data.Set
as
S
import
Paths
(
normalise
)
import
Text.Dot
(
Dot
,
(
.->.
))
import
qualified
Text.Dot
as
D
import
Types
(
Dep
(
LocalMap
))
import
Witherable
(
mapMaybe
)
...
...
@@ -47,3 +53,15 @@ reachableFrom entrypoint graph = recursive mempty (S.singleton entrypoint)
unreachableFrom
::
Ord
a
=>
a
->
Graph
a
->
Set
a
unreachableFrom
entrypoint
graph
=
nodes
graph
\\
reachableFrom
entrypoint
graph
graphToDot
::
Graph
FilePath
->
Dot
()
graphToDot
graph
=
do
nodes
<-
traverseWithKey
(
\
name
edges
->
D
.
node
[(
"label"
,
name
)]
<&>
(,
edges
))
graph
forM_
nodes
$
\
(
node
,
edges
)
->
forM_
edges
$
\
key
->
case
M
.
lookup
key
nodes
of
Just
(
other
,
_
)
->
node
.->.
other
_
->
pure
()
This diff is collapsed.
Click to expand it.
walint.cabal
+
2
−
1
View file @
e103c8e1
...
...
@@ -54,7 +54,8 @@ library
getopt-generics,
regex-tdfa,
extra,
witherable
witherable,
dotgen
-- TODO: move more stuff into lib, these dependencies are silly
executable walint
...
...
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