Skip to content

Incorrectly labeling of ImplicitlyUnwrappedOptional #20

@benhjerrild

Description

@benhjerrild

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
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions