deadcode

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyResult

type ApplyResult struct {
	Declarations int
	Files        int
	Errors       []error
}

ApplyResult captures the outcome of applying a plan.

type BlockedCandidate

type BlockedCandidate struct {
	File   string `json:"file"`
	Line   int    `json:"line"`
	Rule   string `json:"rule"`
	Kind   string `json:"kind"`
	Name   string `json:"name"`
	Reason string `json:"reason"`
}

BlockedCandidate is a dead-code finding that is intentionally not removed.

type Candidate

type Candidate struct {
	File string `json:"file"`
	Line int    `json:"line"`
	Rule string `json:"rule"`
	Kind string `json:"kind"`
	Name string `json:"name"`
}

Candidate is a directly removable dead-code finding.

type KindCount

type KindCount struct {
	Kind  string `json:"kind"`
	Count int    `json:"count"`
}

KindCount is a deterministic count bucket for candidate kinds.

type Plan

type Plan struct {
	Candidates []Candidate        `json:"candidates"`
	Blocked    []BlockedCandidate `json:"blockedCandidates"`
	// contains filtered or unexported fields
}

Plan separates directly removable dead code from findings that still need additional safety work before bulk deletion can use them.

func BuildPlanColumns

func BuildPlanColumns(columns *scanner.FindingColumns) Plan

BuildPlanColumns classifies columnar dead-code findings into immediately removable entries and blocked entries without reconstructing all rows.

func (Plan) Apply

func (p Plan) Apply(suffix string) ApplyResult

Apply runs the plan through the shared fix engine.

func (Plan) Summary

func (p Plan) Summary() Summary

Summary returns stable aggregate counts for the plan.

type ProjectFinding

type ProjectFinding struct {
	File       string `json:"file"`
	Line       int    `json:"line"`
	Kind       string `json:"kind"`
	Name       string `json:"name"`
	FQN        string `json:"fqn"`
	Visibility string `json:"visibility"`
	Reason     string `json:"reason"`
	Module     string `json:"module,omitempty"`
}

ProjectFinding describes a declaration unreachable from project roots.

func AnalyzeProject

func AnalyzeProject(scanRoot string, opts ProjectOptions) ([]ProjectFinding, error)

AnalyzeProject performs project-level reachability dead-code analysis. It discovers Gradle modules at scanRoot (best effort), parses Kotlin and Java files under opts.Paths, identifies reachability roots, and reports any non-private declarations not reachable from those roots.

type ProjectOptions

type ProjectOptions struct {
	// Roots are user-supplied additional reachability roots, identified by
	// FQN or simple name.
	Roots []string
	// Workers controls parser parallelism. Defaults to runtime.NumCPU().
	Workers int
	// Paths restricts scanning to these directories. Defaults to ScanRoot.
	Paths []string
}

ProjectOptions configures project-level dead-code analysis.

type ReasonCount

type ReasonCount struct {
	Reason string `json:"reason"`
	Count  int    `json:"count"`
}

ReasonCount is a deterministic count bucket for blocked reasons.

type Summary

type Summary struct {
	Declarations int           `json:"declarations"`
	Files        int           `json:"files"`
	Kinds        []KindCount   `json:"kinds"`
	Blocked      int           `json:"blocked"`
	Reasons      []ReasonCount `json:"reasons"`
}

Summary is a compact overview of a dead-code removal plan.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL