Skip to content
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

Can we detect generated file like VSCode or Jetbrains do? #11

Closed
frederikhors opened this issue Mar 24, 2022 · 7 comments
Closed

Can we detect generated file like VSCode or Jetbrains do? #11

frederikhors opened this issue Mar 24, 2022 · 7 comments

Comments

@frederikhors
Copy link

Can we detect generated file like VSCode or Jetbrains do?

Using top line in file like: // Code partially generated. or // Code generated by xxx, DO NOT EDIT..

In generated files we can have very long functions.

@martialblog
Copy link
Contributor

This might be better solved with exclude-rules in the .golangci.yml config

issues:
  exclude-rules:
    - path: path/to/generated/code.go
      linters:
        - funlen

@martialblog
Copy link
Contributor

@robinknaapen You think this is also solved with #18 ?

@robinknaapen
Copy link
Contributor

robinknaapen commented Jul 28, 2023

@frederikhors

I thought that golangci-lint already ignored generated files by default. The following example does not trigger funlen

Given this basic config

linters:
  disable-all: true
  enable:
    - funlen
 
linters-settings:
  funlen:
    lines: 5
    statements: 10

And this code

main.go

package main

import "fmt"

func main() {
	fmt.Println(Generated())
}

generated.go

// Code generated by Crow, DO NOT EDIT

package main

func Generated() string {
	// I have a lot of
	// comments
	// This will trigger the linter
	//
	//
	// for sure :)

	return "generated"
}

@robinknaapen
Copy link
Contributor

@martialblog, @frederikhors

Am I correct on my previous comment?

I am kind of reluctant to add another "hint" to the README. Since most of the cases can be distilled from the official documentation better.

@frederikhors
Copy link
Author

frederikhors commented Jul 31, 2023

I'm sorry. I'm not using Go these days. I can't help.

@martialblog
Copy link
Contributor

martialblog commented Jul 31, 2023

@robinknaapen yes you are right, autogenerated code is detected by golangci-lint.

@robinknaapen
Copy link
Contributor

Then I can close this issue I suppose. If I am wrong, feel free to re-open

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

3 participants