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

Specify Configuration File for CSharpier Linter #3553

Closed
NadaMusthafa opened this issue May 11, 2024 · 4 comments · Fixed by #3664
Closed

Specify Configuration File for CSharpier Linter #3553

NadaMusthafa opened this issue May 11, 2024 · 4 comments · Fixed by #3664
Labels
O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity question Further information is requested

Comments

@NadaMusthafa
Copy link

Currently, there are no environment variables available for CSharpier linter to point to a configuration file, making it challenging to specify rules from a specific configuration file. This limitation inhibits users from customizing linting rules efficiently.Hence, with current implementation, how can we set CSharpier linter to point to a custom configuration file?

@NadaMusthafa NadaMusthafa added the question Further information is requested label May 11, 2024
@nvuillam
Copy link
Member

@NadaMusthafa please could you share an example of call to CSharpier with config file, so we can add its management in MegaLinter ?

@creativehub2000
Copy link

We used the following Settings:

Docker Image (latest): oxsecurity/megalinter-only-csharp_csharpier:beta_20240508-1708

Environment variables:

For MegaLinter:
MEGALINTER_FILES_TO_LINT : <list_of_comma_seperated_C#_files>
ENABLE_LINTERS : CSHARP_CSHARPIER
AZURE_COMMENT_REPORTER : false

For CSharpier:
CSHARP_CSHARPIER_CONFIG_FILE : '/config/.editorconfig'
CSHARP_CSHARPIER_CLI_LINT_MODE : list_of_files

With this basic setting, CSharpier throws an exception as shown.

megalinter_issue

Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

@github-actions github-actions bot added the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Jun 13, 2024
@TommyE123
Copy link
Contributor

Hi @NadaMusthafa,

I’ve taken a look into this for you and have found a few problems with config files and paths both in csharpier and megalinter itself.

Taking megalinter out of the equation for a moment, running csharpier manually locally produces these results.

I’ve increased the indent to 8 spaces in the .editorconfig and .csharpierrc for testing purposes.
image

  1. .editorconfig only in the root of the directory ✅
  2. .csharpierrc only in the root of the directory ✅
  3. .csharpierrc in a config folder and use -config-path to point to it ✅
  4. .editorconfig in a config folder and use -config-path to point to it ❌
  5. .editorconfig in root and use --config-path to point to it ❌

This strongly suggests that csharpier doesn’t support using the --config-path to point to a .editorconfig. This would require logging an issue with csharpier directly if you don’t want to put an .editorconfig in the root of your code. However its widely recognised as standard practice to place this type of file in the root, hence why I guess they probably don’t support it.

However while doing some testing for this issue I noticed that megalinter doesn’t work when overriding the configuration file name or path for a .csharpierrc file. I’ve created a PR for this here #3664

Hope this helps,
Tom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants