Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add experimental SpacingAroundAngleBracketsRule #769

Merged
merged 10 commits into from
Jun 9, 2020

Conversation

ymittal
Copy link
Contributor

@ymittal ymittal commented Jun 6, 2020

This builds on @christinalee's work in #587 (thanks so much, your PR was a perfect example of how to add new rules!)

In this PR, we created a lint rule to trim spacing around type parameters (TYPE_PARAMETER_LIST) and type arguments (TYPE_ARGUMENT_LIST).

Note that when the types span multiple lines, this rule does not fix the indentation itself. I rely on IndentationRule to dictate indentation. For example,

var map: Map<

                Int,
                List <   String >
    > = mapOf()

is formatted to

var map: Map<
                Int,
                List<String>
    > = mapOf()

The following shows that the indentation is fixed when all rules are run.

❯ cat sample | ./ktlint/build/run/ktlint --experimental -F --stdin
var map: Map<
    Int,
    List<String>
    > = mapOf()

Christina Lee and others added 7 commits September 23, 2019 21:27
The new angle bracket rule will live in the experimental rule set along with all the other new rules, so this commit refactors the associated tests to also live under the experimental package
Adds a rule to lint against white space before and after angle brackets in type arguments. This includes all of the following:
Map< String, Int>
Map<String, Int >
Map <String, Int>

In all of the above cases, the desired format is
Map<String, Int>

Specifically this rule does not affect generics formatting of the type
fun myFun<T>()
as this is already implemented in a separate rule.
The new angle bracket rule will live in the experimental rule set along with all the other new rules, so this commit refactors the associated tests to also live under the experimental package
Adds a rule to lint against white space before and after angle brackets in type arguments. This includes all of the following:
Map< String, Int>
Map<String, Int >
Map <String, Int>

In all of the above cases, the desired format is
Map<String, Int>

Specifically this rule does not affect generics formatting of the type
fun myFun<T>()
as this is already implemented in a separate rule.
@shashachu shashachu merged commit 322183a into pinterest:master Jun 9, 2020
This was referenced Jun 11, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants