Skip to content

refactor: use sync.Map in RunExclusive; document discard idioms elsewhere#205

Open
tonyandrewmeyer wants to merge 2 commits into
canonical:mainfrom
tonyandrewmeyer:tiobe-comment-cleanup
Open

refactor: use sync.Map in RunExclusive; document discard idioms elsewhere#205
tonyandrewmeyer wants to merge 2 commits into
canonical:mainfrom
tonyandrewmeyer:tiobe-comment-cleanup

Conversation

@tonyandrewmeyer

@tonyandrewmeyer tonyandrewmeyer commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

The primary motivation here is to address the findings from the TIOBE TICS report, according to the cycle's SSDLC requirements.

The only real change is:

helpers.go: replace the cmdMu + map[string]*sync.Mutex pattern in RunExclusive with sync.Map.LoadOrStore. Behaviour is identical (the map only ever grew anyway), but this should be clearer to Coverity and removes the COV_GO_ATOMICITY hit on the "value captured under lock A, used outside it" idiom.

The rest is comments, explaining why error checking is not done. We already have a few of these; this should cover the rest. I requested review of all of these in TIOBE, so the comment shouldn't be needed, but I think it will help reviewers and also maintainers of the code understand that these are deliberate choices.

…m elsewhere

Triages the 2026-06-01 TIOBE security/AI findings cluster (see
canonical-work-queue: roadmap/26.10/repo-setup/tiobe-findings/concierge.csv).

helpers.go: replace the cmdMu + map[string]*sync.Mutex pattern in
RunExclusive with sync.Map.LoadOrStore. Behaviour is identical (the
map only ever grew anyway), but the new shape is statically obvious to
Coverity and removes the COV_GO_ATOMICITY hit on the "value captured
under lock A, used outside it" idiom. Smaller code as a bonus.

Comment-only changes elsewhere — each block documents an existing _ =
discard so the next maintainer (and future TIOBE scans, where useful)
can see the explicit acknowledgement instead of having to re-derive
that pflag's Get*/strings.Builder.Write/etc are unreachable-error
APIs in this caller's flow:

- cmd/main.go parseLoggingFlags: --verbose / --trace / --dry-run
  are registered persistent flags on root; pflag.Get* unreachable error.
- cmd/prepare.go prepareCmd RunE: same, for --config and --preset.
- cmd/restore.go restoreCmd RunE: same, for --dry-run / --verbose / --trace.
- internal/config/config.go NewConfig: same, for the four flag reads.
- internal/config/config.go envOrFlagBool: docstring extended to cover
  the sibling envOrFlagString / envOrFlagSlice helpers too — same
  argument: keys come from getOverrides and are all registered on root.
- internal/providers/providers.go buildHostsTomlFromConfig: note that
  (*strings.Builder).Write never returns a non-nil error, so the five
  fmt.Fprintf calls here cannot either.

All 20 SECURITY findings from the export are reported as TIOBE FPs in
parallel — those rationales rely on these comments to keep the
"intentional discard" story visible in-tree.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@tonyandrewmeyer tonyandrewmeyer force-pushed the tiobe-comment-cleanup branch from d561593 to b0d839c Compare June 4, 2026 09:51
@tonyandrewmeyer tonyandrewmeyer requested a review from hpidcock June 4, 2026 21:06
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.

1 participant