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

Extremely slow kotlin linting #1441

Closed
powturns opened this issue Apr 25, 2022 · 2 comments · Fixed by #3575
Closed

Extremely slow kotlin linting #1441

powturns opened this issue Apr 25, 2022 · 2 comments · Fixed by #3575
Labels
question Further information is requested

Comments

@powturns
Copy link

We've been using megalinter across several projects. Things have been going well, except on an android project where the linting run takes almost 15 minutes to complete.

> docker run -v $(pwd):/workspace -e DEFAULT_WORKSPACE='/workspace' -e ENABLE_LINTERS='KOTLIN_KTLINT' megalinter/megalinter-java:v5

+----MATCHING LINTERS-+----------+----------------+------------+
| Descriptor | Linter | Criteria | Matching files | Format/Fix |
+------------+--------+----------+----------------+------------+
| KOTLIN     | ktlint | .kt|.kts | 464            | no         |
+------------+--------+----------+----------------+------------+
+----SUMMARY-+--------+------+-------+-------+--------+--------------+
| Descriptor | Linter | Mode | Files | Fixed | Errors | Elapsed time |
+------------+--------+------+-------+-------+--------+--------------+
| ✅ KOTLIN  | ktlint | file |   464 |       |      0 |      849.19s |
+------------+--------+------+-------+-------+--------+--------------+

vs. running ktlint directly:

> time ktlint 
ktlint  12.78s user 0.69s system 185% cpu 7.262 total

Any advice as to where to start troubleshooting is much appreciated.

@powturns powturns added the question Further information is requested label Apr 25, 2022
@nvuillam
Copy link
Member

nvuillam commented Apr 25, 2022

The problem comes from the file method used ... ktlint is called once by file, that's what explain such unacceptable elapsed time.

I am not sure than ktlint can take a list of files as parameter (or maybe you can check ? ), that's why list_of_files mode is not used.

Meanwhile, if you don't want to ignore some of the ktlint files, please can you try to define KOTLIN_KTLINT_CLI_LINT_MODE: project in env var or .mega-linter.yml ? It will make ktlint be called just once on the directory, and you should see the same performances than with your local test :)

@powturns
Copy link
Author

That's done it, thanks very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants