Golangci-lint: lll: support the exclude option

Created on 28 Aug 2018  路  6Comments  路  Source: golangci/golangci-lint

I'd like to exclude comments from the lll output. lll has the --exclude flag I could use for that (https://github.com/walle/lll), but it doesn't seem to be supported by golangcli-lint.

Most helpful comment

Thanks @matoous, that works perfectly!

This is my config, so you can see what to add directly to .golangci.yml:

issues:
  exclude-rules:
    - linters:
        - lll
      source: "^// "

All 6 comments

  1. do you want to exclude only comments?
  2. why do you like to make comments an exception to the line length rule?
  1. For now, yes.
  2. I ran the lll linter on our codebase and found that only comments are affected. Many of them are long for a good reason, ie. a long url that can't be broken up, etc.

In any case, it would be useful to transparently allow the configuration of the underlying linters in the way they support it (i.e. not invent new config rules in golangci-lint and translate them to the underlying linter). Other people might be using lll with another custom exclude rule, for example.

2. Many of them are long for a good reason, ie. a long url that can't be broken up

Exactly the problem I have: it's impossible to make the comment line shorter.

I feel a tiny stab or irony that I have to make the comment _longer_ to ignore it with a nolint[:lll] command, e.g.

// nolint[:lll] See https://longurl.org/path/to/thing/with/commit/has/1232u4t98u98fdugdsgeawefe/now/a/file.txt

Same issue here, trying exclude: ^\/\/.+ but without result. Is this a syntax problem?

Currently there's example in readme for excluding certain patterns from linting.

From README:

    # Exclude lll issues for long lines with go:generate
    - linters:
        - lll
      source: "^//go:generate "

In case of long comments it would be:

    - linters:
        - lll
      source: "^// "

Closing.

Thanks @matoous, that works perfectly!

This is my config, so you can see what to add directly to .golangci.yml:

issues:
  exclude-rules:
    - linters:
        - lll
      source: "^// "
Was this page helpful?
0 / 5 - 0 ratings

Related issues

anuaimi picture anuaimi  路  4Comments

lnshi picture lnshi  路  4Comments

kipply picture kipply  路  4Comments

ferhatelmas picture ferhatelmas  路  4Comments

alessio picture alessio  路  4Comments