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

refactor: go-vet alert fix. #128

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

Alt-NoRock
Copy link
Member

In go-vet, Fprintln function is not allowed below context:

  • possible formatting directive %f
  • redundant newline
    Thus, use Fprintf instead of Fprintln.

In go-vet, Fprintln function is not allowed below context:
- possible formatting directive %f
- redundant newline
Thus, use Fprintf instead of Fprintln.
@Alt-NoRock
Copy link
Member Author

Short Description

I want to add new defined format.
In fmts/README.md, we need to go test ./... before PR. but this cmd failed.

My Environment

VSCodeSpace used

$ uname -a
Linux codespaces-0ec3fa 5.15.0-1042-azure #49-Ubuntu SMP Tue Jul 11 17:28:46 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
$ go version
go version go1.20.5 linux/amd64
$ git branch
master

Error Log

add new errorformat test failed by go vet

$ go test ./...
ok      github.com/reviewdog/errorformat        0.008s
# github.com/reviewdog/errorformat/cmd/errorformat
cmd/errorformat/main.go:70:2: fmt.Fprintln call has possible formatting directive %f
cmd/errorformat/main.go:70:2: fmt.Fprintln arg list ends with redundant newline
FAIL    github.com/reviewdog/errorformat/cmd/errorformat [build failed]
ok      github.com/reviewdog/errorformat/fmts   0.120s
ok      github.com/reviewdog/errorformat/writer 0.004s
FAIL

if without go vet, test success.

$ go test -vet=off ./...
ok      github.com/reviewdog/errorformat        0.010s
ok      github.com/reviewdog/errorformat/cmd/errorformat        0.003s
ok      github.com/reviewdog/errorformat/fmts   0.122s
ok      github.com/reviewdog/errorformat/writer 0.004s

Reason of bug and countermeasure.

In usage function, use Fprintf instead of Fprintln.
Because usage context includes formatting directive %f:

Example:
	$ echo '/path/to/file:14:28: error message\nfile2:3:4: msg' | errorformat "%f:%l:%c: %m"

Copy link
Contributor

@shogo82148 shogo82148 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shogo82148 shogo82148 merged commit 30beaab into reviewdog:master Aug 7, 2023
5 checks passed
@review-dog
Copy link
Member

Hi, @Alt-NoRock! We merged your PR to reviewdog! 🐶
Thank you for your contribution! ✨

We just invited you to join the @reviewdog organization on GitHub.
Accept the invite by visiting https://github.com/orgs/reviewdog/invitation.
By joining the team, you'll be a part of reviewdog community and can help the maintenance of reviewdog.

Thanks again!

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

Successfully merging this pull request may close these issues.

3 participants