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

cmd/errtrace: Tighten up opt-out matching #64

Merged
merged 3 commits into from
Nov 30, 2023
Merged

cmd/errtrace: Tighten up opt-out matching #64

merged 3 commits into from
Nov 30, 2023

Conversation

abhinav
Copy link
Contributor

@abhinav abhinav commented Nov 30, 2023

strings.Contains is too wide for this purpose.
It trips up even if a doc comment mentions '//errtrace:skip'.

Narrow it down to a much more selective criteria:

  • must be a single line comment
  • must be at start of the comment (foo() //errtrace:skip)
    or have a space immediately before it (foo() //nolint:bar //errtrace:skip)
  • must reach end of the comment (foo() //errtrace:skip)
    or have a space (foo() //errtrace:skip //nolint:bar)
    or an opening parenthesis (foo() //errtrace:skip(reason))
    immediately after it.

strings.Contains is too wide for this purpose.
It trips up even if a doc comment mentions '//errtrace:skip'.

Narrow it down to a much more selective criteria:

- must be a single line comment
- must be at start of the comment (`foo() //errtrace:skip`)
  or have a space immediately before it (`foo() //nolint:bar //errtrace:skip`)
- must reach end of the comment (`foo() //errtrace:skip`)
  or have a space (`foo() //errtrace:skip //nolint:bar`)
  or an opening parenthesis (`foo() //errtrace:skip(reason)`)
  immediately after it.
To ensure that this isn't considered a multi-line comment
and is processed.
cmd/errtrace/main.go Outdated Show resolved Hide resolved
Co-authored-by: Prashant Varanasi <prashant@prashantv.com>
@abhinav abhinav merged commit 3c0cfb8 into main Nov 30, 2023
9 checks passed
@abhinav abhinav deleted the optout-tighten branch November 30, 2023 16:35
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

2 participants