Remove dead code
Some code is unused in the database. As a couple obvious examples (unless I am missing something), a text search in the codebase suggests that the following modules are not imported anywhere:
Gargantext.Database.Action.TSQuery
-
Gargantext.Database.Schema.Node_NodeNgramsNodeNgrams
(only contains commented code) -
Gargantext.Database.Query.Table.Node_NodeNgramsNodeNgrams
(only contains commented code)
Those are just examples found by chance, there are probably more such modules.There is also a lot of commented code, and I suspect that there is some more dead code at lower levels of granularity (functions that are never called, pattern matching branches that are never selected).
This makes it significantly more difficult than needed to navigate the codebase as a newcomer.
Distinct but related issue about the dependency graph: #180
Tools
Some tools can help detecting dead code systematically:
-
Weeder tells you about dead code, but I don't know with which level of granularity (I don't think it inspects pattern matching branches, for instance).
- From what I understand, @AlfredoDiNapoli has considered running Weeder but didn't find anything worth reporting on.
- I converted his Weeder configuration from the former format
.dhall
into the current.toml
, using the author's script. I am not going to make a merge request right now just for that, but here is the new config: weeder.toml - I managed to have Weeder run, but it seems faulty: one of the first functions it tells me to remove is
startGargantext
, which is obviously not dead code. Here is my (faulty) Weeder output for reference.
-
Calligraphy allows Haskell developers to see their codebase as a graph. This would be useful in a manual search for dead code, and would moreover be a good complement to human-written documentation. (Note that from the author's own admission, Calligraphy's output is not exhaustive, so it should only be treated as an exploration tool, not as sufficient evidence to remove code.)
- I tried to run Calligraphy too, but only got
No files matched your search criteria..
. It seems that I didn't manage to generate the correct.hie
files.
- I tried to run Calligraphy too, but only got
Possible course of action
- Discuss any possible reasons for the existence of dead code in the first place (maybe some of it is expected to be useful in future developments?), and decide whether it should be removed.
- Manage to run Weeder to automatically detect some of the dead code
- Manage to run Calligraphy and manually explore the codebase to find more dead code
- Remove the dead code