Edhar Khimich
Edhar Khimich

Reputation: 1674

Explanation on lint warnings for some of my properties

Analyzing code I found these warnings. Could someone explain me some details about them please. Any alternatives will be welcome

interface A {
   var someBoolean: Boolean // Boolean method 'someBoolean' is always inverted
}

class B {
   var visible: Boolean by mutableStateOf(false) // Method 'visible' is always inverted + The method is empty
       private set // The method is empty
}

Upvotes: 0

Views: 71

Answers (1)

S. Gomez
S. Gomez

Reputation: 616

The "problem" is not usually there. You have to check how you use these methods.

Do you always use these methods in a "not" expression (ie. !someBoolean, !visible, ...)? If so, linter thinks it would be a better idea to reverse the logic of the method so you dont't always have to use the NOT operator.

“Negatives are just a bit harder to understand than positives. So, when possible, conditionals should be expressed as positives.” (4. Avoiding negative conditionals)

Upvotes: 0

Related Questions