Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing ktlint rule wrappers (#5256)
* Refactor formatting ruleset lists This reflects current status at 0.46.1 for standard vs experimental rules * Sort experimental rules * Add FunctionReturnTypeSpacing rule * Add FunctionSignature rule * Add FunctionStartOfBodySpacing rule * Add NullableTypeSpacing rule * Add ParameterListSpacing rule * Add SpacingBetweenFunctionNameAndOpeningParenthesis rule * Add TypeParameterListSpacing rule
- Loading branch information
Showing
10 changed files
with
210 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
.../main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FunctionReturnTypeSpacing.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.gitlab.arturbosch.detekt.formatting.wrappers | ||
|
||
import com.pinterest.ktlint.ruleset.experimental.FunctionReturnTypeSpacingRule | ||
import io.gitlab.arturbosch.detekt.api.Config | ||
import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable | ||
import io.gitlab.arturbosch.detekt.formatting.FormattingRule | ||
|
||
/** | ||
* See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#function-return-type-spacing) for | ||
* documentation. | ||
*/ | ||
@AutoCorrectable(since = "1.22.0") | ||
class FunctionReturnTypeSpacing(config: Config) : FormattingRule(config) { | ||
|
||
override val wrapping = FunctionReturnTypeSpacingRule() | ||
override val issue = issueFor("Checks the spacing between colon and return type.") | ||
} |
43 changes: 43 additions & 0 deletions
43
...ting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FunctionSignature.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.gitlab.arturbosch.detekt.formatting.wrappers | ||
|
||
import com.pinterest.ktlint.core.api.DefaultEditorConfigProperties | ||
import com.pinterest.ktlint.core.api.UsesEditorConfigProperties | ||
import com.pinterest.ktlint.ruleset.experimental.FunctionSignatureRule | ||
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/experimental/#function-signature) for | ||
* documentation. | ||
*/ | ||
@AutoCorrectable(since = "1.22.0") | ||
class FunctionSignature(config: Config) : FormattingRule(config) { | ||
|
||
override val wrapping = FunctionSignatureRule() | ||
override val issue = issueFor("Format signature to be single when possible, multiple lines otherwise.") | ||
|
||
@Configuration("parameter count means multiline threshold") | ||
private val forceMultilineWhenParameterCountGreaterOrEqualThan by config(2_147_483_647) | ||
|
||
@Configuration("indentation size") | ||
private val functionBodyExpressionWrapping by config("default") | ||
|
||
@Configuration("maximum line length") | ||
private val maxLineLength by configWithAndroidVariants(120, 100) | ||
|
||
@Configuration("indentation size") | ||
private val indentSize by config(4) | ||
|
||
override fun overrideEditorConfigProperties(): Map<UsesEditorConfigProperties.EditorConfigProperty<*>, String> = | ||
mapOf( | ||
FunctionSignatureRule.forceMultilineWhenParameterCountGreaterOrEqualThanProperty to | ||
forceMultilineWhenParameterCountGreaterOrEqualThan.toString(), | ||
FunctionSignatureRule.functionBodyExpressionWrappingProperty to functionBodyExpressionWrapping, | ||
DefaultEditorConfigProperties.maxLineLengthProperty to maxLineLength.toString(), | ||
DefaultEditorConfigProperties.indentSizeProperty to indentSize.toString(), | ||
) | ||
} |
17 changes: 17 additions & 0 deletions
17
...main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FunctionStartOfBodySpacing.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.gitlab.arturbosch.detekt.formatting.wrappers | ||
|
||
import com.pinterest.ktlint.ruleset.experimental.FunctionStartOfBodySpacingRule | ||
import io.gitlab.arturbosch.detekt.api.Config | ||
import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable | ||
import io.gitlab.arturbosch.detekt.formatting.FormattingRule | ||
|
||
/** | ||
* See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#function-start-of-body-spacing) for | ||
* documentation. | ||
*/ | ||
@AutoCorrectable(since = "1.22.0") | ||
class FunctionStartOfBodySpacing(config: Config) : FormattingRule(config) { | ||
|
||
override val wrapping = FunctionStartOfBodySpacingRule() | ||
override val issue = issueFor("Check for consistent spacing before start of function body.") | ||
} |
17 changes: 17 additions & 0 deletions
17
...ng/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NullableTypeSpacing.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.gitlab.arturbosch.detekt.formatting.wrappers | ||
|
||
import com.pinterest.ktlint.ruleset.experimental.NullableTypeSpacingRule | ||
import io.gitlab.arturbosch.detekt.api.Config | ||
import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable | ||
import io.gitlab.arturbosch.detekt.formatting.FormattingRule | ||
|
||
/** | ||
* See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#nullable-type-spacing) for | ||
* documentation. | ||
*/ | ||
@AutoCorrectable(since = "1.22.0") | ||
class NullableTypeSpacing(config: Config) : FormattingRule(config) { | ||
|
||
override val wrapping = NullableTypeSpacingRule() | ||
override val issue = issueFor("Ensure no spaces in nullable type.") | ||
} |
17 changes: 17 additions & 0 deletions
17
...g/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ParameterListSpacing.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.gitlab.arturbosch.detekt.formatting.wrappers | ||
|
||
import com.pinterest.ktlint.ruleset.experimental.ParameterListSpacingRule | ||
import io.gitlab.arturbosch.detekt.api.Config | ||
import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable | ||
import io.gitlab.arturbosch.detekt.formatting.FormattingRule | ||
|
||
/** | ||
* See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#parameter-list-spacing) for | ||
* documentation. | ||
*/ | ||
@AutoCorrectable(since = "1.22.0") | ||
class ParameterListSpacing(config: Config) : FormattingRule(config) { | ||
|
||
override val wrapping = ParameterListSpacingRule() | ||
override val issue = issueFor("Ensure consistent spacing inside the parameter list.") | ||
} |
17 changes: 17 additions & 0 deletions
17
.../arturbosch/detekt/formatting/wrappers/SpacingBetweenFunctionNameAndOpeningParenthesis.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.gitlab.arturbosch.detekt.formatting.wrappers | ||
|
||
import com.pinterest.ktlint.ruleset.experimental.SpacingBetweenFunctionNameAndOpeningParenthesisRule | ||
import io.gitlab.arturbosch.detekt.api.Config | ||
import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable | ||
import io.gitlab.arturbosch.detekt.formatting.FormattingRule | ||
|
||
/** | ||
* See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#spacing-between-function-name-and-opening-parenthesis) for | ||
* documentation. | ||
*/ | ||
@AutoCorrectable(since = "1.22.0") | ||
class SpacingBetweenFunctionNameAndOpeningParenthesis(config: Config) : FormattingRule(config) { | ||
|
||
override val wrapping = SpacingBetweenFunctionNameAndOpeningParenthesisRule() | ||
override val issue = issueFor("Ensure consistent spacing between function name and opening parenthesis.") | ||
} |
17 changes: 17 additions & 0 deletions
17
...c/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/TypeParameterListSpacing.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.gitlab.arturbosch.detekt.formatting.wrappers | ||
|
||
import com.pinterest.ktlint.ruleset.experimental.TypeParameterListSpacingRule | ||
import io.gitlab.arturbosch.detekt.api.Config | ||
import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable | ||
import io.gitlab.arturbosch.detekt.formatting.FormattingRule | ||
|
||
/** | ||
* See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#type-parameter-list-spacing) for | ||
* documentation. | ||
*/ | ||
@AutoCorrectable(since = "1.22.0") | ||
class TypeParameterListSpacing(config: Config) : FormattingRule(config) { | ||
|
||
override val wrapping = TypeParameterListSpacingRule() | ||
override val issue = issueFor("Check spacing after a type parameter list in function and class declarations.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters