New rule: RedundantQualifierName
Expected Behavior of the rule
It should recognise and (ideally) fix the RedundantQualifierName violation.
Context
Went through some package + classes movement and Android Studio added the full qualifier for some classes, even though it wasn't necessary.
Such a rule would be especially helpful when dealing with lots of files.
Example
package com.package.my
class Foo(val a: A) {
companion object {
fun from(bar: Bar) : com.package.my.Foo {
/* factory code */
}
}
}
If you run the Redundant qualifier name inspection in IntelliJ / Android Studio, you will see the warning.
Thanks!
Strictly, this is not a violation of the Kotlin coding conventions or Android Kotlin Style Guide. So it does not fit the within the standard ktlint rulesets. Technically, it would not be that hard to write a rule for it and provide it via a custom ruleset.
Ktlint should not try to implement all inspections which are already provided by IntelliJ IDEA and Android Studio.
I become to believe that Ktlint should be restricted
- adding and removing whitespaces and newlines
- adding and removing trailing comma's
- adding and removing braces when needed to improve code readability.
Rules that causes the most problems are typically rules that are violating the principle above. A good example of this is the no-unused-imports rule.