gojp / goreportcard

A report card for your Go application
https://goreportcard.com
Apache License 2.0
1.99k stars 252 forks source link

gofmt issue with header comment not reproducable locally #411

Closed TLINDEN closed 1 year ago

TLINDEN commented 1 year ago

Hello,

all my source files contain a header like this:

/*
Copyright © 2023 ....

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cmd

When I run gofmt -s locally against such files, it is happy. However, the goreportcard reports:

cmd/root.go
Line 1: warning: file is not gofmted with -s (gofmt)

I am pretty sure, this could be easily fixed by just moving the package cmd line to the top. But this is not how open source files have to look IMHO.

TLINDEN commented 1 year ago

I found the problem. "line 1" refers to the first non-comment line. So, this is what caused the warning:

[..]
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package cmd

The empty line above the package line is not allowed, so this is the fix:

[..]
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cmd

Although I use emacs which calls gofmt -s everytime I save a go file, it doesn't fix this one issue, for whatever reason.