Skip to content

[refactor] Route []string includes through shared normalization in extractManifestIncludes #77311

Done

Description

@github-actions

Overview

Sampled semantic refactoring analysis, slice date 2026-11-13. Reviewed 16 non-test functions across 3 files: pkg/cli slice 23/619 (8 functions across add_package_manifest_imports.go and add_package_manifest_includes.go) and pkg/console slice 23/28 (8 functions in render.go). No record was truncated. This covers only the sampled functions, not the whole packages or repository.

One refactoring candidate was verified. extractManifestIncludes normalizes string include entries differently depending on the slice type it receives.

Key findings

Input shape Per-entry handling Location
[]any string entries Trimmed. Entries whose basename is the manifest file name pass through cleanManifestImportPath, and a failure returns an error. pkg/cli/add_package_manifest_includes.go:55-62
[]string entries Wrapped by manifestIncludesFromPaths as Source: p. No trimming, no manifest-path cleaning, no error path. pkg/cli/add_package_manifest_includes.go:86-87, helper at :42-48

Both arms then feed the shared normalization loop (:94-104). That loop checks the supported-path predicates and drops unsupported sources with a warning, so the []string arm skips the per-entry steps the []any arm applies.

Proposed refactoring

Route []string entries through the same per-entry normalization that appendRawEntry uses. One option is a normalizeStringInclude(include, manifestPath string) (repositoryPackageInclude, error) helper called from both arms. If no other caller needs manifestIncludesFromPaths, remove it.

Preservation risks

  • manifestIncludesFromPaths may be intentional. Its name suggests []string callers pass paths that are already validated, so confirm the callers before changing behavior.
  • Trimming changes matching for entries with leading or trailing whitespace.
  • []string entries that fail manifest-path cleaning would now return an error instead of being passed through.
  • Deduplication runs on normalized values, so entries that become equal after cleaning will collapse.
  • Not checked: callers of extractManifestIncludes, uses of manifestIncludesFromPaths, and the predicates isSupportedManifestIncludePath and isManifestImportPath. They are outside the packet, so whether the skipped steps matter in practice is unverified.
Candidates compared and not reported

Three candidate groups were compared: the include handling above (reported), and two in pkg/console/render.go (not reported).

  • formatUnexportedValue (lines 549-564) duplicates the Int, Uint and Float arms of formatNumericKind (lines 567-578). The duplication is about 6 lines, below the significance bar.
  • The type-switch fast paths in applyIntegerFormat (lines 618-648) and applyCostFormat (lines 659-678) look redundant but are not. For reflect.Interface values holding a number, the type switch matches the dynamic type, while the Kind fallback returns baseValue. Removing them would change output.

Next actions

  1. Find the callers of extractManifestIncludes and manifestIncludesFromPaths. If no trusted caller passes []string, apply the change.
  2. Add table tests for []any and []string inputs covering whitespace, manifest-import entries and unsupported paths, before and after the change.

References: §43351366513

Generated by 🔧 Semantic Function Refactoring · claude · routed: haiku55 xhigh · ~3 AIC · ⌖ ~1 AIC · ⊞ 4.1K · ◷

  • expires on Nov 14, 2026, 6:26 PM UTC-08:00

Activity

  1. github-actions commented on Nov 13, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, Copilot will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt50 · ~1 AIC · ⌖ ~2 AIC · ⊞ 11.1K · ◷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions