From d5686d03c0a55a6a2e2fedc7d69515b07c328664 Mon Sep 17 00:00:00 2001 From: ashmrtn <3891298+ashmrtn@users.noreply.github.com> Date: Mon, 19 Jun 2023 09:12:55 -0700 Subject: [PATCH] Flip test comment flag name and value Provides a better UX as specifying a falsy value for a flag can be a bit annoying on CLI. --- pkg/commentmimic/commentmimic.go | 12 ++++++------ pkg/commentmimic/commentmimic_test.go | 2 +- testdata/script/no_test_comments.txtar | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/commentmimic/commentmimic.go b/pkg/commentmimic/commentmimic.go index 13738fb..95bf0d2 100644 --- a/pkg/commentmimic/commentmimic.go +++ b/pkg/commentmimic/commentmimic.go @@ -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" ) @@ -374,7 +374,7 @@ type mimic struct { commentAllExportedFuncs bool commentInterfaces bool commentStructs bool - noTestComments bool + commentTests bool } func New() *analysis.Analyzer { @@ -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( diff --git a/pkg/commentmimic/commentmimic_test.go b/pkg/commentmimic/commentmimic_test.go index 45989a2..633688e 100644 --- a/pkg/commentmimic/commentmimic_test.go +++ b/pkg/commentmimic/commentmimic_test.go @@ -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{ diff --git a/testdata/script/no_test_comments.txtar b/testdata/script/no_test_comments.txtar index 88b1632..b776330 100644 --- a/testdata/script/no_test_comments.txtar +++ b/testdata/script/no_test_comments.txtar @@ -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 --