rohaquinlop / complexipy

An extremely fast Python library to calculate the cognitive complexity of Python files, written in Rust.
https://rohaquinlop.github.io/complexipy/
MIT License
135 stars 7 forks source link

Support additional languages #47

Open andrewdea opened 3 weeks ago

andrewdea commented 3 weeks ago

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 🙂

rohaquinlop commented 2 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.

andrewdea commented 2 weeks ago

@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:

rohaquinlop commented 1 week ago

@andrewdea You're right, I like this approach