Skip to content
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

Messy reordering by DiktatRuleSet #482

Closed
petertrr opened this issue Nov 2, 2020 · 0 comments · Fixed by #637
Closed

Messy reordering by DiktatRuleSet #482

petertrr opened this issue Nov 2, 2020 · 0 comments · Fixed by #637
Assignees
Labels
autofix Issues related to diktat in autofix mode bug Something isn't working

Comments

@petertrr
Copy link
Member

petertrr commented Nov 2, 2020

Describe the bug

class Example {
companion object {
        private val keywordsWithSpaceAfter = TokenSet.create(
                // these keywords are followed by {
                ELSE_KEYWORD, TRY_KEYWORD, DO_KEYWORD, FINALLY_KEYWORD, INIT_KEYWORD,
                // these keywords are followed by (
                FOR_KEYWORD, IF_KEYWORD, WHILE_KEYWORD, CATCH_KEYWORD,
                // these keywords can be followed by either { or (
                WHEN_KEYWORD
        )

        val operatorsWithNoWhitespace = TokenSet.create(DOT, RANGE, COLONCOLON, SAFE_ACCESS, EXCLEXCL)

        // this is the number of parent nodes needed to check if this node is lambda from argument list
        private const val numParentsForLambda = 3
    }
}

is autocorrected into

class Example {
    companion object {
        val operatorsWithNoWhitespace = TokenSet.create(DOT, RANGE, COLONCOLON, SAFE_ACCESS, EXCLEXCL)// this is the number of parent nodes needed to check if this node is lambda
        // from argument list
        private const val NUM_PARENTS_FOR_LAMBDA = 3
        private val keywordsWithSpaceAfter = TokenSet.create(
                // these keywords are followed by {
                ELSE_KEYWORD, TRY_KEYWORD, DO_KEYWORD, FINALLY_KEYWORD, INIT_KEYWORD,
                // these keywords are followed by (
                FOR_KEYWORD, IF_KEYWORD, WHILE_KEYWORD, CATCH_KEYWORD,
                // these keywords can be followed by either { or (
                WHEN_KEYWORD
        )

        
    }
}

and it has a whole lot of problems:

  • comment is getting split and it's parts are shuffled
  • blank lines are left
  • comments are incorrectly formatted after move

Environment information

  • diktat version: 0.1.3
@petertrr petertrr added the bug Something isn't working label Nov 2, 2020
@kentr0w kentr0w self-assigned this Nov 18, 2020
@petertrr petertrr added the autofix Issues related to diktat in autofix mode label Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autofix Issues related to diktat in autofix mode bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants