Tool to gather project statistics like number of lines, classes, enums

does such a tool exist to compare the complexity of source bases?

This touches on my idea that we need more meta-tools. I’d really like to do “find”-like scans that can look recursively through the codebase for combinations of things. What we need is a good API to the analyzer. I wonder how much of that is already done for other LSP languages?

1 Like

I imagine that the analyser probably has that ability just that the api isn’t public.

I tried to ask chatgpt and Claude but the results were completely unreliable. So much for AI

Oooh. Asked Gemini, got pointed at https://github.com/ast-grep:

ast-grep is an abstract syntax tree based tool to search code by pattern code. Think of it as your old-friend grep, but matching AST nodes instead of text. You can write patterns as if you are writing ordinary code. It will match all code that has the same syntactical structure. You can use $ sign + upper case letters as a wildcard, e.g. $MATCH , to match any single AST node. Think of it as regular expression dot . , except it is not textual.

And there appears to be a VSCode plugin for it too!

2 Likes

For convenience: The : got mixed with the link and broke it:

Thanks!

what worked was ask an AI to create a python script to do to the counting I wanted…

That AI again! What can it NOT do? (Rhetorical question, of course…)

it couldn’t do the counting directly, but creating a python script it can…

Interesting. This can be done fairly easily in the context of a custom lint rule, so I guess it shouldn’t be too hard to use the same underlying API to make it accessible to a script