Skip to content

Commit

Permalink
Flip test comment flag name and value
Browse files Browse the repository at this point in the history
Provides a better UX as specifying a falsy value for a flag can be a bit
annoying on CLI.
  • Loading branch information
ashmrtn committed Jun 19, 2023
1 parent ec3c340 commit d5686d0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions pkg/commentmimic/commentmimic.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ const (
CommentExportedFuncsFlag = "comment-exported"
CommentAllExportedFuncsFlag = "comment-all-exported"
CommentInterfacesFlag = "comment-interfaces"
NoTestCommentsFlag = "no-test-comments"
CommentTestsFlag = "comment-tests"
CommentStructsFlag = "comment-structs"
)

Expand All @@ -374,7 +374,7 @@ type mimic struct {
commentAllExportedFuncs bool
commentInterfaces bool
commentStructs bool
noTestComments bool
commentTests bool
}

func New() *analysis.Analyzer {
Expand Down Expand Up @@ -403,10 +403,10 @@ func New() *analysis.Analyzer {
)

fs.BoolVar(
&m.noTestComments,
NoTestCommentsFlag,
true,
"don't require comments on tests, benchmarks, examples, and fuzz tests",
&m.commentTests,
CommentTestsFlag,
false,
"require comments on tests, benchmarks, examples, and fuzz tests",
)

fs.BoolVar(
Expand Down
2 changes: 1 addition & 1 deletion pkg/commentmimic/commentmimic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ func (s *CommentMimicSuite) TestSkipTestComments() {
commentmimic.CommentAllExportedFuncsFlag: true,
commentmimic.CommentInterfacesFlag: true,
commentmimic.CommentStructsFlag: true,
commentmimic.NoTestCommentsFlag: true,
commentmimic.CommentTestsFlag: false,
}

fileMap := map[string]string{
Expand Down
2 changes: 1 addition & 1 deletion testdata/script/no_test_comments.txtar
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
! exec commentmimic --comment-all-exported --no-test-comments not_commented_errors.go not_commented_errors_test.go
! exec commentmimic --comment-all-exported not_commented_errors.go not_commented_errors_test.go
stderr -count=4 'exported element ''Func[A-D]'' should be commented'

-- not_commented_errors.go --
Expand Down

0 comments on commit d5686d0

Please sign in to comment.