Skip to content

Conversation

tino-alfaneti
Copy link

Enforce Explanatory Comments with // coverage-ignore. When a user adds a // coverage-ignore annotation, the tool should enforce that an additional explanatory comment is provided.

Copy link
Owner

@vladopajic vladopajic left a comment

Choose a reason for hiding this comment

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

  • feature should be tested with unit tests on all levels

    • `pkg/testcoverage/config_test.go``
      • TestConfigYamlParse
    • pkg/testcoverage/coverage/cover_test.go
      • new test that will check this functionality with different values used (similar to test Test_findAnnotations but in this test second argument of FindAnnotations must be used with different values)
    • pkg/testcoverage/check_test.go
      • a case in func TestCheck(t *testing.T) where non default value of IgnoreTextRegex is used
  • IgnoreTextRegex does not seem suitable name why not CoverageIgnoreRegex ?

Comment on lines +44 to +50
# (optional; default '//coverage-ignore')
# ignore-text-regex: Defines regular expressions to match specific comment patterns in your code
# that will be recognized as valid coverage ignore markers.
#
# this feature can be used to ensure team members properly document WHY coverage is being skipped,
# which helps maintain code quality and avoid unexplained coverage gaps.
ignore-text-regex:
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
# (optional; default '//coverage-ignore')
# ignore-text-regex: Defines regular expressions to match specific comment patterns in your code
# that will be recognized as valid coverage ignore markers.
#
# this feature can be used to ensure team members properly document WHY coverage is being skipped,
# which helps maintain code quality and avoid unexplained coverage gaps.
ignore-text-regex:
# (optional)
# Defines regular expressions to match specific comment patterns in your code
# that will be recognized as valid coverage ignore markers.
# By default lines having `//coverage-ignore` are excluded from coverage statistic.
ignore-text-regex: ''

@@ -83,6 +83,7 @@ func TestCheck(t *testing.T) {
Paths: []string{`cdn\.go$`, `github\.go$`, `cover\.go$`, `check\.go$`, `path\.go$`},
},
SourceDir: sourceDir,
IgnoreTextRegex: "",
Copy link
Owner

Choose a reason for hiding this comment

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

why specify value us empty string (default)?

@@ -44,6 +44,7 @@ func Test_GenerateCoverageStats(t *testing.T) {
stats, err = GenerateCoverageStats(Config{
Profiles: []string{profileNOK},
SourceDir: sourceDir,
IgnoreTextRegex: "",
Copy link
Owner

Choose a reason for hiding this comment

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

why specify value us empty string (default)? here and other places in same file.

@vladopajic vladopajic changed the title #173 add an optional feature to enforce descriptive comments feat: configurable regexp for coverage-ignore Aug 26, 2025
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.

2 participants