Skip to content

lll: support the exclude option #207

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

Closed
benma opened this issue Aug 28, 2018 · 8 comments
Closed

lll: support the exclude option #207

benma opened this issue Aug 28, 2018 · 8 comments

Comments

@benma
Copy link

benma commented Aug 28, 2018

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.

@jirfag
Copy link
Contributor

jirfag commented Aug 29, 2018

  1. do you want to exclude only comments?
  2. why do you like to make comments an exception to the line length rule?

@benma
Copy link
Author

benma commented Aug 30, 2018

  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.

@henrahmagix
Copy link

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

@nerder
Copy link

nerder commented May 13, 2019

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

@matoous
Copy link
Contributor

matoous commented Sep 24, 2019

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.

@matoous matoous closed this as completed Sep 24, 2019
@henrahmagix
Copy link

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: "^// "

johnboyes added a commit to agilepathway/gauge-confluence that referenced this issue Jul 12, 2021
johnboyes added a commit to agilepathway/gauge-confluence that referenced this issue Jul 12, 2021
johnboyes added a commit to agilepathway/gauge-confluence that referenced this issue Jul 12, 2021
johnboyes added a commit to agilepathway/gauge-confluence that referenced this issue Jul 13, 2021
* Do not publish directories with no specs

This commit ensures that any directories without any specs in them are
not published to Confluence.  Prior to this commit these directories
were being published, appearing in Confluence as pages without any
content or subpages. This was distracting when trying to browse the
published specs in Confluence.

One example of this manifesting itself prior to this commit was if the
Gauge [concept files][1] were put into their own concepts directory.
As we only publish specs and not concepts to Confluence, having concepts
in their own directory was leading to empty directory pages being
published prior to this commit.

The functional tests implementation code in this commit was lifted and
shifted with only minor alterations from [the functional tests repo for
core Gauge][2] (just like the existing functional test implementation
code) - no point in reinventing the wheel.

One other noteworthy thing is that the code to delete a page uses the
low level [Go net http client][3], rather than the higher level
[confluence-go-api client][4]. This is because there was a subtle bug
with the confluence-go-api client (it was returning an error even after
a successful delete, despite returning [the correct 204 status
code][5]). It may be worth removing the confluence-go-api client
altogether in a future pull request, as [minimising dependencies is
generally a good thing][6].

[1]: https://docs.gauge.org/writing-specifications.html#concepts
[2]: https://github.com/getgauge/gauge-tests
[3]: https://pkg.go.dev/net/http
[4]: https://github.com/Virtomize/confluence-go-api
[5]: https://developer.atlassian.com/server/confluence/confluence-rest-api-examples/#delete-a-page
[6]: https://endjin.com/blog/2018/09/whose-package-is-it-anyway-why-its-important-to-minimise-dependencies-in-your-solutions

* Remove unused import

* Exclude long urls in comments from go linting

As per:
golangci/golangci-lint#207 (comment)

* Bump plugin minor version
@alvaroaleman
Copy link

#207 (comment)

This only works for comments on top-level objects, as otherwise there is preceeding whitespace. And for some reason \s isn't supported, so ^\s*// results in a While parsing config: yaml: line 103: found unknown escape character?

@ktong
Copy link

ktong commented Mar 29, 2024

\s*

#207 (comment)

This only works for comments on top-level objects, as otherwise there is preceeding whitespace. And for some reason \s isn't supported, so ^\s*// results in a While parsing config: yaml: line 103: found unknown escape character?

it should be ^\t*//

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

7 participants