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
Why should this rule be added? Share links to existing discussion about what
the community thinks about this.
This is somewhat similar to #1885 -- optional Bools are similar to optional collections in that an "empty" Bool rarely conveys much information.
I haven't found any existing discussions about this, but I have seen folks trying different solutions to dealing with optional Bools, all of which, to me, are not pretty. (see for example: Rule Request: Avoid optional collections)
Provide several examples of what would and wouldn't trigger violations.
// Properties should provide default valueletfoo:Bool= false
// functions should return Bool instead of optional Boolfunc foo()->Bool// input params should default to true or false instead of being optionalfunc foo(bar:Bool= false)// Optional Bool's can arise from collectionsletjsonData:[String:Any]letfoo:Bool?=jsonData["foo"]as?Bool
Should the rule be configurable, if so what parameters should be configurable?
No
Should the rule be opt-in or enabled by default? Why?
See README.md for guidelines on when to mark a
rule as opt-in.
I'm curious what others think, but I would probably see this as an opt-in rule.
The text was updated successfully, but these errors were encountered:
ejmartin504
changed the title
Rule Request: Avoid optional bools
Rule Request: Avoid optional Bools
Jan 19, 2018
New Issue Checklist
Rule Request
the community thinks about this.
This is somewhat similar to #1885 -- optional Bools are similar to optional collections in that an "empty" Bool rarely conveys much information.
I haven't found any existing discussions about this, but I have seen folks trying different solutions to dealing with optional Bools, all of which, to me, are not pretty. (see for example: Rule Request: Avoid optional collections)
Would trigger:
These would not trigger:
No
See README.md for guidelines on when to mark a
rule as opt-in.
I'm curious what others think, but I would probably see this as an opt-in rule.
The text was updated successfully, but these errors were encountered: