Skip to content

refactor(internal): clear the Sonar findings outside the runtime - #1610

Merged
HuiJun merged 2 commits into
developfrom
fix/sonar-internal
Oct 28, 2026
Merged

HuiJun merged 2 commits into
developfrom
fix/sonar-internal

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Clears 14 of the 15 open SonarCloud findings on develop in Go packages under internal/ outside the runtime, at the root; one is deferred because two open PRs rewrite the same function. Behaviour is unchanged: each edit is a split into named helpers, a named constant, a table that replaces a switch (with a new test that it names every kind), or a renamed test variable.

Rule File:line on develop What was done
go:S3776 (32) internal/check/passes/typecheck.go:389 checkTypeTarget Fixed: target resolution (feature-reference unwrap, chain checks, alias) is typeTargetSymbol; the kind-message diagnostic is reportTargetKind.
go:S3776 (33) internal/doc/queryexec/operations.go:604 evaluateProject Fixed: a projection holds the operation's columns and what reading rows learnt; newProjection reads the arguments, cells reads one row, checkProperties reports unknown/missing properties. Argument and error order unchanged.
go:S3776 (34) internal/ir/view/general.go:588 packageEdges Fixed: split into aliasEdges and importEdges.
go:S3776 (33) internal/semantic/semantics/model.go:982 FeatureTypeSetWithImplied Fixed: the usage-base lookup is withUsageBases.
go:S3776 (35) internal/workspace/project/discovery.go:286 used Deferred: #1568 (fix/usage-version-ranges) and #1561 (fix/usage-elimination-named-forms) both rewrite the body of used (their hunks span lines 302–380). Refactoring it under them would conflict with both; it should be split once they land, against the function they leave behind.
go:S1479 internal/ir/view/view.go:289 EdgeKind.String (34 branches) Fixed: one edgeKindNames table sized by a new edgeKindCount sentinel. The switch had no exhaustiveness check (Go has none for switch; make lint runs no exhaustive), so nothing relied on one; the table adds one — TestEdgeKindNamesEveryKind fails on a kind added without a name, and a name out of range still answers "edge".
go:S1192 internal/exec/smt/encode.go:257 "attribute " ×3 Fixed: attributeConstruct constant.
go:S1192 internal/ir/view/dot.go:545 "arrowhead=vee" ×3 Fixed: the two literal uses now use the existing dotArrowheadVee constant.
godre:S8209 internal/ir/docplan/markup/asciidoc.go:135 Fixed: flat, nodes []asciiDocBlock.
godre:S8193 internal/doc/queryexec/named_test.go:143 Fixed: the error's Actual name is now reported in the failure message.
go:S978 internal/frontend/grpc/query_operators_test.go:170 any Fixed: any → listed.
go:S978 internal/workspace/libs/loader_copies_test.go:19 copy Fixed: copy → replica.
go:S978 internal/workspace/libs/loader_copies_test.go:84 copy Fixed: same.

No dispositions.

How it was verified

  • go build ./..., go vet on every touched package, gofmt -l empty.
  • go test -count=1 -timeout 60m ./internal/check/... ./internal/doc/... ./internal/exec/smt/... ./internal/frontend/grpc/... ./internal/ir/... ./internal/semantic/... ./internal/workspace/...: all 37 packages ok.
  • gocognit -over 30 on the four refactored files: none of the four functions remains over 30.
  • Sonar's analyze_code_snippet on each changed file: the develop copies report exactly the findings above; the branch copies report none of them (the remaining hits are findings already resolved on develop). godre:* rules are not reported by the snippet analyser; checked by eye.

Overlap with open PRs

Checklist

  • make test and make lint pass locally
  • Tests added or updated for the change
  • Documentation extended where it already covers the surface (see CONTRIBUTING.md)
  • Changelog entry added as changes/unreleased/<slug>.<section>.md, not as an edit to CHANGELOG.md — not needed: refactor only
  • baselines regenerated and make docs-counts run if a gate count moved (compliance rows need nothing: the census is counted at docs build) — no count moved
  • No internal work-item labels (waves, slices, F4, K5) in the body, docs, or changelog

Requested by: @HuiJun

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

Split checkTypeTarget, evaluateProject, packageEdges and
FeatureTypeSetWithImplied into named helpers, name each edge kind from one
table sized by the kinds (with a test that every kind is named), name the
repeated construct and arrowhead literals, group flattenAsciiDoc's
parameters, and rename two shadowing test variables.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
devin-ai-integration[bot]

This comment was marked as resolved.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review October 28, 2026 06:46
@HuiJun
HuiJun merged commit d12e417 into develop Oct 28, 2026
83 of 99 checks passed
@HuiJun
HuiJun deleted the fix/sonar-internal branch October 28, 2026 13:07
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