Hi,
On the following input:
class Foo
def self.foo(att, val = nil, exception: true)
maybe_rescue =
->(proc) {
if exception
proc[]
else
begin
proc[]
rescue => e
logger.warn "ignored an error: #{e}"
nil
end
end
}
if val.is_a?(String)
case att
when nil then nil
when :birth_date, 'birth_date' then val = maybe_rescue[->{Date.parse(val)}]
when :created_at, 'created_at' then val = maybe_rescue[->{DateTime.parse(val)}]
end
end
end
end
I get a false positive about maybe_rescue
: “Remove this unused “maybe_rescue” local variable.”
This is sonar on macOS, downloaded as a zip.
- sonar-scanner-5.0.1.3006-macosx
- sonarqube-10.2.1.78527/bin/macosx-universal-64
Sorry if this is not the right place, I’m new to Sonar.
Cheers!