Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is it possible to disable warnings for a single line/method? #44

Open
haemi opened this issue Dec 7, 2016 · 2 comments
Open

is it possible to disable warnings for a single line/method? #44

haemi opened this issue Dec 7, 2016 · 2 comments

Comments

@haemi
Copy link

haemi commented Dec 7, 2016

I know that rules can be disabled via configuration, but I would like to disable warnings for single methods only - is this possible?

I.e. the cyclomatic complexity-warning is annoying when a method only contains a switch-statement, therefore I would like to disable it for that method. Can this be achieved somehow?

@S2dentik
Copy link
Contributor

S2dentik commented Dec 7, 2016

For the moment - no, but I guess that could be implemented. A question is what would be the proper way to do it? SwiftLint for example excludes code between two specific comments. I don't think that's nice as that would be ok if we want to exclude a whole class, but for a method we'd have to make our file much dirtier. Two other possibilities are the :

  1. Excludes file
  2. Another command-line option
    And the excluded method would be ClassName.methodName. Although this would mean to hardcode the method a little.
    @thelvis4 what do you think?

@thelvis4
Copy link
Contributor

thelvis4 commented Dec 7, 2016

@haemi Currently, there is no option to disable warnings per line / per function.
You can ignore a whole file, though. You can do this either by using an excludes file (like this one) or by specifying it directly with -e option (ex. taylor -e Taylor/main.swift).

@S2dentik I think the ugly method SwiftLint is using is still the most reliable one, because:

  • It allows you to change class/function name with no need to make any change in how you call taylor.
  • If you delete the class/function, it's easier to spot that you don't need the exclude comments.

Actually, using special comments is the way most tools (not just for Swift) manage the fine grained exclusions. Eventually, we could go with this option and implement it in taylor as well. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants