You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The nonzero? method returns self if num is not zero, nil otherwise, and not a boolean. Causing false positive with the Style/IfWithBooleanLiteralBranches cop with code such as val.nonzero? ? true : false
Expected behavior
The cop should not flag statements such as val.nonzero? ? true : false
…nLiteralBranches`
Fixesrubocop#9459.
This PR adds `AllowedMethods` option to `Style/IfWithBooleanLiteralBranches` and
set `nonzero?` as default value.
The
nonzero?
method returns self if num is not zero, nil otherwise, and not a boolean. Causing false positive with theStyle/IfWithBooleanLiteralBranches
cop with code such asval.nonzero? ? true : false
Expected behavior
The cop should not flag statements such as
val.nonzero? ? true : false
Actual behavior
Steps to reproduce the problem
Run the cop against code like
val.nonzero? ? true : false
, for example https://github.com/wpscanteam/CMSScanner/blob/master/lib/cms_scanner/web_site.rb#L74RuboCop version
The text was updated successfully, but these errors were encountered: