Swiftlint: Disable line_length rule for comments

Created on 15 Nov 2017  路  6Comments  路  Source: realm/SwiftLint

Hi, quick question here : I have the line_length rule enabled in my project but I was wondering if it was possible to disable it for comments, and eventually classes signatures. Thanks!

enhancement

Most helpful comment

Hello @giofid,

I think this is the way to set it

line_length: 
    warning: 200
    ignores_comments: true

Let me know if that helps.

All 6 comments

@raaaphh line_length rule already can ignore comments. It can be configured by adding following lines to your .swiftlint.yml

line_length: 
  ignores_comments: true

As for classes signatures, is that desired @marcelofabri ?

Could be useful to have a different configuration setting for declaration signatures, either different lengths or disabling.

Closing this because the original issue was about disabling it for comments. Feel free to open a new issue for tracking disabling it for declaration signatures.

Hi,
Currently, in my .swiftlint.yml I have

line_length: 200

Now, if I add ignores_comments: true

line_length: 200
    ignores_comments: true

I obtain this error:

scanner: mapping values are not allowed in this context:

I would like to have only line_length warning (no error) after 200 characters and ignore comments. How can i achieve this?

Hello @giofid,

I think this is the way to set it

line_length: 
    warning: 200
    ignores_comments: true

Let me know if that helps.

Thank you @sammy-SC,
I already tried your suggestion, but

line_length: 200

and

line_length: 
    warning: 200

are not equivalent. If i run swiftlint rules command, in the former case I obtain the below configuration for line_length:

| line_length | ... | warning: 200, ignores urls: false, ignores function declarations: false, ignores comments: false, ignores interpolated strings: false |

In the latter case, I obtain

| line_length | ... | warning: 200, error: 200, ignores urls: false, ignores function declarations: false, ignores comments: false, ignores interpolated strings: false |

In the latter case, as you can see, there is an error: 200 extra.

So, set just the warning level implicitly it seems different from set just the warning level explicitly (the error level is set too).

How can I set just the warning level and ignore the comments?

Was this page helpful?
0 / 5 - 0 ratings