Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Rule Request: Avoid optional Bools #2011
New Issue Checklist
This is somewhat similar to #1885 -- optional Bools are similar to optional collections in that an "empty" Bool rarely conveys much information.
let foo: Bool? let bar: Bool? = false let baz = Optional.some(false)
These would not trigger:
// Properties should provide default value let foo: Bool = false // functions should return Bool instead of optional Bool func foo() -> Bool // input params should default to true or false instead of being optional func foo(bar: Bool = false) // Optional Bool's can arise from collections let jsonData: [String: Any] let foo: Bool? = jsonData["foo"] as? Bool
I'm curious what others think, but I would probably see this as an opt-in rule.