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

Conventional Range rule appears to be broken #1502

Closed
andrewparmet opened this issue Aug 11, 2022 · 3 comments · Fixed by #1524
Closed

Conventional Range rule appears to be broken #1502

andrewparmet opened this issue Aug 11, 2022 · 3 comments · Fixed by #1524
Assignees
Labels
bug Something isn't working
Milestone

Comments

@andrewparmet
Copy link

Describe the bug

We're being required to replace a range created with .. with a non-equal range.

Expected behavior

Range replacements should be equal.

Observed behavior

They are not.

Steps to Reproduce

Write code like 0..(string.length - 2)) and see that it's corrected to 0 until (string.length)). Here's a demonstration of the difference:

fun main(args: Array<String>) {
    val string = "abc123"
    println(string.substring(0..(string.length - 2)))  // prints abc12
    println(string.substring(0 until (string.length))) // prints abc123
}

Environment information

  • diktat version: 1.0.3 (and cannot upgrade easily due to conflicts between Spotless/Ktlint/DiKTat)
  • build tool (maven/gradle): gradle
  • how is diktat run (CLI, plugin, etc.): spotless
  • kotlin version: 1.6.21
  • operating system: Mac
  • link to a project (if your project is public):
@andrewparmet andrewparmet added the bug Something isn't working label Aug 11, 2022
@petertrr
Copy link
Member

Hi @andrewparmet! Thanks for your report. While the behavior you have described is definitely a bug, could you please also describe a bit more about why it's not easy to upgrade diktat? Starting with spotless-gradle-plugin 6.8.0 minimal supported version of diktat is 1.2.1 because of some breaking changes in the ktlint framework. Do you face problems related to this?

@andrewparmet
Copy link
Author

Probably - I was getting NoClassDefFoundErrors related to some internal ktlint config classes. I was trying a blind upgrade to see if the rule had been fixed in the latest version, but it doesn't look like it's been touched since it was written.

@orchestr7
Copy link
Member

orchestr7 commented Sep 13, 2022

@petertrr could you please have a look. Looks critical as also affects checks

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
Development

Successfully merging a pull request may close this issue.

4 participants