Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration per file #1134

Open
mnojek opened this issue Oct 28, 2024 · 1 comment
Open

Configuration per file #1134

mnojek opened this issue Oct 28, 2024 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@mnojek
Copy link
Member

mnojek commented Oct 28, 2024

I would like to have a way to configure rules per file or directory. I have a global configuration for my project at root, but I have some directories that I want to configure differently.

Example use case: I have some directories in the project that contain outdated code that is being migrated. We decided in the team that we don't want to refactor these tests, yet Robocop still uses the root's configuration for it. I would like to exclude some rules for this specific directory. Having a pyproject.toml or .robocop file in this directory does not affect the project's configuration.

Proposed solution: Add a way to extend the main configuration file for specific files/directories (example how it's done in airflow project with ruff):

[tool.ruff.lint.extend-per-file-ignores]
"airflow/__init__.py" = ["F401", "TCH004", "I002"]
"airflow/models/__init__.py" = ["F401", "TCH004"]
"airflow/models/sqla_models.py" = ["F401"]
"providers/src/airflow/providers/__init__.py" = ["I002"]
@mnojek mnojek added the enhancement New feature or request label Oct 28, 2024
@mnojek mnojek modified the milestones: 5.0.0, 6.0.0 Oct 28, 2024
@bhirsz
Copy link
Member

bhirsz commented Oct 28, 2024

I feel it's two features in one request.

One is to have separate configurable file per directory, like somehow described in #606

Second is to have options that allows to extend some of the configurations per file (for example extend exclude for specific files like in your example).

Second should be a lot easier to implement than first, as the first requires more planning if it comes to dealing with multiple configuration files (merging etc), But then we need to clearly define which options could be 'extended'. Extending exclude should be easy, include harder (as it may require reloading the rules), same with keeping separate rule configuration per file.

So I propose we can go with 2) first, and do it only for exclude. Then over the time we can implement 1) option. But I will take a second look if 1) is easier than I think, because it's better option overall from the user perspective.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants