From df55f84aba84580cbd7f2d10c3dacd89b410a4ab Mon Sep 17 00:00:00 2001 From: Sha Sha Chu Date: Wed, 22 May 2019 16:29:09 -0700 Subject: [PATCH] Disable no wildcard rule (#435) Bandaid for https://github.com/pinterest/ktlint/issues/48 Also adding list of disabled rules to README for visibility. --- README.md | 41 +++++++++++-------- .../standard/StandardRuleSetProvider.kt | 6 ++- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 4e78bec773..8b5f5afdf3 100644 --- a/README.md +++ b/README.md @@ -30,23 +30,23 @@ It's also [easy to create your own](#creating-a-reporter). ## Standard rules - 4 spaces for indentation -(unless a different `indent_size` value is set in .editorconfig (see [EditorConfig](#editorconfig) section for more)); -- No semicolons (unless used to separate multiple statements on the same line); -- No wildcard / unused `import`s; -- No consecutive blank lines; -- No blank lines before `}`; -- No trailing whitespaces; -- No `Unit` returns (`fun fn {}` instead of `fun fn: Unit {}`); -- No empty (`{}`) class bodies; -- No spaces around range (`..`) operator; -- No newline before (binary) `+` & `-`, `*`, `/`, `%`, `&&`, `||`; -- When wrapping chained calls `.`, `?.` and `?:` should be placed on the next line; -- When a line is broken at an assignment (`=`) operator the break comes after the symbol; -- When class/function signature doesn't fit on a single line, each parameter must be on a separate line; -- Consistent string templates (`$v` instead of `${v}`, `${p.v}` instead of `${p.v.toString()}`); -- Consistent order of modifiers; -- Consistent spacing after keywords, commas; around colons, curly braces, parens, infix operators, comments, etc; -- Newline at the end of each file (not enabled by default, but recommended) +(unless a different `indent_size` value is set in .editorconfig (see [EditorConfig](#editorconfig) section for more)) +- No semicolons (unless used to separate multiple statements on the same line) +- No unused `import`s +- No consecutive blank lines +- No blank lines before `}` +- No trailing whitespaces +- No `Unit` returns (`fun fn {}` instead of `fun fn: Unit {}`) +- No empty (`{}`) class bodies +- No spaces around range (`..`) operator +- No newline before (binary) `+` & `-`, `*`, `/`, `%`, `&&`, `||` +- When wrapping chained calls `.`, `?.` and `?:` should be placed on the next line +- When a line is broken at an assignment (`=`) operator the break comes after the symbol +- When class/function signature doesn't fit on a single line, each parameter must be on a separate line +- Consistent string templates (`$v` instead of `${v}`, `${p.v}` instead of `${p.v.toString()}`) +- Consistent order of modifiers +- Consistent spacing after keywords, commas; around colons, curly braces, parens, infix operators, comments, etc +- Newline at the end of each file (not enabled by default, but recommended) (set `insert_final_newline=true` in .editorconfig to enable (see [EditorConfig](#editorconfig) section for more)). ## Experimental rules @@ -56,6 +56,13 @@ by passing the `--experimental` flag to `ktlint`. - Indentation formatting - Import ordering +## Disabled rules +- No wildcard `import`s +- Annotation formatting +- No underscores in package names +- Braces required for if/else statements +- Multi-line lambdas must name `it` param + ## EditorConfig ktlint recognizes the following [.editorconfig](http://editorconfig.org/) properties (provided they are specified under `[*.{kt,kts}]`): diff --git a/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/StandardRuleSetProvider.kt b/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/StandardRuleSetProvider.kt index f158c73555..57fc025ee7 100644 --- a/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/StandardRuleSetProvider.kt +++ b/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/StandardRuleSetProvider.kt @@ -33,7 +33,11 @@ class StandardRuleSetProvider : RuleSetProvider { NoTrailingSpacesRule(), NoUnitReturnRule(), NoUnusedImportsRule(), - NoWildcardImportsRule(), + // Disabling because it is now allowed by the Jetbrains styleguide, although it is still disallowed by + // the Android styleguide. + // Re-enable when there is a way to globally disable rules + // See discussion here: https://github.com/pinterest/ktlint/issues/48 + // NoWildcardImportsRule(), ParameterListWrappingRule(), SpacingAroundColonRule(), SpacingAroundCommaRule(),