Skip to content

chore(go): remove unused exported declarations and enforce AST check in codequality - #1277

Merged
kyasbal merged 3 commits into
push-wlwkzqlxxppvfrom
push-wtxqxzwlokuq
Nov 18, 2026
Merged

kyasbal merged 3 commits into
push-wlwkzqlxxppvfrom
push-wtxqxzwlokuq

Conversation

@kyasbal

@kyasbal kyasbal commented Nov 17, 2026

Copy link
Copy Markdown
Member

Stacked on #1276

Background

Standard Go static analysis tools (unused, deadcode) only track function call reachability or unexported symbols within a single package. In a monorepo application, exported types, constants, errors, TaskID declarations, and package-level timeline style variables (style.MustRegister*) can remain completely unreferenced across the entire repository without triggering any linter—especially package-level variables initialized by function calls, which remain live in init() and even inflate generated icon atlases.

Approach

Add a --unused-exports check mode to scripts/codequality (scripts/codequality/internal/astcheck/unused_exports.go) using golang.org/x/tools/go/packages type information across the repository, and wire it into make lint-go and GitHub Actions (backend-tests):

  • unused-exported-decl: Flags exported package-level type, var, const, and func declarations in non-generated production Go packages that have zero references across all production and test packages in the repository.
  • unregistered-impl-task: Flags pkg/task/inspection/**/impl task variables that are omitted from Register(registry) and unreferenced elsewhere, catching tasks forgotten during wiring.

Remove all existing unreferenced exported declarations and regenerate the embedded icon atlas after dropping unused timeline revision states.

@kyasbal
kyasbal requested review from RyuSA and jyane as code owners November 17, 2026 05:46
@kyasbal kyasbal added the area:backend-core Core backend frameworks, DAG task runner, and server API label Nov 17, 2026
@kyasbal
kyasbal requested a review from kkuchima as a code owner November 17, 2026 05:46
@kyasbal kyasbal added area:backend-parser Log parsers and log timeline mapper tasks area:cicd GitHub Actions workflows and release pipelines area:devenv Development environment, Makefile, and build tooling labels Nov 17, 2026
@kyasbal
kyasbal requested a review from renamoo as a code owner November 17, 2026 05:46
@kyasbal kyasbal added area:khifile .khi file format, serialization, and schema type:chore Maintenance, dependency updates, and tooling chores labels Nov 17, 2026
@kyasbal
kyasbal requested a review from K53 as a code owner November 17, 2026 05:46

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request cleans up numerous unused types, constants, variables, and files across the codebase, aligning with the monorepo's policy of direct unification without retaining legacy shims. It also introduces a new code quality check tool (unused-exports) to detect unused exported declarations in pkg/ and unregistered task variables in *_impl packages, integrating it into the linting pipeline. A review comment suggests including the internal/ directory in the code quality tool's package scanner to prevent false positives for symbols referenced in internal packages.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Go Quality Report (origin/push-wlwkzqlxxppv) — ✅ PASS

Metric Result
Changed Scope 4 prod file(s), 2 test file(s), 34 unit(s)
Patch Coverage 98.6% (215/218 lines)
Mutation Score 100.0% (86/86 killed, 0 survived)
Function Similarity OK (26 new unit(s), 0 matches across 2533 corpus units)

Commit: 319ea27ae48d · Cloud Build Logs

@kyasbal
kyasbal added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit 80f8f75 Nov 18, 2026
37 checks passed
@kyasbal
kyasbal deleted the push-wtxqxzwlokuq branch November 18, 2026 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend-core Core backend frameworks, DAG task runner, and server API area:backend-parser Log parsers and log timeline mapper tasks area:cicd GitHub Actions workflows and release pipelines area:devenv Development environment, Makefile, and build tooling area:khifile .khi file format, serialization, and schema type:chore Maintenance, dependency updates, and tooling chores

1 participant