-
-
Notifications
You must be signed in to change notification settings - Fork 803
Kotlin language version handling #1748
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
Conversation
Signed-off-by: Semyon Levin <levin.semen@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #1748 +/- ##
============================================
- Coverage 79.86% 79.78% -0.09%
- Complexity 1936 1937 +1
============================================
Files 325 324 -1
Lines 5478 5500 +22
Branches 1013 1015 +2
============================================
+ Hits 4375 4388 +13
- Misses 581 587 +6
- Partials 522 525 +3
Continue to review full report at Codecov.
|
@arturbosch @schalkms Could you please take a look? |
This PR fixes this warning:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I think this is a nice addition.
I have added some questions to this review.
The cli flag is just a check right. There's no other behavior
I think documentation and tests are missing for this cli flag.
detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/invoke/CliArgument.kt
Show resolved
Hide resolved
detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/invoke/CliArgument.kt
Show resolved
Hide resolved
detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/Detekt.kt
Outdated
Show resolved
Hide resolved
detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/Detekt.kt
Show resolved
Hide resolved
detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/ProcessingSettings.kt
Outdated
Show resolved
Hide resolved
detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/KtCompiler.kt
Show resolved
Hide resolved
detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/DetektFacade.kt
Show resolved
Hide resolved
@remal you need to use the |
Fix a misprint
@schalkms Yes, you're right. I'm trying to analyze sources of a project that depends on an older version of Kotlin (1.2). So I see this warning every time I run Detekt. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good.
Regarding the tests, I think it's okay then.
With my PR in #1752 codecov doesn't fail anymore when the test coverage decreases.
I'm resolving the remaining discussions.
Please take a look at my last question. Otherwise this is then good to go, I think.
@@ -77,6 +77,11 @@ Usage: detekt [options] | |||
--input, -i | |||
Input paths to analyze. Multiple paths are separated by comma. If not | |||
specified the current working directory is used. | |||
--language-version | |||
EXPERIMENTAL: Compatibility mode for Kotlin language version X.Y, reports |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reports errors for all language features that came out later.
What do you mean by that? Could you please show an example to help me understand the problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I haven't seen such warnings. I suppose we can get them if Kotlin JARs in the classpath are not aligned, for example.
@schalkms I have an idea to move automated Kotlin version detection from Detekt's Gradle plugin to |
@remal is this PR then obsolete? |
…t-api Signed-off-by: Semyon Levin <levin.semen@gmail.com>
@schalkms I've pushed a new commit with moving version retrieval logic. BTW I haven't tested it in Java >= 9 environment. |
Signed-off-by: Semyon Levin <levin.semen@gmail.com>
@@ -95,18 +95,18 @@ fun createCompilerConfiguration( | |||
private fun Iterable<File>.getKotlinLanguageVersion(): LanguageVersion? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to unit test this single method.
Then we are also sure that it works on all JVM versions with the help of CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a test. See KotlinEnvironmentUtilsTest
.
This test does not:
- Test the code against different versions of Kotlin
- Test the code against different versions of JVM
PS: Asking for tests was very useful - I catched a bug :)
Signed-off-by: Semyon Levin <levin.semen@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, seems reasonable to support older kotlin versions when 1.4 comes out.
Please revert the continuous indent to 4 again, see this summary ticket for example JuulLabs/kotlin-code-styles#1 (comment)
KtLint deleted the option to configure the continuous indent and android kotlin guide uses 4. Also jetbrains reverted many places where 8 was used for example parameter lists. We will just stick with 4.
Kotlin/kotlin-style-guide#38
The test seems to fail on Java 9+, any idea why?
|
Signed-off-by: Semyon Levin <levin.semen@gmail.com>
@arturbosch I'm afraid I didn't understand what you meant by "revert the continuous indent to 4 again". Could you please give a specific example? I'd appreciate it if you could make a comment to a specific line. I've fixed the test. Please take a look. It seems that Application ClassLoader is not an instance of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the test.
IMHO this PR looks fine now! Thank you for that!
We will have to wait for Artur's final review.
"Available 'report-id' values: 'txt', 'xml', 'html'. " + | ||
"These can also be used in combination with each other " + | ||
"e.g. '-r txt:reports/detekt.txt -r xml:reports/detekt.xml'") | ||
"Entry should consist of: [report-id:path]. " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole indentation in this file for example got reformatted to 8 continuous spaces instead of four.
I like the annotation parameter formatting though :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a look. Is it OK now?
https://github.com/JetBrains/kotlin/blob/master/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt | ||
*/ | ||
@Parameter( | ||
names = ["--classpath", "-cp"], | ||
description = "EXPERIMENTAL: Paths where to find user class files and depending jar files. " + | ||
"Used for type resolution." | ||
"Used for type resolution." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this ^^
Signed-off-by: Semyon Levin <levin.semen@gmail.com>
Signed-off-by: Semyon Levin <levin.semen@gmail.com>
@arturbosch Please take a look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you very much!
This PR helps to solve an issue when a user have a Kotlin project with Kotlin version less then Detekt's Kotlin version. Without these fixes a lot of Kotlin embedded compiler warnings occur.
Also a lot of coding style issues have been fixed.