Comments (11)
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.
from megalinter.
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 ?
KOTLIN_DETEKT_ARGUMENTS: ["--config",".detekt.yml"]
If you don't want to totally overwrite detekt config, you might use the following
KOTLIN_DETEKT_ARGUMENTS: ["--build-upon-default-config","--config",".detekt.yml"]
from megalinter.
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:
❌ Linted [KOTLIN] files with [detekt]: Found 2 error(s) - (0.53s)
- Using [detekt v1.23.5] https://megalinter.io/7.11.1/descriptors/kotlin_detekt
- MegaLinter key: [KOTLIN_DETEKT]
- Rules config: identified by [detekt]
- Number of files analyzed: [2]
[detekt] src/Test.kt - ERROR - 1 error(s)
--Error detail:
Was passed main parameter 'src/Test.kt' but no main parameter was defined in your arg class
Usage: detekt [options]
Options:
--all-rules
Activates all available (even unstable) rules.
Default: false
--auto-correct, -ac
Allow rules to auto correct code if they support it. The default rule
sets do NOT support auto correcting and won't change any line in the
users code base. However custom rules can be written to support auto
correcting. The additional 'formatting' rule set, added with
'--plugins', does support it and needs this flag.
Default: false
--base-path, -bp
Specifies a directory as the base path.Currently it impacts all file
paths in the formatted reports. File paths in console output and txt
report are not affected and remain as absolute paths.
--baseline, -b
If a baseline xml file is passed in, only new code smells not in the
baseline are printed in the console.
--build-upon-default-config
Preconfigures detekt with a bunch of rules and some opinionated defaults
for you. Allows additional provided configurations to override the
defaults.
Default: false
--classpath, -cp
EXPERIMENTAL: Paths where to find user class files and depending jar
files. Used for type resolution.
--config, -c
Path to the config file (path/to/config.yml). Multiple configuration
files can be specified with ',' or ';' as separator.
--config-resource, -cr
Path to the config resource on detekt's classpath (path/to/config.yml).
--create-baseline, -cb
Treats current analysis findings as a smell baseline for future detekt
runs.
Default: false
--debug
Prints extra information about configurations and extensions.
Default: false
--disable-default-rulesets, -dd
Disables default rule sets.
Default: false
--excludes, -ex
Globbing patterns describing paths to exclude from the analysis.
--generate-config, -gc
Export default config. Path can be specified with --config option
(default path: default-detekt-config.yml)
Default: false
--help, -h
Shows the usage.
--includes, -in
Globbing patterns describing paths to include in the analysis. Useful in
combination with 'excludes' patterns.
--input, -i
Input paths to analyze. Multiple paths are separated by comma. If not
specified the current working directory is used.
--jdk-home
EXPERIMENTAL: Use a custom JDK home directory to include into the
classpath
--jvm-target
EXPERIMENTAL: Target version of the generated JVM bytecode that was
generated during compilation and is now being used for type resolution
(1.8, 9, 10, ..., 20)
Default: 1.8
--language-version
EXPERIMENTAL: Compatibility mode for Kotlin language version X.Y,
reports errors for all language features that came out later
Possible Values: [1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1]
--max-issues
Return exit code 0 only when found issues count does not exceed
specified issues count.
--parallel
Enables parallel compilation and analysis of source files. Do some
benchmarks first before enabling this flag. Heuristics show performance
benefits starting from 2000 lines of Kotlin code.
Default: false
--plugins, -p
Extra paths to plugin jars separated by ',' or ';'.
--report, -r
Generates a report for given 'report-id' and stores it on given 'path'.
Entry should consist of: [report-id:path]. Available 'report-id' values:
'txt', 'xml', 'html', 'md', 'sarif'. These can also be used in
combination with each other e.g. '-r txt:reports/detekt.txt -r
xml:reports/detekt.xml'
--version
Prints the detekt CLI version.
Default: false
Looks like something is not correct in the way the arguments are passed to Detekt, perhaps?
from megalinter.
@michaeloa please can you run with LOG_LEVEL: DEBUG so we can see the exact command line built by MegaLinter ?
from megalinter.
The debug returns the following:
[detekt] command: ['detekt-cli', '-i', '--config', '.detekt.yml', 'src/Test.kt']
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 ['detekt-cli', '--config', '.detekt.yml', '-i', 'src/Test.kt']
instead.
from megalinter.
@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 ?
from megalinter.
Let me check. I knew this once, but it's been a while.
from megalinter.
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.
from megalinter.
We can run detekt with project mode (on repo root without -i
), and in case someone wants something special he/she can configure extra parameters
What do you think about this proposition ?
from megalinter.
@michaeloa please can you confirm with newest beta version that now it's ok for your use case ? :)
from megalinter.
thanks for your feedback :)
from megalinter.
Related Issues (20)
- Update version of tflint-ruleset-aws HOT 3
- Doesn't seem to use LINTER_RULES_PATH in WSL HOT 10
- Powershell installed twice HOT 3
- TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension On Install HOT 2
- ENABLE_ERRORS_LINTERS HOT 7
- Powershell error table formatting issue HOT 1
- Devskim config ignored instead crawl-archives enabled by default HOT 1
- VSCODE error HOT 2
- Can EXTENDS be set in env? HOT 2
- TFLint - deprecated argument in ".tflint.hcl" HOT 6
- Action "Auto-Update Linters" is failing HOT 19
- Dependency "ip" needs to be replaced HOT 2
- Dependency Dashboard
- Add conftest integration HOT 2
- False negatives in v8r when validating mega-linter.yml HOT 4
- golangci-lint linter fails, as my go.mod has 1.22, but Alpine 3.19 has 1.21 HOT 4
- [Bug] Github Actions - 404 Network Errors Encountered with MegaLinter URLs HOT 3
- gherkin-linter in c_cpp flavor HOT 1
- Set env var via PRE_COMMAND HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from megalinter.