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
Update documentation for TrailingComma rules #5513
Changes from 1 commit
5af7b73
34f356f
476ed79
7513394
37ebcec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,17 @@ package io.gitlab.arturbosch.detekt.formatting.wrappers | |
import com.pinterest.ktlint.core.api.UsesEditorConfigProperties | ||
import com.pinterest.ktlint.ruleset.standard.TrailingCommaOnCallSiteRule | ||
import io.gitlab.arturbosch.detekt.api.Config | ||
import io.gitlab.arturbosch.detekt.api.config | ||
import io.gitlab.arturbosch.detekt.api.configWithAndroidVariants | ||
import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable | ||
import io.gitlab.arturbosch.detekt.api.internal.Configuration | ||
import io.gitlab.arturbosch.detekt.formatting.FormattingRule | ||
|
||
/** | ||
* See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/) for documentation. | ||
* | ||
* [Kotlin coding convention](https://kotlinlang.org/docs/coding-conventions.html#trailing-commas) recommends | ||
* trailing comma encourage the use of trailing commas at the declaration site and | ||
* leaves it at your discretion for the call site. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you'd suggested adding a reference to the Android style guide? Though that style guide doesn't say anything about trailing commas, so I expect we will get some issues raised. Perhaps instead it can be made clear that the defaults match upstream ktlint. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will emphasize ktlint here |
||
*/ | ||
@AutoCorrectable(since = "1.22.0") | ||
class TrailingCommaOnCallSite(config: Config) : FormattingRule(config) { | ||
|
@@ -18,7 +22,10 @@ class TrailingCommaOnCallSite(config: Config) : FormattingRule(config) { | |
override val issue = issueFor("Rule to mandate/forbid trailing commas at call sites") | ||
|
||
@Configuration("Defines whether a trailing comma (or no trailing comma) should be enforced at call sites") | ||
chao2zhang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private val useTrailingCommaOnCallSite by config(false) | ||
private val useTrailingCommaOnCallSite by configWithAndroidVariants( | ||
defaultValue = true, | ||
defaultAndroidValue = false, | ||
) | ||
|
||
override fun overrideEditorConfigProperties(): Map<UsesEditorConfigProperties.EditorConfigProperty<*>, String> = | ||
mapOf( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,17 @@ package io.gitlab.arturbosch.detekt.formatting.wrappers | |
import com.pinterest.ktlint.core.api.UsesEditorConfigProperties | ||
import com.pinterest.ktlint.ruleset.standard.TrailingCommaOnDeclarationSiteRule | ||
import io.gitlab.arturbosch.detekt.api.Config | ||
import io.gitlab.arturbosch.detekt.api.config | ||
import io.gitlab.arturbosch.detekt.api.configWithAndroidVariants | ||
import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable | ||
import io.gitlab.arturbosch.detekt.api.internal.Configuration | ||
import io.gitlab.arturbosch.detekt.formatting.FormattingRule | ||
|
||
/** | ||
* See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/) for documentation. | ||
* | ||
* [Kotlin coding convention](https://kotlinlang.org/docs/coding-conventions.html#trailing-commas) recommends | ||
* trailing comma encourage the use of trailing commas at the declaration site and | ||
* leaves it at your discretion for the call site. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above |
||
*/ | ||
@AutoCorrectable(since = "1.22.0") | ||
class TrailingCommaOnDeclarationSite(config: Config) : FormattingRule(config) { | ||
|
@@ -18,7 +22,10 @@ class TrailingCommaOnDeclarationSite(config: Config) : FormattingRule(config) { | |
override val issue = issueFor("Rule to mandate/forbid trailing commas at declaration sites") | ||
|
||
@Configuration("Defines whether a trailing comma (or no trailing comma) should be enforced at declaration sites") | ||
chao2zhang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private val useTrailingCommaOnDeclarationSite by config(false) | ||
private val useTrailingCommaOnDeclarationSite by configWithAndroidVariants( | ||
defaultValue = true, | ||
defaultAndroidValue = false, | ||
) | ||
|
||
override fun overrideEditorConfigProperties(): Map<UsesEditorConfigProperties.EditorConfigProperty<*>, String> = | ||
mapOf( | ||
|
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'm unsure this should be .gitignored. I'm actually in favor of having a
.java-version
in the root folderThere 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.
Yes but everyone's
.java-version
content will be different depending on the exact minor/patch versionThere 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.
Maybe open a separate PR for this? I'm otherwise happy to merge this PR.
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 agree that we should move this to another pr. This PR is the last thing that we need to release 1.22.0.
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 should be able to have just the major version (like
11
) inside.java-version
and that will be picked up correctly by jenv