actionability

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyPatternLabel

ApplyPatternLabel adjusts clone classification based on the AST-detected non-actionable pattern. This upgrades the category and suggestion to reflect the specific reason the clone is non-actionable, rather than relying solely on the first node's type.

func EvaluateActionability

func EvaluateActionability(nodeSeqs [][]*domain.CloneNode) domain.CloneActionability

EvaluateActionability analyzes a clone group and determines whether it represents actionable duplication or idiomatic boilerplate noise.

A group is actionable when it contains real logic that can be extracted, composed, or otherwise refactored. Non-actionable patterns are standard Go idioms that cannot be eliminated without breaking semantics.

To be non-actionable, EVERY clone in the group must match the same boilerplate pattern. If any clone differs, the group is actionable.

func EvaluateActionabilityWithDisabled

func EvaluateActionabilityWithDisabled(
	nodeSeqs [][]*domain.CloneNode,
	disabled map[PatternLabel]bool,
) domain.CloneActionability

EvaluateActionabilityWithDisabled is like EvaluateActionability but skips patterns whose labels are in the disabled set.

func EvaluateExtractability added in v0.6.0

func EvaluateExtractability(nodeSeqs [][]*domain.CloneNode) domain.ExtractabilityAnalysis

EvaluateExtractability runs the 4-property extractability analysis on a clone group. Returns the merged analysis from all checkers.

When type info is unavailable (syntax-only mode), properties default to true (harmful), preventing false negatives. The denylist patterns still run as fallback.

func ListActionabilityPatterns

func ListActionabilityPatterns(w io.Writer)

ListActionabilityPatterns writes all pattern labels to the writer, one per line.

Types

type PatternLabel

type PatternLabel string

PatternLabel identifies which non-actionable pattern was detected. Empty string means actionable.

const (
	PatternNone                    PatternLabel = ""
	PatternTestData                PatternLabel = "testdata-pair"
	PatternTableDrivenTest         PatternLabel = "table-driven-test"
	PatternTestScaffolding         PatternLabel = "test-scaffolding"
	PatternDataDominated           PatternLabel = "data-dominated"
	PatternSignatureOnly           PatternLabel = "signature-only"
	PatternRAIIDefer               PatternLabel = "raii-defer"
	PatternErrorPropagation        PatternLabel = "error-propagation"
	PatternErrorWrapping           PatternLabel = "error-wrapping"
	PatternAssertionChain          PatternLabel = "assertion-chain"
	PatternCobraBoilerplate        PatternLabel = "cobra-boilerplate"
	PatternInterfaceImpl           PatternLabel = "interface-implementation"
	PatternDescribeTable           PatternLabel = "describe-table"
	PatternBuilderCallback         PatternLabel = "builder-callback"
	PatternAssignErrorCheck        PatternLabel = "assign-error-check"
	PatternSingleCallExpr          PatternLabel = "single-call-expression"
	PatternSingleSimpleStmt        PatternLabel = "single-simple-statement"
	PatternSingleDeclaration       PatternLabel = "single-declaration"
	PatternGuardClause             PatternLabel = "guard-clause"
	PatternTestHelperDelegate      PatternLabel = "test-helper-delegate"
	PatternInterfaceMethod         PatternLabel = "interface-method"
	PatternBoolGuard               PatternLabel = "bool-guard"
	PatternPropertyEngine          PatternLabel = "property-engine"
	PatternPropertyControlFlow     PatternLabel = "property-control-flow"
	PatternPropertyROI             PatternLabel = "property-roi"
	PatternPropertyParameterizable PatternLabel = "property-parameterizable"
	PatternTemplRenderingIdiom     PatternLabel = "templ-rendering-idiom"
)

func AllActionabilityPatterns

func AllActionabilityPatterns() []PatternLabel

AllActionabilityPatterns returns all registered pattern labels in priority order.

func EvaluateActionabilityWithLabel

func EvaluateActionabilityWithLabel(nodeSeqs [][]*domain.CloneNode) (PatternLabel, domain.CloneActionability)

EvaluateActionabilityWithLabel returns both the actionability and the pattern label that caused it. This allows downstream code to adjust category/suggestion based on which specific pattern was detected.

Jump to

Keyboard shortcuts

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