revive icon indicating copy to clipboard operation
revive copied to clipboard

[Feature request] Check comment spacing

Open chen3feng opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe.

In our projects, some comments didn't follow the style guides, such as commented code:

	//t.Log(err)
	//t.Log(targets)

or the normal comments:

	ClientIp   string `protobuf:"bytes,11,opt,name=client_ip,json=clientIp,proto3" json:"client_ip,omitempty"`       //client IP
	ClientIpv6 string `protobuf:"bytes,12,opt,name=client_ipv6,json=clientIpv6,proto3" json:"client_ipv6,omitempty"` // client IPv6

There should be a space between the leading // and the comment text.

Describe the solution you'd like Add a rule to check commit spacing.

But for line comments, special comments such as compile directives:

//go:noinline
//go:generate go mod tidy
//go:generate mockgen
//revive:disable

should be allowed. We can use a whitelist to allow these forms. The default whitelist can be

"\w+:\w+"

, which can match most special comments.

chen3feng avatar Aug 16 '22 04:08 chen3feng

I'd like that rule! Do you want to implement it and we can merge?

mgechev avatar Aug 18 '22 19:08 mgechev

I'd like to implement this feature.

chen3feng avatar Sep 02 '22 00:09 chen3feng

Hi, May I work on this issue?

qascade avatar Oct 04 '22 20:10 qascade

Thanks, for assigning this issue to me. Going through the code base. Will get back to you, if I have any issues. Will raise a draft PR, half way through and request a review once done.

qascade avatar Oct 07 '22 01:10 qascade

Are there any other special comments or directives that I should look out for other than those mentioned in the issue? Is there a list that I can refer to ?? I can add a logic to match //go:* and //revive:* expression. Or would you rather like me to have a hard coded list?

qascade avatar Oct 17 '22 11:10 qascade

Thanks @chavacava for the merge. If there are any other issues that I can work on, please let me know. I think this issue can be closed.

qascade avatar Oct 29 '22 17:10 qascade

Thanks @qascade!

mgechev avatar Oct 31 '22 21:10 mgechev