NEAL icon indicating copy to clipboard operation
NEAL copied to clipboard

Incorrectly labeling of ImplicitlyUnwrappedOptional

Open benhjerrild opened this issue 6 years ago • 0 comments

The following code and rule incorrectly result in a NEAL failure.

public class MyObject {
    public func myFunc(_ object: Any) -> Bool {
        return object as? Dictionary<AnyHashable, Any> != nil
    }
}
rule Bang {
  Swift::TypeIdentifier where ImplicitlyUnwrappedOptional == true {
    fail("No forced unwrapping allowed")
  }
}

Since there is no force unwrap the test should not fail.

When parens are added the rule no longer results in a NEAL failure.

public class MyObject {
    public func myFunc(_ object: Any) -> Bool {
        return (object as? Dictionary<AnyHashable, Any>) != nil
    }
}

benhjerrild avatar Feb 12 '19 00:02 benhjerrild