-
-
Notifications
You must be signed in to change notification settings - Fork 242
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
How does one configure Detekt? #3579
Comments
Hi @michaeloa , MegaLinter embeds linters and links to their documentation, but it's not our responsibility to document the linters themselves :) About detekt config, the doc is here -> https://detekt.dev/docs/introduction/configurations It does not seem detekt CLI looks for a config file name Please can you try with the following arguments in your .mega-linter.yml , and define a .detekt.yml at the root of your repo ?
If you don't want to totally overwrite detekt config, you might use the following
|
I've used detekt in a "super" linter like implementation before, and it does indeed not require a configuration file to run, nor look for a default. So I actually did try to pass kotlin arguments previously, but all that leads to is this:
Looks like something is not correct in the way the arguments are passed to Detekt, perhaps? |
@michaeloa please can you run with LOG_LEVEL: DEBUG so we can see the exact command line built by MegaLinter ? |
The debug returns the following:
That would seem to explain the issue (which would appear to be a bug). The file to be analyzed should be passed to the -i parameter. This should be something along the lines of |
@michaeloa ok got it, i know how to solve that bug But it seems that deteckt is called once by file, that seems not optimized at all, do you know if it can take a list of files, which would be more performant ? |
Let me check. I knew this once, but it's been a while. |
AFAIK, you do not need -i to run detekt; it should default to scan the working directory. Alternatively, you should also be able to input a path to detekt. |
We can run detekt with project mode (on repo root without What do you think about this proposition ? |
@michaeloa please can you confirm with newest beta version that now it's ok for your use case ? :) |
Seems like a reasonable approach. It is a bit of an inconvenience if one wants to fetch the detekt.yml from a URL (as we currently do with the other linters), but I assume I can use the pre/post hook commands to download a remote config file, if needed. Going to be away from my work PC for the rest of the week, but I did a quick test with a local detekt.yml and -r beta, and that works now, so the immediate issue seems solved. Many thanks. |
thanks for your feedback :) |
Hi, I want to run detekt for git diff. Is this possible with the latest changes? |
For now I have overcome this by overriding the following value on the CI/CD side. But that doesn't seem like good behavior for us:
|
@enciyo Interesting question - haven't looked into that yet (though it'll surely become relevant once we work more on using megalinter). Might make sense to open a new issue, since this one is resolved and closed. |
I've tried several different variants of rules config.
.detekt-config.yml
detekt-config.yml
detekt.yaml
detekt.yml
default-detekt-config.yml
None of them seem to be working. How do I get it to use a custom rules config?
I find this a general issue with the documentation, btw. Lots of variable documentation, but I've yet to see any documentation about how to add rules config for various linters easily. The documentation of the individual linters is often not clear enough on this.
The text was updated successfully, but these errors were encountered: