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

Add analysis of fully-qualified expression in NewLines rule #1403

Closed
Arrgentum opened this issue Jun 27, 2022 · 1 comment · Fixed by #1411
Closed

Add analysis of fully-qualified expression in NewLines rule #1403

Arrgentum opened this issue Jun 27, 2022 · 1 comment · Fixed by #1411
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Arrgentum
Copy link
Member

Arrgentum commented Jun 27, 2022

Describe the bug

Fully-qualified expression should not be separated

Initial code:

private val holder: java.util.concurrent.atomic.AtomicReference<T> = java.util.concurrent.atomic.AtomicReference(valueToStore)
private val holder: kotlin.native.concurrent.AtomicReference<T> = kotlin.native.concurrent.AtomicReference(valueToStore)

Expected behavior

private val holder: java.util.concurrent.atomic.AtomicReference<T> = java.util.concurrent.atomic.AtomicReference(valueToStore)
private val holder: kotlin.native.concurrent.AtomicReference<T> = kotlin.native.concurrent.AtomicReference(valueToStore)

Observed behavior

private val holder: java.util.concurrent.atomic.AtomicReference<T> = java.util
        .concurrent
        .atomic
        .AtomicReference(valueToStore)
private val holder: kotlin.native.concurrent.AtomicReference<T> = kotlin.native
        .concurrent
        .AtomicReference(valueToStore)

Environment information

  • diktat version: 1.2.0
  • kotlin version: 1.6
@Arrgentum Arrgentum added the bug Something isn't working label Jun 27, 2022
@orchestr7 orchestr7 added this to the 1.2.1 milestone Jun 27, 2022
@orchestr7
Copy link
Member

Solution: parentExpressionList?.dropWhile { !it.treeParent.textContains('(') && !it.treeParent.textContains('{') }

That will format the following: java.util.Test().map().size

To the following format:

java.util.Test()
.map()
.size

Only the following code won't be covered:

test.list.size

but that is the problem of code author :)

Arrgentum pushed a commit that referenced this issue Jun 27, 2022
Arrgentum pushed a commit that referenced this issue Jun 27, 2022
Arrgentum pushed a commit that referenced this issue Jun 28, 2022
 * add analytic fully-qualified
 * add test
 * correct warning message

## Issue (#1403)
Arrgentum pushed a commit that referenced this issue Jun 28, 2022
 * add analytic fully-qualified
 * add test
 * correct warning message
 * run fix mode

## Issue (#1403)
Arrgentum pushed a commit that referenced this issue Jun 28, 2022
 * add analytic fully-qualified
 * add test
 * correct warning message
 * run fix mode

## Issue (#1403)
Arrgentum pushed a commit that referenced this issue Jun 28, 2022
 * add analytic fully-qualified
 * add test
 * correct warning message
 * run fix mode

## Issue (#1403)
Arrgentum pushed a commit that referenced this issue Jun 28, 2022
 * add analytic fully-qualified
 * add test
 * correct warning message
 * run fix mode

## Issue (#1403)
Arrgentum added a commit that referenced this issue Jun 29, 2022
#1411)

## Whats added:
* Added logic fully-qualified - don't separate fully-qualified as a regular `dot qualified expression`
* Added 1 fix test and 5 tests examples
* Correct warning message

## Issue #1403
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants