-
Notifications
You must be signed in to change notification settings - Fork 503
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
CLI should lint only *.kt,*.kts files when only path are provided #917
Comments
Documentation of CLI is not explicitly states it, but you need to pass file extensions that will be included into linting. It is located in example usages. If you invoke ktlint without any paths (for example , I am not sure if it is better to check only |
@Tapchicoma My bad, thanks! I thought I was seeing the error by running ktlint without specifying a path, but checking my log now - I've used a path in those cases. If it makes any difference - it would be better if the behavior is the same, in my opinion. Whether a path is specified or not, only Kotlin files should be checked when no pattern is specified. This turns out to be a change request, so this issue can be closed or converted. |
I think what you are proposing makes sense. |
… only process files with default kotlin extensions in that directory or its subdirectories. This is equivalent to execute ktlint in that directory without specifying any pattern. Closes pinterest#917
…1537) * Expand (existing) directory to globs for default kotlin extensions * When an (existing) directory (without glob pattern) is specified then only process files with default kotlin extensions in that directory or its subdirectories. This is equivalent to execute ktlint in that directory without specifying any pattern. Closes #917 * When a glob does not contain an absolute path then do not prefix it with the root directory but instead ensure that it is prefixed it with the "**/" matcher. In this way files directly inside the workdir are matched as well as files in subdirectories of the workdir. * Print an error message and return with non-zero exit code when no files are found that match with the globs Closes #629 * Refactor by eliminating variable project2Files * Refactor to improve readability and consistency * Extract constants to private values. Align name of test class with production class. * Remove characters which may cause a problem on Windows * Normalize paths for Windows build * Disable tests on Windows using absolute paths as those are not supported by jimfs
Expected Behavior
The same type of files (kotlin) should be checked regardless of whether a path has been passed or not - as long as no pattern has been specified in the path.
No errors of type "Not a valid Kotlin file" should be shown for files that are clearly not in Kotlin.
Observed Behavior
Seeing errors for Java files when running with a path parameter without a pattern, like
ktlint /Users/bla/project/somefolder/
Steps to Reproduce
It's just an Android project with some Java and Kotlin files. Java and Kotlin are found coexisting in the same packages and folders. Happens both on classes and interfaces.
Your Environment
The text was updated successfully, but these errors were encountered: