Swiftlint: Ignore rule based on regex?

Created on 17 Mar 2016  路  5Comments  路  Source: realm/SwiftLint

Thanks for making this awesome swift linter. :sparkles:
I am just getting started to setup SwiftLint for my projects.

I usually have a lot of NSLocalizedString calls that exceed my configured line_length of 200.
I have successfully ignored these warnings by appending // swiftlint:disable:this line_length to the problematic lines in my project, but was wondering if there would be a _global_ way to just disable line_length warnings/errors for all lines that contain NSLocalizedString?

enhancement

Most helpful comment

+1

Another case where it would be useful is force_cast (see #69), so a generic ignore_regex option would be great. Even better if it would be an option in custom_rules as well.

All 5 comments

+1

Another case where it would be useful is force_cast (see #69), so a generic ignore_regex option would be great. Even better if it would be an option in custom_rules as well.

For force_cast and force_unwrap I definitely have code that is exactly the way I want it but which always generates the errors. cellForRowAtIndexPath always dequeues a cell and force casts it to the correct UITableView subclass. There's not a good way to change that code to avoid the force cast.

Also, my use of UIImage(named:) requires a force unwrap. I always want to know during development if that call fails. So the force unwrap is like an assert and I want it in my code.

The inability to configure these rules reduces my liklihood of adopting swiftlint because of the spew of errors I have to wade through to find the legitimate bad code.

Anyway, I like the tool but would like some greater ability to configure these rules.

@phoney, have you considered using https://github.com/mac-cain13/R.swift ?

Closing this due to lack of activity. You can ignore rules locally using swiftlint:disable as mentioned on the README which is a more general solution than ignoring based on a regex.

Need this feature.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BalestraPatrick picture BalestraPatrick  路  3Comments

muzamilhassan1987 picture muzamilhassan1987  路  3Comments

jcarroll-mediafly picture jcarroll-mediafly  路  3Comments

Tableau-David-Potter picture Tableau-David-Potter  路  3Comments

tomasebrennan picture tomasebrennan  路  3Comments