saveourtool / diktat

Strict coding standard for Kotlin and a custom set of rules for detecting code smells, code style issues and bugs
https://diktat.saveourtool.com
MIT License
537 stars 39 forks source link

Have Calls to Extension Functions Respect `maxCallsInOneLine` #1705

Closed adamsmd closed 10 months ago

adamsmd commented 1 year ago

Describe the bug

The number of allowed extension function calls on a line does not seem to respect [WRONG_NEWLINES].maxCallsInOneLine.

Steps to Reproduce

In diktat.kt:

- name: WRONG_NEWLINES
  configuration:
    maxParametersInOneLine: 100
    maxCallsInOneLine: 100

Somewhere in your Kotlin code:

3.toInt().toInt().toInt().toInt()

(Granted, using toInt() repeatedly this way is dumb. This is just to make the example simple.)

Expected behavior

No warning from DiKTat.

Observed behavior

DiKTat produces the following warning:

[WRONG_NEWLINES] incorrect line breaking: wrong split long `dot qualified expression` or `safe access expression` (diktat-ruleset:newlines)

Notes

This issue seems to be related to the use of a magic number instead of a configuration variable at the following, but I don't understand enough of the code to know if that number controls other things: https://github.com/saveourtool/diktat/blob/9c96ec43e36818a325bb43e4ef12ceffa838828a/diktat-rules/src/main/kotlin/com/saveourtool/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt#L160

Environment information

nulls commented 1 year ago

hi @adamsmd, thanks for raising the issue. We will look into it