0

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
}
Edhar Khimich
  • 1,468
  • 1
  • 17
  • 20

1 Answers1

0

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)

S. Gomez
  • 296
  • 4