golangci-lint icon indicating copy to clipboard operation
golangci-lint copied to clipboard

Idea: support "nolint ranges"

Open alecthomas opened this issue 7 years ago • 9 comments

Revive has the concept of begin/end blocks for nolinting. See here.

This could be useful under some circumstances.

alecthomas avatar Jun 25 '18 21:06 alecthomas

I would like to see this implemented. My use-case: disable gocyclo for a specific exported method without exposing nolint:gocyclo in the godoc.

AlekSi avatar Jul 25 '18 12:07 AlekSi

Stale bot went rampant. @jirfag please reopen.

AlekSi avatar Oct 16 '19 06:10 AlekSi

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 13 '20 09:04 stale[bot]

My use-case: disable gocyclo for a specific exported method without exposing nolint:gocyclo in the godoc.

That's still a problem.

AlekSi avatar Apr 13 '20 10:04 AlekSi

@AlekSi is there a reason you're not able to do:

// Save provides a complex save method!
func Save() { // nolint:gocyclo

theckman avatar May 18 '20 04:05 theckman

A better exemple coud be:

// Save provides a complex save method using third-party library with really long method names.
func Save() {
  ...
  very long line of code //nolint:lll
  ...
  another very long line of code //nolint:lll
  ...
  one more //nolint:lll
  ...
}

AlekSi avatar May 18 '20 05:05 AlekSi

@AlekSi I appreciate that other use cases exist, I was asking if my suggestion works for your specific challenge above.

theckman avatar May 18 '20 09:05 theckman

I have just had the experience of ignore lll reports like @AlekSi mentioned, and I've been wanting this feature too. Can I be the assignee for this Issue?

I'm thinking of doing ignore as follows.

func Save() {
  //nolint-begin:lll
  very long line of code 
  another very long line of code
  one more 
  ...
  //nolint-end:lll
}

Please give your opinions on this idea. (And other opinions are also verrry welcome.)

sanposhiho avatar May 03 '21 12:05 sanposhiho

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 10 '22 18:07 stale[bot]