Skip to content

Commit

Permalink
Move wrapping logic from IndentationRule to new WrappingRule
Browse files Browse the repository at this point in the history
Wrapping logic belong in an own rule, so it can be disabled without
disabling the indentation logic.

The WrappingRule contains a simplified indentation logic. Whenever
a linebreak is inserted, it determines the indentation based on the
current indentation of the parent node regardless whether this node
is indented correctly. It is the responsibility of the
IndentationRule, which runs later than the WrappingRule to fix the
indentations.

Spec files used in the unit tests have been split. Some parts are
moved to new spec files specific for the WrappingRule. Other
parts are moved to real unit tests. And on some spec files,
both the wrapping and indentation rules are run together. Those
files need further refactoring.

The RuleExtension now also allows the diffFileLint and
diffFileFormat to run on a list of rules. Spec files which are
used for linting with multiple rules must specify the rule-id
in the expectations. The rule-id now optionally can also be
specified in those expectation when the file is checked by
only one rule. However, in case the detail property of the
LintError contains a ":" then the rule-id *must* be specified
as it is used as delimiter.

Closes pinterest#835
  • Loading branch information
paul-dingemans committed Mar 7, 2022
1 parent cf96f51 commit 60499e0
Show file tree
Hide file tree
Showing 27 changed files with 2,049 additions and 653 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).

### Changed
- Print the rule id always in the PlainReporter ([#1121](https://github.com/pinterest/ktlint/issues/1121))
- All wrapping logic is moved from the `indent` rule to the new rule `wrapping` (as part of the `standard` ruleset). In case you currently have disabled the `indent` rule, you may want to reconsider whether this is still necessary or that you also want to disable the new `wrapping` rule to keep the status quo. Both rules can be run independent of each other. ([#835](https://github.com/pinterest/ktlint/issues/835))


### Removed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ fun main() {
}

// expect
// 3:19:Unexpected spacing before "::"
// 4:21:Unexpected spacing after "::"
// 5:20:Unexpected spacing around "::"
// 6:21:Unexpected spacing after "::"
// 10:45:Unexpected spacing after "::"
// 11:42:Unexpected spacing before "::"
// 12:44:Unexpected spacing around "::"
// 16:45:Unexpected spacing after "::"
// 23:70:Unexpected spacing around "::"
// 28:11:Unexpected spacing after "::"
// 33:20:Unexpected spacing before "::"
// 3:19:double-colon-spacing:Unexpected spacing before "::"
// 4:21:double-colon-spacing:Unexpected spacing after "::"
// 5:20:double-colon-spacing:Unexpected spacing around "::"
// 6:21:double-colon-spacing:Unexpected spacing after "::"
// 10:45:double-colon-spacing:Unexpected spacing after "::"
// 11:42:double-colon-spacing:Unexpected spacing before "::"
// 12:44:double-colon-spacing:Unexpected spacing around "::"
// 16:45:double-colon-spacing:Unexpected spacing after "::"
// 23:70:double-colon-spacing:Unexpected spacing around "::"
// 28:11:double-colon-spacing:Unexpected spacing after "::"
// 33:20:double-colon-spacing:Unexpected spacing before "::"
Loading

0 comments on commit 60499e0

Please sign in to comment.