aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/json/v2/errors.go
diff options
context:
space:
mode:
authorRudy Regazzoni <rudy.regazzoni@sonarsource.com>2026-02-13 09:00:43 +0000
committerGopher Robot <gobot@golang.org>2026-02-13 10:09:49 -0800
commitcba008453e9535840ebfcf6a038a4172008ef1fc (patch)
tree17e82781ed2b83d800e9e6b96a26141253d63cf1 /src/encoding/json/v2/errors.go
parent3e4143dd440ac2621ef03d394cdc2cc0ac34acd5 (diff)
downloadgo-cba008453e9535840ebfcf6a038a4172008ef1fc.tar.xz
cmd/cover: exclude commented-out code from coverage instrumentation
Add logic to exclude purely commented lines from coverage instrumentation. When instrumenting Go code for coverage, the cover tool now identifies and excludes lines that contain only comments from coverage blocks. This prevents commented-out code from being reported as "uncovered" in coverage reports, which can be misleading. The implementation adds a splitBlockByComments function that parses source code character by character to identify segments containing executable code versus segments containing only comments. The addCounters function now uses this to create coverage counters only for segments that contain actual executable code. The parser correctly handles: - Single-line comments (//) - Multi-line comments (/* */) - String literals containing comment-like sequences - Raw string literals with fake comments - Mixed lines with both code and comments This improves the accuracy of coverage reports by ensuring that commented-out code, TODOs, and documentation comments don't inflate the count of uncovered lines. Fixes #22545 Change-Id: Ib428e6569011abb5f315387e81547147a2dadd2b GitHub-Last-Rev: 915058146bb5f929f08d63ee191edebd51b2ab56 GitHub-Pull-Request: golang/go#76692 Reviewed-on: https://go-review.googlesource.com/c/go/+/726800 Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Alan Donovan <adonovan@google.com> Reviewed-by: Nicholas Husin <husin@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/encoding/json/v2/errors.go')
0 files changed, 0 insertions, 0 deletions