getcodelimit / codelimit

Your Refactoring Alarm 🔔
https://codelimit.vercel.app
GNU General Public License v3.0
33 stars 2 forks source link

Add a environment / config variable to ignore certain certain function patterns #21

Closed bbelderbos closed 11 months ago

bbelderbos commented 1 year ago

Similar to https://github.com/getcodelimit/codelimit/issues/20 but that is more for linting, with this issue I suggest a config variable to specify one or more patterns to be ignored, for example main.py or __init__.py (we've seen long constructors in FastAPI for example).

Not sure if this should work with function names and/or module names. Probably best to ignore minimally so I suggest the former.

Bare bones env variable handling = os.environ but usually we use an .env locally in Python. If you go that route I suggest adding the python-dotenv or python-decouple package / dependency, see: https://pybit.es/articles/how-to-handle-environment-variables-in-python/

robvanderleek commented 12 months ago

Hi @bbelderbos

Thanks for this suggestion 🙂

I've looked at how other tools solve the exclusion feature:

As it's not common to exclude function names and to keep things familiar for most users, I'm proposing to add an --exclude option for excluding files/directories with a regular expression, and to also support loading this setting from a pyprojec.toml file.

What do you think?

bbelderbos commented 11 months ago

Thanks for your research on this @robvanderleek, that sounds like a great way to design this. Not urgent for me right now but I think it will be useful feature. It's a bit like globally ignoring E501 with flake because you might not agree with this long line violation, likewise there might be functions you just don't want to include in this analysis, long init.py constructors come to mind.

robvanderleek commented 11 months ago

/cib

create-issue-branch[bot] commented 11 months ago

Branch issue-21-Add_aenvironment/_config_variable_to_ignore_certain_certain_function_patterns created!

robvanderleek commented 11 months ago

Hi @bbelderbos

It took some time; for now, I've added an --exclude command-line option. Together with the functionality to exclude functions using a # nocl comment, I think this will handle most situations for current users.

Thanks for submitting both issues!

bbelderbos commented 11 months ago

Nice, this will be useful, thanks!