github.com/elek/golangci-lint@v1.42.2-0.20211208090441-c05b7fcb3a9a/pkg/golinters/nolintlint/README.md (about)

     1  # nolintlint
     2  
     3  nolintlint is a Go static analysis tool to find ill-formed or insufficiently explained `// nolint` directives for golangci
     4  (or any other linter, using th ) 
     5  
     6  ## Purpose
     7  
     8  To ensure that lint exceptions have explanations.  Consider the case below:
     9  
    10  ```Go
    11  import "crypto/md5" //nolint
    12  
    13  func hash(data []byte) []byte {
    14  	return md5.New().Sum(data) //nolint
    15  }
    16  ```
    17  
    18  In the above case, nolint directives are present but the user has no idea why this is being done or which linter
    19  is being suppressed (in this case, gosec recommends against use of md5).  `nolintlint` can require that the code provide an explanation, which might look as follows:
    20  
    21  ```Go
    22  import "crypto/md5" //nolint:gosec // this is not used in a secure application
    23  
    24  func hash(data []byte) []byte {
    25  	return md5.New().Sum(data) //nolint:gosec // this result is not used in a secure application
    26  }
    27  ```
    28  
    29  `nolintlint` can also identify cases where you may have written `//  nolint`.  Finally `nolintlint`, can also enforce that you
    30  use the machine-readable nolint directive format `//nolint` and that you mention what linter is being suppressed, as shown above when we write `//nolint:gosec`.
    31