Open andrewdea opened 3 weeks ago
I would prefer using a parser instead of tree-sitter
but that's because I've found breaking changes when they update a repository language, and it is a bit painful to refactor the code to make it compatible with the new version. But that's just my opinion, I'm not sure if every language parser is available at crates.io.
Which languages are we going to prioritize to support them? I was thinking in the following languages:
@andrewdea I would like to know which ones you have in mind.
@rohaquinlop I think those are great candidates!
Can you say a bit more about tree-sitter's breaking changes? I've used tree-sitter's python bindings before and I did encounter some breaking changes, but the earlier versions are usually quite stable, so that it's easy to delay updates until they're absolutely needed and the code is ready.
Here's the approach I'm thinking:
Starting with tree-sitter would have a few advantages:
"out-of-the-box" intermediate layer: parsing is specific to each language, but the cognitive-complexity algorithm aims at being language-agnostic. So we need to be able to apply it to any parsed snippet. We can start by using tree-sitter
's existing tried-and-tested approach, and we'll see which changes we need to make to fit our use-case. Otherwise adding support for any language would involve two implementations: the parsing, and the cognitive-complexity computation, which would then create a lot of complexity in terms of maintaining the algorithm and ensuring it is consistent across languages
complexipy
will be useful across countless code-bases and use-caseSorry this is a bit long, would love to know what you think 🙂
@andrewdea You're right, I like this approach
Related issue: #13
From my understanding, using tree-sitter is most likely the best way to go about this.
When possible, a specialized parser is probably preferable, so I don't think we'd remove the current RustPython parser. But tree-sitter will allow us to support most languages, with minimal specialized treatment of each.
Feedback welcome 🙂