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

WrongEqualsTypeParameter does not ignore multi-parameter equals methods #2230

Closed
FatihYalmanbas opened this issue Jan 8, 2020 · 0 comments
Closed
Milestone

Comments

@FatihYalmanbas
Copy link

WrongEqualsTypeParameter

Expected Behavior of the rule

As stated with the documentation provided, WrongEqualsTypeParameter should only check for equals methods with one parameter.

If function is not top level and name is equals and has one parameter that is not Any? or Kotlin.Any? rule should fail.

Context

For mocking purposes I delegate some of standard library methods to helper classes. such as

interface StringHelper {
    @Contract("null -> true")
    fun isEmpty(input: String?): Boolean

    @JvmDefault
    @Contract("null, null -> true")
    fun equals(left: String?, right: String?, ignoreCase: Boolean = false): Boolean
}

class StringHelperImpl : StringHelper {

    override fun isEmpty(input: String?) = input.isNullOrEmpty()

    override fun equals(left: String?, right: String?, ignoreCase: Boolean): Boolean = left.equals(right, ignoreCase)

}

In this particular case rule fails. I believe rule should ignore equals methods with more than one parameter.

@3flex 3flex closed this as completed in 2486bfa Jan 11, 2020
@arturbosch arturbosch added this to the 1.4.0 milestone Jan 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants