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

revive: improve 'exported' rule output. #1994

Merged
merged 1 commit into from May 19, 2021

Conversation

ldez
Copy link
Member

@ldez ldez commented May 17, 2021

Fixes #1993

example.go
package main

import "fmt"

var HorribleGlobalVar = map[int]string{
	1:    "s1",
	2:    "s2",
	3:    "s3",
	2000: "s2000",
}

var (
	GroupOfHorribleGlobalVar = map[int]string{
		1:    "s1",
		2:    "s2",
		3:    "s3",
		2000: "s2000",
	}
)

type Foo struct {
	S1 string
	S2 string
	S3 string
	S4 string
	S5 string
}

func Goo() {
	to := "test"

	fmt.Println(to)
}
.golangci.yml
linters:

  disable-all: true
  enable:
    - revive

issues:
  exclude-use-default: false
before the PR
$ golangci-lint run --disable-all -Erevive
main.go:5:5: exported: exported var HorribleGlobalVar should have comment or be unexported (revive)
var HorribleGlobalVar = map[int]string{
        1:    "s1",
        2:    "s2",
        3:    "s3",
        2000: "s2000",
}
main.go:13:2: exported: exported var GroupOfHorribleGlobalVar should have comment or be unexported (revive)
        GroupOfHorribleGlobalVar = map[int]string{
                1:    "s1",
                2:    "s2",
                3:    "s3",
                2000: "s2000",
        }
main.go:21:6: exported: exported type Foo should have comment or be unexported (revive)
type Foo struct {
        S1 string
        S2 string
        S3 string
        S4 string
        S5 string
}
main.go:29:1: exported: exported function Goo should have comment or be unexported (revive)
func Goo() {
        to := "test"

        fmt.Println(to)
}
with the PR
$ ./golangci-lint run --disable-all -Erevive
main.go:5:5: exported: exported var HorribleGlobalVar should have comment or be unexported (revive)
var HorribleGlobalVar = map[int]string{
    ^
main.go:13:2: exported: exported var GroupOfHorribleGlobalVar should have comment or be unexported (revive)
        GroupOfHorribleGlobalVar = map[int]string{
        ^
main.go:21:6: exported: exported type Foo should have comment or be unexported (revive)
type Foo struct {
     ^
main.go:29:1: exported: exported function Goo should have comment or be unexported (revive)
func Goo() {
^

@ldez ldez added the enhancement New feature or improvement label May 17, 2021
@ldez ldez force-pushed the feat/revice-exported-source-scope branch from 752513e to 782e806 Compare May 19, 2021 14:41
@ldez ldez merged commit 62668d4 into golangci:master May 19, 2021
@ldez ldez deleted the feat/revice-exported-source-scope branch May 19, 2021 23:17
SeigeC pushed a commit to SeigeC/golangci-lint that referenced this pull request Apr 4, 2023
@ldez ldez added this to the v1.41 milestone Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

revive: cut output from exported rule
2 participants