-
Notifications
You must be signed in to change notification settings - Fork 48
Add support for disabled/ignored regions #324
Description
// tailor:disable is very useful for cases where we just don't want to make a line conform for some reason, but this could be even more powerful if it were extended to a region:
// tailor:ignore-begin
// begin a section of code which I want to ignore
let foos = fooResult.map { ($0 as! Foo).foo! } // no warning
let bars = barResult.map { ($0 as! Bar).bar! } // no warning
// tailor:ignore-end
let baz = qux as! Baz // warning!An example use case is our tests. We'd prefer to run every swift file possible through Tailor because we want to adhere to those standards wherever possible, but there are just some cases (JSON parsing is a good one) where we want to consider it OK to force-cast and the like (after all, this is only a contrived test example), and we don't want to include the disable comment on every line.
Another use case might be formatted dictionaries, where we want to disregard the normal colon whitespace rules to improve readability:
// tailor:ignore-begin
let dict = ["foo" : "whatever",
"automobiles" : "trains",
"apples" : "oranges",
"cars" : "planes"]
// this is only a few items long, but you can imagine a much larger dictionary/collection structure.
// tailor:ignore-endObviously this syntax is just a suggestion, I'm sure you could settle on whatever best fits the conventions that you want Tailor to follow.