In the following code snippet SonarCloud reports the else
as redundant:
val useDeviceTimeZone = if (isEmpty()) false else repository.readUseDeviceTimeZoneEnabled()
Here is the full function:
https://sonarcloud.io/organizations/eventfahrplan/rules?open=kotlin%3AS1125&rule_key=kotlin%3AS1125
Hi @tobiaspreuss,
This looks like a true positive to me. Your case seems to be the same as the following line in the noncompliant example of the rule description:
booleanVariable = if (booleanMethod()) false else exp;
It therefore can be replaced as follows:
val useDeviceTimeZone = !isEmpty() && repository.readUseDeviceTimeZoneEnabled()
Cheers,
Sebastian
1 Like
Thank you. This wasn’t obvious to me.
system
(system)
Closed
6
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.