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

#1002 - add "checkPublicInterface" option to "exported" rule to allow check documentation on public methods on public interfaces #1003

Merged
merged 11 commits into from
Jul 30, 2024

Conversation

comdiv
Copy link
Contributor

@comdiv comdiv commented Jun 28, 2024

Feature implementation for #1002

rule/exported.go Outdated Show resolved Hide resolved
@chavacava
Copy link
Collaborator

Hi @comdiv. Are you still working in the PR? (some tests are not passing)

Copy link
Contributor

@ccoVeille ccoVeille left a comment

Choose a reason for hiding this comment

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

I found a few things. Maybe you could consider them

rule/exported.go Outdated Show resolved Hide resolved
rule/exported.go Show resolved Hide resolved
rule/exported.go Outdated Show resolved Hide resolved
@comdiv comdiv requested a review from ccoVeille July 22, 2024 06:16
@mgechev
Copy link
Owner

mgechev commented Jul 24, 2024

@chavacava I'm ready to merge when you also approve.

Comment on lines +328 to +329
if iface, ok := v.Type.(*ast.InterfaceType); ok {
if ast.IsExported(v.Name.Name) {
Copy link
Collaborator

@denisvmedia denisvmedia Jul 29, 2024

Choose a reason for hiding this comment

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

I'd maybe change it to

Suggested change
if iface, ok := v.Type.(*ast.InterfaceType); ok {
if ast.IsExported(v.Name.Name) {
if ast.IsExported(v.Name.Name) {
if iface, ok := v.Type.(*ast.InterfaceType); ok {

This is to avoid preliminary type assertions for non-exported symbols.

P.S. And if so, two outer ifs would be possible to join as a single if (if w.checkPublicInterface && ast.IsExported(v.Name.Name)).

Comment on lines +32 to +35
flagStr, ok := flag.(string)
if !ok {
panic(fmt.Sprintf("Invalid argument for the %s rule: expecting a string, got %T", r.Name(), flag))
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: the switch/case below can work without this assertion (it can compare flag to case values directly).


type somePrivate interface {
AllGood()
}
Copy link
Collaborator

@denisvmedia denisvmedia Jul 29, 2024

Choose a reason for hiding this comment

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

nit (add a new line)

Suggested change
}
}

Copy link
Collaborator

@denisvmedia denisvmedia left a comment

Choose a reason for hiding this comment

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

LGTM (few nits though)

@chavacava chavacava merged commit 8f9edc9 into mgechev:master Jul 30, 2024
4 checks passed
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.

None yet

6 participants