Taylor icon indicating copy to clipboard operation
Taylor copied to clipboard

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

Open haemi opened this issue 7 years ago • 2 comments

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?

haemi avatar Dec 07 '16 06:12 haemi

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?

S2dentik avatar Dec 07 '16 08:12 S2dentik

@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. 😊

thelvis4 avatar Dec 07 '16 09:12 thelvis4