config

package
v1.31.2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ArchitectureStyleLayered is the default, backward-compatible preset.
	// An empty style is treated as layered.
	ArchitectureStyleLayered = "layered"

	// ArchitectureStyleHexagonal enforces Hexagonal / Onion architecture: the
	// domain has no outward dependencies (Dependency Inversion).
	ArchitectureStyleHexagonal = "hexagonal"

	// ArchitectureStyleClean enforces Clean Architecture: inner layers never
	// depend on outer ones.
	ArchitectureStyleClean = "clean"

	// ArchitectureStyleMVC enforces MVC/MVT: the view may not depend directly on
	// the model (such a dependency is discouraged and emits a warning).
	ArchitectureStyleMVC = "mvc"
)

Architecture style preset names. Users select one via `style` in the [architecture] section of pyscn.toml / pyproject.toml to auto-apply a matching set of layers and dependency rules.

View Source
const (
	// DefaultLowComplexityThreshold defines the upper bound for low complexity functions
	DefaultLowComplexityThreshold = domain.DefaultComplexityLowThreshold

	// DefaultMediumComplexityThreshold defines the upper bound for medium complexity functions
	DefaultMediumComplexityThreshold = domain.DefaultComplexityMediumThreshold

	// DefaultMinComplexityFilter defines the minimum complexity to report
	DefaultMinComplexityFilter = domain.DefaultComplexityMinFilter

	// DefaultMaxComplexityLimit defines no upper limit for complexity analysis
	DefaultMaxComplexityLimit = domain.DefaultComplexityMaxLimit

	// DefaultCognitiveComplexityThreshold defines the high-risk threshold for cognitive complexity
	DefaultCognitiveComplexityThreshold = domain.DefaultCognitiveComplexityThreshold

	// DefaultNestingDepthThreshold defines the high-risk threshold for nesting depth
	DefaultNestingDepthThreshold = domain.DefaultNestingDepthThreshold

	// DefaultFunctionSLOCWarnThreshold defines the function length above which a function is long
	DefaultFunctionSLOCWarnThreshold = domain.DefaultFunctionSLOCWarnThreshold

	// DefaultFunctionSLOCCriticalThreshold defines the function length above which a function is too long
	DefaultFunctionSLOCCriticalThreshold = domain.DefaultFunctionSLOCCriticalThreshold
)

Default complexity thresholds - re-exported from domain for backward compatibility All default values are defined in domain/defaults.go

View Source
const (
	// DefaultDeadCodeMinSeverity defines the minimum severity level to report
	DefaultDeadCodeMinSeverity = domain.DefaultDeadCodeMinSeverity

	// DefaultDeadCodeContextLines defines the number of context lines to show
	DefaultDeadCodeContextLines = domain.DefaultDeadCodeContextLines

	// DefaultDeadCodeSortBy defines the default sorting criteria
	DefaultDeadCodeSortBy = domain.DefaultDeadCodeSortBy
)

Default dead code detection settings - re-exported from domain for backward compatibility

Variables

This section is empty.

Functions

func ArchitectureStylePreset added in v1.23.0

func ArchitectureStylePreset(style string) ([]LayerDefinition, []LayerRule)

ArchitectureStylePreset returns the layer definitions and dependency rules for the named architecture style. An empty style is treated as "layered". Returns (nil, nil) for an unrecognized style so callers can fall back to auto-detection.

func GenerateDefaultConfigTOML added in v1.11.1

func GenerateDefaultConfigTOML() (string, error)

GenerateDefaultConfigTOML renders the default config template with domain values and returns the resulting TOML string.

func LoadDefaultConfigTOMLString added in v1.4.1

func LoadDefaultConfigTOMLString() (string, error)

LoadDefaultConfigTOMLString returns the rendered default config as a string This can be used to display to users

func Merge added in v1.26.2

func Merge[T comparable](base, override T) T

Merge returns override unless it is the zero value for its type, in which case base is returned. The zero value (0, "", 0.0, ...) means "not set"; actual defaults live in the config layer, never in override values.

func MergePtr added in v1.26.2

func MergePtr[T any](base, override *T) *T

MergePtr returns override unless it is nil, in which case base is returned. nil means "not set"; a non-nil pointer is an explicit value, including the zero value (e.g. explicit false for *bool).

func MergeSlice added in v1.26.2

func MergeSlice[T any](base, override []T) []T

MergeSlice returns override unless it is empty, in which case base is returned. An empty slice means "not set".

func SaveConfig

func SaveConfig(config *Config, path string) error

SaveConfig saves configuration to a TOML file

Types

type AnalysisConfig

type AnalysisConfig struct {
	// IncludePatterns specifies file patterns to include
	IncludePatterns []string `mapstructure:"include_patterns" yaml:"include_patterns"`

	// ExcludePatterns specifies file patterns to exclude
	ExcludePatterns []string `mapstructure:"exclude_patterns" yaml:"exclude_patterns"`

	// Recursive controls whether to analyze directories recursively
	Recursive bool `mapstructure:"recursive" yaml:"recursive"`

	// FollowSymlinks controls whether to follow symbolic links
	FollowSymlinks bool `mapstructure:"follow_symlinks" yaml:"follow_symlinks"`
}

AnalysisConfig holds general analysis configuration

type AnalysisTomlConfig added in v1.4.0

type AnalysisTomlConfig struct {
	IncludePatterns []string `toml:"include_patterns"`
	ExcludePatterns []string `toml:"exclude_patterns"`
	Recursive       *bool    `toml:"recursive"`
	FollowSymlinks  *bool    `toml:"follow_symlinks"`
	// contains filtered or unexported fields
}

AnalysisTomlConfig represents the [analysis] section

type ArchitectureConfig

type ArchitectureConfig struct {
	// Enabled controls whether architecture validation is performed
	Enabled bool `mapstructure:"enabled" yaml:"enabled"`

	// Validation modes
	ValidateLayers         bool `mapstructure:"validate_layers" yaml:"validate_layers"`
	ValidateCohesion       bool `mapstructure:"validate_cohesion" yaml:"validate_cohesion"`
	ValidateResponsibility bool `mapstructure:"validate_responsibility" yaml:"validate_responsibility"`

	// Style is an optional architecture preset: "layered", "hexagonal", "clean", "mvc".
	Style string `mapstructure:"style" yaml:"style"`

	// Layer definitions
	Layers          []LayerDefinition `mapstructure:"layers" yaml:"layers"`
	Rules           []LayerRule       `mapstructure:"rules" yaml:"rules"`
	NeutralPrefixes []string          `mapstructure:"neutral_prefixes" yaml:"neutral_prefixes"`

	// Thresholds
	MinCohesion         float64 `mapstructure:"min_cohesion" yaml:"min_cohesion"`
	MaxCoupling         int     `mapstructure:"max_coupling" yaml:"max_coupling"`
	MaxResponsibilities int     `mapstructure:"max_responsibilities" yaml:"max_responsibilities"`

	// Violation severity levels
	LayerViolationSeverity          string `mapstructure:"layer_violation_severity" yaml:"layer_violation_severity"`
	CohesionViolationSeverity       string `mapstructure:"cohesion_violation_severity" yaml:"cohesion_violation_severity"`
	ResponsibilityViolationSeverity string `mapstructure:"responsibility_violation_severity" yaml:"responsibility_violation_severity"`

	// Reporting options
	ShowAllViolations   bool `mapstructure:"show_all_violations" yaml:"show_all_violations"`
	GroupByType         bool `mapstructure:"group_by_type" yaml:"group_by_type"`
	IncludeSuggestions  bool `mapstructure:"include_suggestions" yaml:"include_suggestions"`
	MaxViolationsToShow int  `mapstructure:"max_violations_to_show" yaml:"max_violations_to_show"`

	// Custom rules
	CustomPatterns    []string `mapstructure:"custom_patterns" yaml:"custom_patterns"`
	AllowedPatterns   []string `mapstructure:"allowed_patterns" yaml:"allowed_patterns"`
	ForbiddenPatterns []string `mapstructure:"forbidden_patterns" yaml:"forbidden_patterns"`

	// Strict mode enforcement
	StrictMode       bool `mapstructure:"strict_mode" yaml:"strict_mode"`
	FailOnViolations bool `mapstructure:"fail_on_violations" yaml:"fail_on_violations"`
}

ArchitectureConfig holds configuration for architecture validation

type ArchitectureTomlConfig added in v1.4.0

type ArchitectureTomlConfig struct {
	Enabled                         *bool                 `toml:"enabled"`
	ValidateLayers                  *bool                 `toml:"validate_layers"`
	ValidateCohesion                *bool                 `toml:"validate_cohesion"`
	ValidateResponsibility          *bool                 `toml:"validate_responsibility"`
	MinCohesion                     *float64              `toml:"min_cohesion"`
	MaxCoupling                     *int                  `toml:"max_coupling"`
	MaxResponsibilities             *int                  `toml:"max_responsibilities"`
	LayerViolationSeverity          string                `toml:"layer_violation_severity"`
	CohesionViolationSeverity       string                `toml:"cohesion_violation_severity"`
	ResponsibilityViolationSeverity string                `toml:"responsibility_violation_severity"`
	ShowAllViolations               *bool                 `toml:"show_all_violations"`
	GroupByType                     *bool                 `toml:"group_by_type"`
	IncludeSuggestions              *bool                 `toml:"include_suggestions"`
	MaxViolationsToShow             *int                  `toml:"max_violations_to_show"`
	CustomPatterns                  []string              `toml:"custom_patterns"`
	AllowedPatterns                 []string              `toml:"allowed_patterns"`
	ForbiddenPatterns               []string              `toml:"forbidden_patterns"`
	StrictMode                      *bool                 `toml:"strict_mode"`
	FailOnViolations                *bool                 `toml:"fail_on_violations"`
	NeutralPrefixes                 []string              `toml:"neutral_prefixes"`
	Style                           string                `toml:"style"`
	Layers                          []LayerDefinitionToml `toml:"layers"`
	Rules                           []LayerRuleToml       `toml:"rules"`
}

ArchitectureTomlConfig represents the [architecture] section

type CboTomlConfig added in v1.4.0

type CboTomlConfig struct {
	LowThreshold          *int  `toml:"low_threshold"`
	MediumThreshold       *int  `toml:"medium_threshold"`
	MinCbo                *int  `toml:"min_cbo"`
	MaxCbo                *int  `toml:"max_cbo"`
	ShowZeros             *bool `toml:"show_zeros"`
	IncludeBuiltins       *bool `toml:"include_builtins"`
	IncludeImports        *bool `toml:"include_imports"`
	GroupNamespaceImports *bool `toml:"group_namespace_imports"`
}

CboTomlConfig represents the [cbo] section

type CloneAnalysisConfig

type CloneAnalysisConfig struct {
	// Minimum requirements for clone candidates
	MinLines int `mapstructure:"min_lines" yaml:"min_lines" json:"min_lines"`
	MinNodes int `mapstructure:"min_nodes" yaml:"min_nodes" json:"min_nodes"`

	// Edit distance configuration
	MaxEditDistance float64 `mapstructure:"max_edit_distance" yaml:"max_edit_distance" json:"max_edit_distance"`

	// Normalization options
	IgnoreLiterals    *bool `mapstructure:"ignore_literals" yaml:"ignore_literals" json:"ignore_literals"`
	IgnoreIdentifiers *bool `mapstructure:"ignore_identifiers" yaml:"ignore_identifiers" json:"ignore_identifiers"`
	SkipDocstrings    *bool `mapstructure:"skip_docstrings" yaml:"skip_docstrings" json:"skip_docstrings"`

	// Cost model configuration
	CostModelType string `mapstructure:"cost_model_type" yaml:"cost_model_type" json:"cost_model_type"`

	// Advanced analysis
	EnableDFA *bool `mapstructure:"enable_dfa" yaml:"enable_dfa" json:"enable_dfa"` // Data Flow Analysis for Type-4
}

CloneAnalysisConfig holds core analysis parameters

func (*CloneAnalysisConfig) Validate

func (a *CloneAnalysisConfig) Validate() error

Validate validates the analysis configuration

type CloneOutputConfig

type CloneOutputConfig struct {
	// Format and display
	Format      string `mapstructure:"format" yaml:"format" json:"format"`
	ShowDetails *bool  `mapstructure:"show_details" yaml:"show_details" json:"show_details"`
	ShowContent *bool  `mapstructure:"show_content" yaml:"show_content" json:"show_content"`

	// Sorting and grouping
	SortBy      string `mapstructure:"sort_by" yaml:"sort_by" json:"sort_by"`
	GroupClones *bool  `mapstructure:"group_clones" yaml:"group_clones" json:"group_clones"`

	// Output destination (not serialized)
	Writer io.Writer `json:"-" yaml:"-" mapstructure:"-"`
}

CloneOutputConfig holds output formatting configuration (This extends the existing OutputConfig with clone-specific fields)

func (*CloneOutputConfig) Validate

func (o *CloneOutputConfig) Validate() error

Validate validates the output configuration

type ClonesConfig

type ClonesConfig struct {
	// Analysis settings
	MinLines          int     `toml:"min_lines"`
	MinNodes          int     `toml:"min_nodes"`
	MaxEditDistance   float64 `toml:"max_edit_distance"`
	IgnoreLiterals    *bool   `toml:"ignore_literals"`    // pointer to detect unset
	IgnoreIdentifiers *bool   `toml:"ignore_identifiers"` // pointer to detect unset
	SkipDocstrings    *bool   `toml:"skip_docstrings"`    // pointer to detect unset
	CostModelType     string  `toml:"cost_model_type"`

	// Thresholds
	Type1Threshold      float64 `toml:"type1_threshold"`
	Type2Threshold      float64 `toml:"type2_threshold"`
	Type3Threshold      float64 `toml:"type3_threshold"`
	Type4Threshold      float64 `toml:"type4_threshold"`
	SimilarityThreshold float64 `toml:"similarity_threshold"`

	// Advanced analysis
	EnableDFA *bool `toml:"enable_dfa"` // Enable Data Flow Analysis for Type-4 detection

	// Filtering
	MinSimilarity     float64  `toml:"min_similarity"`
	MaxSimilarity     float64  `toml:"max_similarity"`
	EnabledCloneTypes []string `toml:"enabled_clone_types"`
	MaxResults        int      `toml:"max_results"`

	// Grouping
	GroupingMode      string  `toml:"grouping_mode"`
	GroupingThreshold float64 `toml:"grouping_threshold"`
	KCoreK            int     `toml:"k_core_k"`

	// LSH (flat structure with lsh_ prefix)
	LSHEnabled             string  `toml:"lsh_enabled"`
	LSHAutoThreshold       int     `toml:"lsh_auto_threshold"`
	LSHSimilarityThreshold float64 `toml:"lsh_similarity_threshold"`
	LSHBands               int     `toml:"lsh_bands"`
	LSHRows                int     `toml:"lsh_rows"`
	LSHHashes              int     `toml:"lsh_hashes"`

	// Performance
	MaxMemoryMB    int   `toml:"max_memory_mb"`
	BatchSize      int   `toml:"batch_size"`
	EnableBatching *bool `toml:"enable_batching"` // pointer to detect unset
	MaxGoroutines  int   `toml:"max_goroutines"`
	TimeoutSeconds int   `toml:"timeout_seconds"`

	// Input
	Paths           []string `toml:"paths"`
	Recursive       *bool    `toml:"recursive"` // pointer to detect unset
	IncludePatterns []string `toml:"include_patterns"`
	ExcludePatterns []string `toml:"exclude_patterns"`

	// Output
	Format      string `toml:"format"`
	ShowDetails *bool  `toml:"show_details"` // pointer to detect unset
	ShowContent *bool  `toml:"show_content"` // pointer to detect unset
	SortBy      string `toml:"sort_by"`
	GroupClones *bool  `toml:"group_clones"` // pointer to detect unset
}

ClonesConfig represents the [clones] section (flat structure)

type CommunitiesConfig added in v1.25.0

type CommunitiesConfig struct {
	Enabled             bool    `mapstructure:"enabled" yaml:"enabled"`
	Algorithm           string  `mapstructure:"algorithm" yaml:"algorithm"`
	Scope               string  `mapstructure:"scope" yaml:"scope"`
	MinCommunitySize    int     `mapstructure:"min_community_size" yaml:"min_community_size"`
	IncludeLazyEdges    bool    `mapstructure:"include_lazy_edges" yaml:"include_lazy_edges"`
	ReportBridgeModules bool    `mapstructure:"report_bridge_modules" yaml:"report_bridge_modules"`
	Resolution          float64 `mapstructure:"resolution" yaml:"resolution"`
}

CommunitiesConfig holds configuration for module community detection

type CommunitiesTomlConfig added in v1.25.0

type CommunitiesTomlConfig struct {
	Enabled             *bool    `toml:"enabled"`
	Algorithm           string   `toml:"algorithm"`
	Scope               string   `toml:"scope"`
	MinCommunitySize    *int     `toml:"min_community_size"`
	IncludeLazyEdges    *bool    `toml:"include_lazy_edges"`
	ReportBridgeModules *bool    `toml:"report_bridge_modules"`
	Resolution          *float64 `toml:"resolution"`
}

CommunitiesTomlConfig represents the [communities] section

type ComplexityConfig

type ComplexityConfig struct {
	// LowThreshold is the upper bound for low complexity (inclusive)
	LowThreshold int `mapstructure:"low_threshold" yaml:"low_threshold"`

	// MediumThreshold is the upper bound for medium complexity (inclusive)
	// Values above this are considered high complexity
	MediumThreshold int `mapstructure:"medium_threshold" yaml:"medium_threshold"`

	// CognitiveComplexityThreshold is the high-risk threshold for cognitive complexity.
	CognitiveComplexityThreshold int `mapstructure:"cognitive_complexity_threshold" yaml:"cognitive_complexity_threshold"`

	// NestingDepthThreshold is the high-risk threshold for maximum nesting depth.
	NestingDepthThreshold int `mapstructure:"nesting_depth_threshold" yaml:"nesting_depth_threshold"`

	// FunctionSLOCWarnThreshold is the function length (in source lines) above
	// which a function is reported as long.
	FunctionSLOCWarnThreshold int `mapstructure:"function_sloc_warn_threshold" yaml:"function_sloc_warn_threshold"`

	// FunctionSLOCCriticalThreshold is the function length (in source lines)
	// above which a function is reported as too long.
	FunctionSLOCCriticalThreshold int `mapstructure:"function_sloc_critical_threshold" yaml:"function_sloc_critical_threshold"`

	// Enabled controls whether complexity analysis is performed
	Enabled bool `mapstructure:"enabled" yaml:"enabled"`

	// ReportUnchanged controls whether to report functions with complexity = 1
	ReportUnchanged bool `mapstructure:"report_unchanged" yaml:"report_unchanged"`

	// MaxComplexity is the maximum allowed complexity before failing analysis
	// 0 means no limit
	MaxComplexity int `mapstructure:"max_complexity" yaml:"max_complexity"`
}

ComplexityConfig holds configuration for cyclomatic complexity analysis

func (*ComplexityConfig) AssessRiskLevel

func (c *ComplexityConfig) AssessRiskLevel(complexity, cognitiveComplexity, nestingDepth int) string

AssessRiskLevel determines risk level based on cyclomatic complexity, cognitive complexity, nesting depth, and their thresholds.

func (*ComplexityConfig) ExceedsMaxComplexity

func (c *ComplexityConfig) ExceedsMaxComplexity(complexity int) bool

ExceedsMaxComplexity checks if complexity exceeds the maximum allowed

func (*ComplexityConfig) ShouldReport

func (c *ComplexityConfig) ShouldReport(complexity int) bool

ShouldReport determines if a complexity result should be reported

type ComplexityTomlConfig added in v1.4.0

type ComplexityTomlConfig struct {
	Enabled                      *bool `toml:"enabled"`                        // pointer to detect unset
	ReportUnchanged              *bool `toml:"report_unchanged"`               // pointer to detect unset
	LowThreshold                 *int  `toml:"low_threshold"`                  // pointer to detect unset
	MediumThreshold              *int  `toml:"medium_threshold"`               // pointer to detect unset
	CognitiveComplexityThreshold *int  `toml:"cognitive_complexity_threshold"` // pointer to detect unset
	NestingDepthThreshold        *int  `toml:"nesting_depth_threshold"`        // pointer to detect unset

	FunctionSLOCWarnThreshold     *int `toml:"function_sloc_warn_threshold"`     // pointer to detect unset
	FunctionSLOCCriticalThreshold *int `toml:"function_sloc_critical_threshold"` // pointer to detect unset

	MaxComplexity *int `toml:"max_complexity"` // pointer to detect unset
	MinComplexity *int `toml:"min_complexity"` // pointer to detect unset
}

ComplexityTomlConfig represents the [complexity] section

type Config

type Config struct {
	// Complexity holds complexity analysis configuration
	Complexity ComplexityConfig `mapstructure:"complexity" yaml:"complexity"`

	// DeadCode holds dead code detection configuration
	DeadCode DeadCodeConfig `mapstructure:"dead_code" yaml:"dead_code"`

	// Clones holds the unified clone detection configuration
	Clones *PyscnConfig `mapstructure:"clones" yaml:"clones"`

	// SystemAnalysis holds system-level analysis configuration
	SystemAnalysis SystemAnalysisConfig `mapstructure:"system_analysis" yaml:"system_analysis"`

	// Dependencies holds dependency analysis configuration
	Dependencies DependencyAnalysisConfig `mapstructure:"dependencies" yaml:"dependencies"`

	// Communities holds module community detection configuration
	Communities CommunitiesConfig `mapstructure:"communities" yaml:"communities"`

	// Architecture holds architecture validation configuration
	Architecture ArchitectureConfig `mapstructure:"architecture" yaml:"architecture"`

	// Output holds output formatting configuration
	Output OutputConfig `mapstructure:"output" yaml:"output"`

	// Analysis holds general analysis configuration
	Analysis AnalysisConfig `mapstructure:"analysis" yaml:"analysis"`
}

Config represents the main configuration structure

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration

func LoadConfig

func LoadConfig(configPath string) (*Config, error)

LoadConfig loads configuration from file or returns default config This is a TOML-only implementation that replaces the previous Viper-based loader

func LoadConfigWithTarget

func LoadConfigWithTarget(configPath string, targetPath string) (*Config, error)

LoadConfigWithTarget loads configuration with target path context Uses TOML-only configuration loader

func LoadDefaultConfigFromTOML added in v1.4.1

func LoadDefaultConfigFromTOML() (*Config, error)

LoadDefaultConfigFromTOML parses the embedded default config and returns the full Config struct

func PyscnConfigToConfig added in v1.4.1

func PyscnConfigToConfig(pyscn *PyscnConfig) *Config

PyscnConfigToConfig converts PyscnConfig (from TOML loader) to legacy Config struct

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration values

type DITomlConfig added in v1.16.0

type DITomlConfig struct {
	Enabled                   *bool  `toml:"enabled"`
	MinSeverity               string `toml:"min_severity"`
	ConstructorParamThreshold *int   `toml:"constructor_param_threshold"`
}

DITomlConfig represents the [di] section

type DeadCodeConfig

type DeadCodeConfig struct {
	// Enabled controls whether dead code detection is performed
	Enabled bool `mapstructure:"enabled" yaml:"enabled"`

	// MinSeverity is the minimum severity level to report
	MinSeverity string `mapstructure:"min_severity" yaml:"min_severity"`

	// ShowContext controls whether to show surrounding code context
	ShowContext bool `mapstructure:"show_context" yaml:"show_context"`

	// ContextLines is the number of context lines to show around dead code
	ContextLines int `mapstructure:"context_lines" yaml:"context_lines"`

	// SortBy specifies how to sort results: severity, line, file, function
	SortBy string `mapstructure:"sort_by" yaml:"sort_by"`

	// Detection options
	DetectAfterReturn         bool `mapstructure:"detect_after_return" yaml:"detect_after_return"`
	DetectAfterBreak          bool `mapstructure:"detect_after_break" yaml:"detect_after_break"`
	DetectAfterContinue       bool `mapstructure:"detect_after_continue" yaml:"detect_after_continue"`
	DetectAfterRaise          bool `mapstructure:"detect_after_raise" yaml:"detect_after_raise"`
	DetectUnreachableBranches bool `mapstructure:"detect_unreachable_branches" yaml:"detect_unreachable_branches"`

	// IgnorePatterns specifies patterns for code to ignore (e.g., comments, debug code)
	IgnorePatterns []string `mapstructure:"ignore_patterns" yaml:"ignore_patterns"`
}

DeadCodeConfig holds configuration for dead code detection

func (*DeadCodeConfig) GetMinSeverityLevel

func (c *DeadCodeConfig) GetMinSeverityLevel() int

GetMinSeverityLevel returns the minimum severity level as an integer for comparison

func (*DeadCodeConfig) HasAnyDetectionEnabled

func (c *DeadCodeConfig) HasAnyDetectionEnabled() bool

HasAnyDetectionEnabled checks if any detection type is enabled

func (*DeadCodeConfig) ShouldDetectDeadCode

func (c *DeadCodeConfig) ShouldDetectDeadCode() bool

ShouldDetectDeadCode determines if dead code detection should be performed

type DeadCodeTomlConfig added in v1.4.0

type DeadCodeTomlConfig struct {
	Enabled                   *bool    `toml:"enabled"`
	MinSeverity               string   `toml:"min_severity"`
	ShowContext               *bool    `toml:"show_context"`
	ContextLines              *int     `toml:"context_lines"`
	SortBy                    string   `toml:"sort_by"`
	DetectAfterReturn         *bool    `toml:"detect_after_return"`
	DetectAfterBreak          *bool    `toml:"detect_after_break"`
	DetectAfterContinue       *bool    `toml:"detect_after_continue"`
	DetectAfterRaise          *bool    `toml:"detect_after_raise"`
	DetectUnreachableBranches *bool    `toml:"detect_unreachable_branches"`
	IgnorePatterns            []string `toml:"ignore_patterns"`
}

DeadCodeTomlConfig represents the [dead_code] section

type DefaultConfigValues added in v1.11.1

type DefaultConfigValues struct {
	// Complexity
	ComplexityLowThreshold         int
	ComplexityMediumThreshold      int
	ComplexityLowThresholdPlus1    int
	ComplexityMediumThresholdPlus1 int
	ComplexityMinFilter            int
	ComplexityMaxLimit             int

	// Dead Code
	DeadCodeMinSeverity  string
	DeadCodeContextLines int
	DeadCodeSortBy       string

	// Clone thresholds
	Type1Threshold       float64
	Type2Threshold       float64
	Type3Threshold       float64
	Type4Threshold       float64
	SimilarityThreshold  float64
	GroupingThreshold    float64
	CloneMinLines        int
	CloneMinNodes        int
	CloneMaxEditDistance float64

	// LSH
	LSHAutoThreshold       int
	LSHSimilarityThreshold float64
	LSHBands               int
	LSHRows                int
	LSHHashes              int

	// Performance
	MaxMemoryMB    int
	BatchSize      int
	MaxGoroutines  int
	TimeoutSeconds int

	// CBO
	CBOLowThreshold      int
	CBOMediumThreshold   int
	CBOLowThresholdPlus1 int
}

DefaultConfigValues holds all values used to render the default config template. All values are sourced from the domain package to ensure a single source of truth.

type DependenciesTomlConfig added in v1.4.0

type DependenciesTomlConfig struct {
	Enabled           *bool    `toml:"enabled"`
	IncludeStdLib     *bool    `toml:"include_stdlib"`
	IncludeThirdParty *bool    `toml:"include_third_party"`
	FollowRelative    *bool    `toml:"follow_relative"`
	DetectCycles      *bool    `toml:"detect_cycles"`
	CalculateMetrics  *bool    `toml:"calculate_metrics"`
	FindLongChains    *bool    `toml:"find_long_chains"`
	MinCoupling       *int     `toml:"min_coupling"`
	MaxCoupling       *int     `toml:"max_coupling"`
	MinInstability    *float64 `toml:"min_instability"`
	MaxDistance       *float64 `toml:"max_distance"`
	SortBy            string   `toml:"sort_by"`
	ShowMatrix        *bool    `toml:"show_matrix"`
	ShowMetrics       *bool    `toml:"show_metrics"`
	ShowChains        *bool    `toml:"show_chains"`
	GenerateDotGraph  *bool    `toml:"generate_dot_graph"`
	CycleReporting    string   `toml:"cycle_reporting"`
	MaxCyclesToShow   *int     `toml:"max_cycles_to_show"`
	ShowCyclePaths    *bool    `toml:"show_cycle_paths"`
}

DependenciesTomlConfig represents the [dependencies] section

type DependencyAnalysisConfig

type DependencyAnalysisConfig struct {
	// Enabled controls whether dependency analysis is performed
	Enabled bool `mapstructure:"enabled" yaml:"enabled"`

	// Scope options
	IncludeStdLib     bool `mapstructure:"include_stdlib" yaml:"include_stdlib"`
	IncludeThirdParty bool `mapstructure:"include_third_party" yaml:"include_third_party"`
	FollowRelative    bool `mapstructure:"follow_relative" yaml:"follow_relative"`

	// Analysis options
	DetectCycles     bool `mapstructure:"detect_cycles" yaml:"detect_cycles"`
	CalculateMetrics bool `mapstructure:"calculate_metrics" yaml:"calculate_metrics"`
	FindLongChains   bool `mapstructure:"find_long_chains" yaml:"find_long_chains"`

	// Filtering thresholds
	MinCoupling    int     `mapstructure:"min_coupling" yaml:"min_coupling"`
	MaxCoupling    int     `mapstructure:"max_coupling" yaml:"max_coupling"`
	MinInstability float64 `mapstructure:"min_instability" yaml:"min_instability"`
	MaxDistance    float64 `mapstructure:"max_distance" yaml:"max_distance"`

	// Reporting options
	SortBy           string `mapstructure:"sort_by" yaml:"sort_by"` // name, coupling, instability, distance, risk
	ShowMatrix       bool   `mapstructure:"show_matrix" yaml:"show_matrix"`
	ShowMetrics      bool   `mapstructure:"show_metrics" yaml:"show_metrics"`
	ShowChains       bool   `mapstructure:"show_chains" yaml:"show_chains"`
	GenerateDotGraph bool   `mapstructure:"generate_dot_graph" yaml:"generate_dot_graph"`

	// Cycle analysis
	CycleReporting  string `mapstructure:"cycle_reporting" yaml:"cycle_reporting"` // all, critical, summary
	MaxCyclesToShow int    `mapstructure:"max_cycles_to_show" yaml:"max_cycles_to_show"`
	ShowCyclePaths  bool   `mapstructure:"show_cycle_paths" yaml:"show_cycle_paths"`
}

DependencyAnalysisConfig holds configuration for dependency analysis

type FilteringConfig

type FilteringConfig struct {
	// Similarity range filtering
	MinSimilarity float64 `mapstructure:"min_similarity" yaml:"min_similarity" json:"min_similarity"`
	MaxSimilarity float64 `mapstructure:"max_similarity" yaml:"max_similarity" json:"max_similarity"`

	// Clone type filtering
	EnabledCloneTypes []string `mapstructure:"enabled_clone_types" yaml:"enabled_clone_types" json:"enabled_clone_types"`

	// Result limiting
	MaxResults int `mapstructure:"max_results" yaml:"max_results" json:"max_results"`
}

FilteringConfig holds filtering and selection criteria

func (*FilteringConfig) Validate

func (f *FilteringConfig) Validate() error

Validate validates the filtering configuration

type GroupingConfig

type GroupingConfig struct {
	// Grouping strategy: connected, star, complete_linkage, k_core
	Mode string `mapstructure:"mode" yaml:"mode" json:"mode"`

	// Minimum similarity threshold for group membership
	Threshold float64 `mapstructure:"threshold" yaml:"threshold" json:"threshold"`

	// K value for k-core mode (minimum neighbors)
	KCoreK int `mapstructure:"k_core_k" yaml:"k_core_k" json:"k_core_k"`
}

GroupingConfig holds clone grouping configuration

type InputConfig

type InputConfig struct {
	// File selection
	Paths           []string `mapstructure:"paths" yaml:"paths" json:"paths"`
	Recursive       *bool    `mapstructure:"recursive" yaml:"recursive" json:"recursive"`
	IncludePatterns []string `mapstructure:"include_patterns" yaml:"include_patterns" json:"include_patterns"`
	ExcludePatterns []string `mapstructure:"exclude_patterns" yaml:"exclude_patterns" json:"exclude_patterns"`
}

InputConfig holds input processing configuration

func (*InputConfig) Validate

func (i *InputConfig) Validate() error

Validate validates the input configuration

type LSHConfig

type LSHConfig struct {
	// Whether to enable LSH acceleration: true, false, "auto"
	Enabled string `mapstructure:"enabled" yaml:"enabled" json:"enabled"`

	// Fragment count threshold for auto-enabling LSH
	AutoThreshold int `mapstructure:"auto_threshold" yaml:"auto_threshold" json:"auto_threshold"`

	// LSH similarity threshold for candidate generation
	SimilarityThreshold float64 `mapstructure:"similarity_threshold" yaml:"similarity_threshold" json:"similarity_threshold"`

	// LSH parameters (advanced)
	Bands  int `mapstructure:"bands" yaml:"bands" json:"bands"`
	Rows   int `mapstructure:"rows" yaml:"rows" json:"rows"`
	Hashes int `mapstructure:"hashes" yaml:"hashes" json:"hashes"`
}

LSHConfig holds LSH acceleration configuration

type LayerDefinition

type LayerDefinition struct {
	Name        string   `mapstructure:"name" yaml:"name"`
	Packages    []string `mapstructure:"packages" yaml:"packages"`
	Description string   `mapstructure:"description" yaml:"description"`
	IsAbstract  bool     `mapstructure:"is_abstract" yaml:"is_abstract"`
}

LayerDefinition defines an architectural layer

type LayerDefinitionToml added in v1.4.1

type LayerDefinitionToml struct {
	Name        string   `toml:"name"`
	Description string   `toml:"description"`
	Packages    []string `toml:"packages"`
	IsAbstract  bool     `toml:"is_abstract"`
}

LayerDefinitionToml represents a layer definition in TOML

type LayerRule

type LayerRule struct {
	From        string   `mapstructure:"from" yaml:"from"`
	Allow       []string `mapstructure:"allow" yaml:"allow"`
	Deny        []string `mapstructure:"deny" yaml:"deny"`
	Warn        []string `mapstructure:"warn" yaml:"warn"`
	Description string   `mapstructure:"description" yaml:"description"`
}

LayerRule defines dependency rules between layers

type LayerRuleToml added in v1.4.1

type LayerRuleToml struct {
	From        string   `toml:"from"`
	Allow       []string `toml:"allow"`
	Deny        []string `toml:"deny"`
	Warn        []string `toml:"warn"`
	Description string   `toml:"description"`
}

LayerRuleToml represents a layer rule in TOML

type LcomTomlConfig added in v1.11.0

type LcomTomlConfig struct {
	LowThreshold    *int `toml:"low_threshold"`
	MediumThreshold *int `toml:"medium_threshold"`
}

LcomTomlConfig represents the [lcom] section

type MockDataTomlConfig added in v1.7.0

type MockDataTomlConfig struct {
	Enabled        *bool    `toml:"enabled"`
	MinSeverity    string   `toml:"min_severity"`
	SortBy         string   `toml:"sort_by"`
	IgnoreTests    *bool    `toml:"ignore_tests"`
	Keywords       []string `toml:"keywords"`
	Domains        []string `toml:"domains"`
	IgnorePatterns []string `toml:"ignore_patterns"`
}

MockDataTomlConfig represents the [mock_data] section

type OutputConfig

type OutputConfig struct {
	// Format specifies the output format: json, yaml, text, csv
	Format string `mapstructure:"format" yaml:"format"`

	// ShowDetails controls whether to show detailed breakdown
	ShowDetails bool `mapstructure:"show_details" yaml:"show_details"`

	// SortBy specifies how to sort results: name, complexity, risk
	SortBy string `mapstructure:"sort_by" yaml:"sort_by"`

	// MinComplexity is the minimum complexity to report (filters low values)
	MinComplexity int `mapstructure:"min_complexity" yaml:"min_complexity"`

	// Directory specifies the output directory for reports (empty = tool default, e.g., ".pyscn/reports" under current working directory)
	Directory string `mapstructure:"directory" yaml:"directory"`
}

OutputConfig holds configuration for output formatting

type OutputTomlConfig added in v1.4.0

type OutputTomlConfig struct {
	Format        string `toml:"format"`
	ShowDetails   *bool  `toml:"show_details"`
	SortBy        string `toml:"sort_by"`
	MinComplexity *int   `toml:"min_complexity"`
	Directory     string `toml:"directory"`
}

OutputTomlConfig represents the [output] section

type PerformanceConfig

type PerformanceConfig struct {
	// Memory management
	MaxMemoryMB    int   `mapstructure:"max_memory_mb" yaml:"max_memory_mb" json:"max_memory_mb"`
	BatchSize      int   `mapstructure:"batch_size" yaml:"batch_size" json:"batch_size"`
	EnableBatching *bool `mapstructure:"enable_batching" yaml:"enable_batching" json:"enable_batching"`

	// Parallelization
	MaxGoroutines int `mapstructure:"max_goroutines" yaml:"max_goroutines" json:"max_goroutines"`

	// Early termination
	TimeoutSeconds int `mapstructure:"timeout_seconds" yaml:"timeout_seconds" json:"timeout_seconds"`
}

PerformanceConfig holds performance-related settings

func (*PerformanceConfig) Validate

func (p *PerformanceConfig) Validate() error

Validate validates the performance configuration

type PyprojectPyscnSection added in v1.4.0

type PyprojectPyscnSection struct {
	ProjectRoot    string                   `toml:"project_root"`
	Complexity     ComplexityTomlConfig     `toml:"complexity"`
	DeadCode       DeadCodeTomlConfig       `toml:"dead_code"`
	Output         OutputTomlConfig         `toml:"output"`
	Analysis       AnalysisTomlConfig       `toml:"analysis"`
	Cbo            CboTomlConfig            `toml:"cbo"`
	Lcom           LcomTomlConfig           `toml:"lcom"`
	Architecture   ArchitectureTomlConfig   `toml:"architecture"`
	SystemAnalysis SystemAnalysisTomlConfig `toml:"system_analysis"`
	Dependencies   DependenciesTomlConfig   `toml:"dependencies"`
	Communities    CommunitiesTomlConfig    `toml:"communities"`
	Clones         ClonesConfig             `toml:"clones"`
	DI             DITomlConfig             `toml:"di"`
}

PyprojectPyscnSection represents the [tool.pyscn] section in pyproject.toml

type PyprojectToml

type PyprojectToml struct {
	Tool ToolConfig `toml:"tool"`
}

PyprojectToml represents the structure of pyproject.toml

type PyscnConfig

type PyscnConfig struct {
	// ProjectRoot is the effective absolute project root resolved from the
	// configuration file location and its optional project_root value.
	ProjectRoot string `mapstructure:"project_root" yaml:"project_root" json:"project_root"`

	// Clone Analysis Configuration
	Analysis CloneAnalysisConfig `mapstructure:"analysis" yaml:"analysis" json:"analysis"`

	// Thresholds Configuration
	Thresholds ThresholdConfig `mapstructure:"thresholds" yaml:"thresholds" json:"thresholds"`

	// Filtering Configuration
	Filtering FilteringConfig `mapstructure:"filtering" yaml:"filtering" json:"filtering"`

	// Input Configuration
	Input InputConfig `mapstructure:"input" yaml:"input" json:"input"`

	// Output Configuration (Clone-specific)
	Output CloneOutputConfig `mapstructure:"output" yaml:"output" json:"output"`

	// Performance Configuration
	Performance PerformanceConfig `mapstructure:"performance" yaml:"performance" json:"performance"`

	// Grouping Configuration
	Grouping GroupingConfig `mapstructure:"grouping" yaml:"grouping" json:"grouping"`

	// LSH Configuration
	LSH LSHConfig `mapstructure:"lsh" yaml:"lsh" json:"lsh"`

	// Complexity Configuration (from [complexity] section in TOML)
	ComplexityEnabled            *bool `mapstructure:"complexity_enabled" yaml:"complexity_enabled" json:"complexity_enabled"`
	ComplexityReportUnchanged    *bool `mapstructure:"complexity_report_unchanged" yaml:"complexity_report_unchanged" json:"complexity_report_unchanged"`
	ComplexityLowThreshold       int   `mapstructure:"complexity_low_threshold" yaml:"complexity_low_threshold" json:"complexity_low_threshold"`
	ComplexityMediumThreshold    int   `mapstructure:"complexity_medium_threshold" yaml:"complexity_medium_threshold" json:"complexity_medium_threshold"`
	CognitiveComplexityThreshold int   `mapstructure:"cognitive_complexity_threshold" yaml:"cognitive_complexity_threshold" json:"cognitive_complexity_threshold"`
	NestingDepthThreshold        int   `mapstructure:"nesting_depth_threshold" yaml:"nesting_depth_threshold" json:"nesting_depth_threshold"`

	FunctionSLOCWarnThreshold     int `mapstructure:"function_sloc_warn_threshold" yaml:"function_sloc_warn_threshold" json:"function_sloc_warn_threshold"`
	FunctionSLOCCriticalThreshold int `` /* 127-byte string literal not displayed */

	ComplexityMaxComplexity int `mapstructure:"complexity_max_complexity" yaml:"complexity_max_complexity" json:"complexity_max_complexity"`
	ComplexityMinComplexity int `mapstructure:"complexity_min_complexity" yaml:"complexity_min_complexity" json:"complexity_min_complexity"`

	// DeadCode Configuration (from [dead_code] section in TOML)
	DeadCodeEnabled                   *bool    `mapstructure:"dead_code_enabled" yaml:"dead_code_enabled" json:"dead_code_enabled"`
	DeadCodeMinSeverity               string   `mapstructure:"dead_code_min_severity" yaml:"dead_code_min_severity" json:"dead_code_min_severity"`
	DeadCodeShowContext               *bool    `mapstructure:"dead_code_show_context" yaml:"dead_code_show_context" json:"dead_code_show_context"`
	DeadCodeContextLines              int      `mapstructure:"dead_code_context_lines" yaml:"dead_code_context_lines" json:"dead_code_context_lines"`
	DeadCodeSortBy                    string   `mapstructure:"dead_code_sort_by" yaml:"dead_code_sort_by" json:"dead_code_sort_by"`
	DeadCodeDetectAfterReturn         *bool    `mapstructure:"dead_code_detect_after_return" yaml:"dead_code_detect_after_return" json:"dead_code_detect_after_return"`
	DeadCodeDetectAfterBreak          *bool    `mapstructure:"dead_code_detect_after_break" yaml:"dead_code_detect_after_break" json:"dead_code_detect_after_break"`
	DeadCodeDetectAfterContinue       *bool    `mapstructure:"dead_code_detect_after_continue" yaml:"dead_code_detect_after_continue" json:"dead_code_detect_after_continue"`
	DeadCodeDetectAfterRaise          *bool    `mapstructure:"dead_code_detect_after_raise" yaml:"dead_code_detect_after_raise" json:"dead_code_detect_after_raise"`
	DeadCodeDetectUnreachableBranches *bool    `` /* 142-byte string literal not displayed */
	DeadCodeIgnorePatterns            []string `mapstructure:"dead_code_ignore_patterns" yaml:"dead_code_ignore_patterns" json:"dead_code_ignore_patterns"`

	// Output Configuration (from [output] section in TOML - general output settings)
	OutputFormat        string `mapstructure:"output_format" yaml:"output_format" json:"output_format"`
	OutputShowDetails   *bool  `mapstructure:"output_show_details" yaml:"output_show_details" json:"output_show_details"`
	OutputSortBy        string `mapstructure:"output_sort_by" yaml:"output_sort_by" json:"output_sort_by"`
	OutputMinComplexity int    `mapstructure:"output_min_complexity" yaml:"output_min_complexity" json:"output_min_complexity"`
	OutputDirectory     string `mapstructure:"output_directory" yaml:"output_directory" json:"output_directory"`

	// Analysis Configuration (from [analysis] section in TOML - general analysis settings)
	AnalysisIncludePatterns []string `mapstructure:"analysis_include_patterns" yaml:"analysis_include_patterns" json:"analysis_include_patterns"`
	AnalysisExcludePatterns []string `mapstructure:"analysis_exclude_patterns" yaml:"analysis_exclude_patterns" json:"analysis_exclude_patterns"`
	AnalysisRecursive       *bool    `mapstructure:"analysis_recursive" yaml:"analysis_recursive" json:"analysis_recursive"`
	AnalysisFollowSymlinks  *bool    `mapstructure:"analysis_follow_symlinks" yaml:"analysis_follow_symlinks" json:"analysis_follow_symlinks"`

	// CBO Configuration (from [cbo] section in TOML)
	CboLowThreshold          int   `mapstructure:"cbo_low_threshold" yaml:"cbo_low_threshold" json:"cbo_low_threshold"`
	CboMediumThreshold       int   `mapstructure:"cbo_medium_threshold" yaml:"cbo_medium_threshold" json:"cbo_medium_threshold"`
	CboMinCbo                int   `mapstructure:"cbo_min_cbo" yaml:"cbo_min_cbo" json:"cbo_min_cbo"`
	CboMaxCbo                int   `mapstructure:"cbo_max_cbo" yaml:"cbo_max_cbo" json:"cbo_max_cbo"`
	CboShowZeros             *bool `mapstructure:"cbo_show_zeros" yaml:"cbo_show_zeros" json:"cbo_show_zeros"`
	CboIncludeBuiltins       *bool `mapstructure:"cbo_include_builtins" yaml:"cbo_include_builtins" json:"cbo_include_builtins"`
	CboIncludeImports        *bool `mapstructure:"cbo_include_imports" yaml:"cbo_include_imports" json:"cbo_include_imports"`
	CboGroupNamespaceImports *bool `mapstructure:"cbo_group_namespace_imports" yaml:"cbo_group_namespace_imports" json:"cbo_group_namespace_imports"`

	// LCOM Configuration (from [lcom] section in TOML)
	LcomLowThreshold    int `mapstructure:"lcom_low_threshold" yaml:"lcom_low_threshold" json:"lcom_low_threshold"`
	LcomMediumThreshold int `mapstructure:"lcom_medium_threshold" yaml:"lcom_medium_threshold" json:"lcom_medium_threshold"`

	// Architecture Configuration (from [architecture] section in TOML)
	ArchitectureEnabled                         *bool             `mapstructure:"architecture_enabled" yaml:"architecture_enabled" json:"architecture_enabled"`
	ArchitectureValidateLayers                  *bool             `mapstructure:"architecture_validate_layers" yaml:"architecture_validate_layers" json:"architecture_validate_layers"`
	ArchitectureValidateCohesion                *bool             `mapstructure:"architecture_validate_cohesion" yaml:"architecture_validate_cohesion" json:"architecture_validate_cohesion"`
	ArchitectureValidateResponsibility          *bool             `` /* 139-byte string literal not displayed */
	ArchitectureMinCohesion                     float64           `mapstructure:"architecture_min_cohesion" yaml:"architecture_min_cohesion" json:"architecture_min_cohesion"`
	ArchitectureMaxCoupling                     int               `mapstructure:"architecture_max_coupling" yaml:"architecture_max_coupling" json:"architecture_max_coupling"`
	ArchitectureMaxResponsibilities             int               `` /* 130-byte string literal not displayed */
	ArchitectureLayerViolationSeverity          string            `` /* 142-byte string literal not displayed */
	ArchitectureCohesionViolationSeverity       string            `` /* 151-byte string literal not displayed */
	ArchitectureResponsibilityViolationSeverity string            `` /* 169-byte string literal not displayed */
	ArchitectureShowAllViolations               *bool             `` /* 127-byte string literal not displayed */
	ArchitectureGroupByType                     *bool             `mapstructure:"architecture_group_by_type" yaml:"architecture_group_by_type" json:"architecture_group_by_type"`
	ArchitectureIncludeSuggestions              *bool             `` /* 127-byte string literal not displayed */
	ArchitectureMaxViolationsToShow             int               `` /* 136-byte string literal not displayed */
	ArchitectureCustomPatterns                  []string          `mapstructure:"architecture_custom_patterns" yaml:"architecture_custom_patterns" json:"architecture_custom_patterns"`
	ArchitectureAllowedPatterns                 []string          `mapstructure:"architecture_allowed_patterns" yaml:"architecture_allowed_patterns" json:"architecture_allowed_patterns"`
	ArchitectureForbiddenPatterns               []string          `mapstructure:"architecture_forbidden_patterns" yaml:"architecture_forbidden_patterns" json:"architecture_forbidden_patterns"`
	ArchitectureStrictMode                      *bool             `mapstructure:"architecture_strict_mode" yaml:"architecture_strict_mode" json:"architecture_strict_mode"`
	ArchitectureFailOnViolations                *bool             `mapstructure:"architecture_fail_on_violations" yaml:"architecture_fail_on_violations" json:"architecture_fail_on_violations"`
	ArchitectureNeutralPrefixes                 []string          `mapstructure:"architecture_neutral_prefixes" yaml:"architecture_neutral_prefixes" json:"architecture_neutral_prefixes"`
	ArchitectureStyle                           string            `mapstructure:"architecture_style" yaml:"architecture_style" json:"architecture_style"`
	ArchitectureLayers                          []LayerDefinition `mapstructure:"architecture_layers" yaml:"architecture_layers" json:"architecture_layers"`
	ArchitectureRules                           []LayerRule       `mapstructure:"architecture_rules" yaml:"architecture_rules" json:"architecture_rules"`

	// SystemAnalysis Configuration (from [system_analysis] section in TOML)
	SystemAnalysisEnabled               *bool `mapstructure:"system_analysis_enabled" yaml:"system_analysis_enabled" json:"system_analysis_enabled"`
	SystemAnalysisEnableDependencies    *bool `` /* 136-byte string literal not displayed */
	SystemAnalysisEnableArchitecture    *bool `` /* 136-byte string literal not displayed */
	SystemAnalysisUseComplexityData     *bool `` /* 136-byte string literal not displayed */
	SystemAnalysisUseClonesData         *bool `mapstructure:"system_analysis_use_clones_data" yaml:"system_analysis_use_clones_data" json:"system_analysis_use_clones_data"`
	SystemAnalysisUseDeadCodeData       *bool `` /* 133-byte string literal not displayed */
	SystemAnalysisGenerateUnifiedReport *bool `` /* 148-byte string literal not displayed */

	// Communities Configuration (from [communities] section in TOML)
	CommunitiesEnabled             *bool   `mapstructure:"communities_enabled" yaml:"communities_enabled" json:"communities_enabled"`
	CommunitiesAlgorithm           string  `mapstructure:"communities_algorithm" yaml:"communities_algorithm" json:"communities_algorithm"`
	CommunitiesScope               string  `mapstructure:"communities_scope" yaml:"communities_scope" json:"communities_scope"`
	CommunitiesMinCommunitySize    int     `mapstructure:"communities_min_community_size" yaml:"communities_min_community_size" json:"communities_min_community_size"`
	CommunitiesIncludeLazyEdges    *bool   `mapstructure:"communities_include_lazy_edges" yaml:"communities_include_lazy_edges" json:"communities_include_lazy_edges"`
	CommunitiesReportBridgeModules *bool   `` /* 130-byte string literal not displayed */
	CommunitiesResolution          float64 `mapstructure:"communities_resolution" yaml:"communities_resolution" json:"communities_resolution"`

	// Dependencies Configuration (from [dependencies] section in TOML)
	DependenciesEnabled           *bool   `mapstructure:"dependencies_enabled" yaml:"dependencies_enabled" json:"dependencies_enabled"`
	DependenciesIncludeStdLib     *bool   `mapstructure:"dependencies_include_stdlib" yaml:"dependencies_include_stdlib" json:"dependencies_include_stdlib"`
	DependenciesIncludeThirdParty *bool   `` /* 127-byte string literal not displayed */
	DependenciesFollowRelative    *bool   `mapstructure:"dependencies_follow_relative" yaml:"dependencies_follow_relative" json:"dependencies_follow_relative"`
	DependenciesDetectCycles      *bool   `mapstructure:"dependencies_detect_cycles" yaml:"dependencies_detect_cycles" json:"dependencies_detect_cycles"`
	DependenciesCalculateMetrics  *bool   `mapstructure:"dependencies_calculate_metrics" yaml:"dependencies_calculate_metrics" json:"dependencies_calculate_metrics"`
	DependenciesFindLongChains    *bool   `mapstructure:"dependencies_find_long_chains" yaml:"dependencies_find_long_chains" json:"dependencies_find_long_chains"`
	DependenciesMinCoupling       int     `mapstructure:"dependencies_min_coupling" yaml:"dependencies_min_coupling" json:"dependencies_min_coupling"`
	DependenciesMaxCoupling       int     `mapstructure:"dependencies_max_coupling" yaml:"dependencies_max_coupling" json:"dependencies_max_coupling"`
	DependenciesMinInstability    float64 `mapstructure:"dependencies_min_instability" yaml:"dependencies_min_instability" json:"dependencies_min_instability"`
	DependenciesMaxDistance       float64 `mapstructure:"dependencies_max_distance" yaml:"dependencies_max_distance" json:"dependencies_max_distance"`
	DependenciesSortBy            string  `mapstructure:"dependencies_sort_by" yaml:"dependencies_sort_by" json:"dependencies_sort_by"`
	DependenciesShowMatrix        *bool   `mapstructure:"dependencies_show_matrix" yaml:"dependencies_show_matrix" json:"dependencies_show_matrix"`
	DependenciesShowMetrics       *bool   `mapstructure:"dependencies_show_metrics" yaml:"dependencies_show_metrics" json:"dependencies_show_metrics"`
	DependenciesShowChains        *bool   `mapstructure:"dependencies_show_chains" yaml:"dependencies_show_chains" json:"dependencies_show_chains"`
	DependenciesGenerateDotGraph  *bool   `mapstructure:"dependencies_generate_dot_graph" yaml:"dependencies_generate_dot_graph" json:"dependencies_generate_dot_graph"`
	DependenciesCycleReporting    string  `mapstructure:"dependencies_cycle_reporting" yaml:"dependencies_cycle_reporting" json:"dependencies_cycle_reporting"`
	DependenciesMaxCyclesToShow   int     `mapstructure:"dependencies_max_cycles_to_show" yaml:"dependencies_max_cycles_to_show" json:"dependencies_max_cycles_to_show"`
	DependenciesShowCyclePaths    *bool   `mapstructure:"dependencies_show_cycle_paths" yaml:"dependencies_show_cycle_paths" json:"dependencies_show_cycle_paths"`

	// MockData Configuration (from [mock_data] section in TOML)
	MockDataEnabled        *bool    `mapstructure:"mock_data_enabled" yaml:"mock_data_enabled" json:"mock_data_enabled"`
	MockDataMinSeverity    string   `mapstructure:"mock_data_min_severity" yaml:"mock_data_min_severity" json:"mock_data_min_severity"`
	MockDataSortBy         string   `mapstructure:"mock_data_sort_by" yaml:"mock_data_sort_by" json:"mock_data_sort_by"`
	MockDataIgnoreTests    *bool    `mapstructure:"mock_data_ignore_tests" yaml:"mock_data_ignore_tests" json:"mock_data_ignore_tests"`
	MockDataKeywords       []string `mapstructure:"mock_data_keywords" yaml:"mock_data_keywords" json:"mock_data_keywords"`
	MockDataDomains        []string `mapstructure:"mock_data_domains" yaml:"mock_data_domains" json:"mock_data_domains"`
	MockDataIgnorePatterns []string `mapstructure:"mock_data_ignore_patterns" yaml:"mock_data_ignore_patterns" json:"mock_data_ignore_patterns"`

	// DI Configuration (from [di] section in TOML)
	DIEnabled                   *bool  `mapstructure:"di_enabled" yaml:"di_enabled" json:"di_enabled"`
	DIMinSeverity               string `mapstructure:"di_min_severity" yaml:"di_min_severity" json:"di_min_severity"`
	DIConstructorParamThreshold int    `mapstructure:"di_constructor_param_threshold" yaml:"di_constructor_param_threshold" json:"di_constructor_param_threshold"`
	// contains filtered or unexported fields
}

PyscnConfig represents the universal pyscn configuration from TOML files This holds all configuration sections that can be loaded from .pyscn.toml or pyproject.toml

func DefaultPyscnConfig added in v1.4.0

func DefaultPyscnConfig() *PyscnConfig

DefaultPyscnConfig returns a configuration with sensible defaults All default values are sourced from domain/defaults.go

func FromCloneRequest

func FromCloneRequest(request *domain.CloneRequest) *PyscnConfig

FromCloneRequest creates unified PyscnConfig from domain's CloneRequest

func LoadPyprojectConfig

func LoadPyprojectConfig(startDir string) (*PyscnConfig, error)

LoadPyprojectConfig loads pyscn configuration from pyproject.toml

func LoadPyprojectConfigFromFile added in v1.10.1

func LoadPyprojectConfigFromFile(filePath string) (*PyscnConfig, error)

LoadPyprojectConfigFromFile loads configuration from a specific pyproject.toml file path.

func (*PyscnConfig) EffectiveFunctionSLOCThresholds added in v1.29.1

func (c *PyscnConfig) EffectiveFunctionSLOCThresholds() (warn int, critical int)

EffectiveFunctionSLOCThresholds resolves the long-function tiers. Setting one tier moves the other with it, so raising just the warn threshold past the default critical threshold (or lowering just the critical threshold below the default warn threshold) cannot produce an inverted pair. Setting both keeps the values verbatim, leaving an inverted pair for validation to reject.

func (*PyscnConfig) EffectiveOutputMinComplexity added in v1.16.0

func (c *PyscnConfig) EffectiveOutputMinComplexity() int

EffectiveOutputMinComplexity resolves the output filter precedence. [output].min_complexity overrides [complexity].min_complexity only when the output value was explicitly set.

func (*PyscnConfig) HasExplicitAnalysisIncludePatterns added in v1.22.5

func (c *PyscnConfig) HasExplicitAnalysisIncludePatterns() bool

func (*PyscnConfig) ToCloneRequest added in v1.4.0

func (c *PyscnConfig) ToCloneRequest(outputWriter io.Writer) *domain.CloneRequest

ToCloneRequest converts unified PyscnConfig to domain's CloneRequest This maintains backward compatibility with the domain package

func (*PyscnConfig) Validate added in v1.4.0

func (c *PyscnConfig) Validate() error

Validate checks if the configuration is valid

type PyscnTomlConfig

type PyscnTomlConfig struct {
	// ProjectRoot is resolved relative to the directory containing the config file.
	ProjectRoot    string                   `toml:"project_root"`
	Complexity     ComplexityTomlConfig     `toml:"complexity"`      // [complexity] section
	DeadCode       DeadCodeTomlConfig       `toml:"dead_code"`       // [dead_code] section
	Output         OutputTomlConfig         `toml:"output"`          // [output] section
	Analysis       AnalysisTomlConfig       `toml:"analysis"`        // [analysis] section
	Cbo            CboTomlConfig            `toml:"cbo"`             // [cbo] section
	Lcom           LcomTomlConfig           `toml:"lcom"`            // [lcom] section
	Architecture   ArchitectureTomlConfig   `toml:"architecture"`    // [architecture] section
	SystemAnalysis SystemAnalysisTomlConfig `toml:"system_analysis"` // [system_analysis] section
	Dependencies   DependenciesTomlConfig   `toml:"dependencies"`    // [dependencies] section
	Communities    CommunitiesTomlConfig    `toml:"communities"`     // [communities] section
	Clones         ClonesConfig             `toml:"clones"`          // [clones] section - unified flat structure
	MockData       MockDataTomlConfig       `toml:"mock_data"`       // [mock_data] section
	DI             DITomlConfig             `toml:"di"`              // [di] section
}

PyscnTomlConfig represents the structure of .pyscn.toml

func ConfigToPyscnTomlConfig added in v1.4.1

func ConfigToPyscnTomlConfig(cfg *Config) *PyscnTomlConfig

ConfigToPyscnTomlConfig converts a Config to PyscnTomlConfig for TOML serialization

type SystemAnalysisConfig

type SystemAnalysisConfig struct {
	// Enabled controls whether system analysis is performed
	Enabled bool `mapstructure:"enabled" yaml:"enabled"`

	// Analysis components to enable
	EnableDependencies bool `mapstructure:"enable_dependencies" yaml:"enable_dependencies"`
	EnableArchitecture bool `mapstructure:"enable_architecture" yaml:"enable_architecture"`

	// Integration with other analyses
	UseComplexityData bool `mapstructure:"use_complexity_data" yaml:"use_complexity_data"`
	UseClonesData     bool `mapstructure:"use_clones_data" yaml:"use_clones_data"`
	UseDeadCodeData   bool `mapstructure:"use_dead_code_data" yaml:"use_dead_code_data"`

	// Output options
	GenerateUnifiedReport bool `mapstructure:"generate_unified_report" yaml:"generate_unified_report"`
}

SystemAnalysisConfig holds configuration for system-level analysis

type SystemAnalysisTomlConfig added in v1.4.0

type SystemAnalysisTomlConfig struct {
	Enabled               *bool `toml:"enabled"`
	EnableDependencies    *bool `toml:"enable_dependencies"`
	EnableArchitecture    *bool `toml:"enable_architecture"`
	UseComplexityData     *bool `toml:"use_complexity_data"`
	UseClonesData         *bool `toml:"use_clones_data"`
	UseDeadCodeData       *bool `toml:"use_dead_code_data"`
	GenerateUnifiedReport *bool `toml:"generate_unified_report"`
}

SystemAnalysisTomlConfig represents the [system_analysis] section

type ThresholdConfig

type ThresholdConfig struct {
	// Type-specific thresholds (these determine clone classification)
	Type1Threshold float64 `mapstructure:"type1_threshold" yaml:"type1_threshold" json:"type1_threshold"`
	Type2Threshold float64 `mapstructure:"type2_threshold" yaml:"type2_threshold" json:"type2_threshold"`
	Type3Threshold float64 `mapstructure:"type3_threshold" yaml:"type3_threshold" json:"type3_threshold"`
	Type4Threshold float64 `mapstructure:"type4_threshold" yaml:"type4_threshold" json:"type4_threshold"`

	// General similarity threshold (minimum for any clone to be reported)
	SimilarityThreshold float64 `mapstructure:"similarity_threshold" yaml:"similarity_threshold" json:"similarity_threshold"`
}

ThresholdConfig holds similarity thresholds for different clone types

func (*ThresholdConfig) Validate

func (t *ThresholdConfig) Validate() error

Validate validates the threshold configuration

type TomlConfigLoader

type TomlConfigLoader struct{}

TomlConfigLoader handles TOML-only configuration loading

func NewTomlConfigLoader

func NewTomlConfigLoader() *TomlConfigLoader

NewTomlConfigLoader creates a new TOML configuration loader

func (*TomlConfigLoader) FindConfigFileFromPath added in v1.10.1

func (l *TomlConfigLoader) FindConfigFileFromPath(startPath string) string

FindConfigFileFromPath discovers a config file from the given path. Priority: 1. .pyscn.toml 2. pyproject.toml containing [tool.pyscn]

func (*TomlConfigLoader) GetSupportedConfigFiles

func (l *TomlConfigLoader) GetSupportedConfigFiles() []string

GetSupportedConfigFiles returns the list of supported TOML config files in order of precedence

func (*TomlConfigLoader) LoadConfig

func (l *TomlConfigLoader) LoadConfig(path string) (*PyscnConfig, error)

LoadConfig loads configuration from TOML files with ruff-like priority: 1. .pyscn.toml (dedicated config file) 2. pyproject.toml (with [tool.pyscn] section) 3. defaults

The path parameter can be either: - a direct file path (e.g. "/path/to/pyproject.toml") - a directory path (searches parent directories)

func (*TomlConfigLoader) ResolveConfigPath added in v1.10.1

func (l *TomlConfigLoader) ResolveConfigPath(configPath string, targetPath string) (string, error)

ResolveConfigPath resolves the effective configuration file path once.

  • If configPath is provided, it must exist; files are used directly and directories are searched.
  • If configPath is empty, targetPath (or cwd) is searched.

type ToolConfig

type ToolConfig struct {
	Pyscn PyprojectPyscnSection `toml:"pyscn"`
}

ToolConfig represents the [tool] section

Jump to

Keyboard shortcuts

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