config

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLowComplexityThreshold defines the upper bound for low complexity functions
	// Functions with complexity <= 9 are considered low risk and easy to maintain
	DefaultLowComplexityThreshold = 9

	// DefaultMediumComplexityThreshold defines the upper bound for medium complexity functions
	// Functions with complexity 10-19 are considered medium risk and may need refactoring
	DefaultMediumComplexityThreshold = 19

	// DefaultMinComplexityFilter defines the minimum complexity to report
	// Functions with complexity >= 1 will be included in reports
	DefaultMinComplexityFilter = 1

	// DefaultMaxComplexityLimit defines no upper limit for complexity analysis
	// Setting to 0 means no maximum complexity enforcement
	DefaultMaxComplexityLimit = 0
)

Default complexity thresholds based on McCabe complexity standards

View Source
const (
	// DefaultDeadCodeMinSeverity defines the minimum severity level to report
	DefaultDeadCodeMinSeverity = "warning"

	// DefaultDeadCodeContextLines defines the number of context lines to show
	DefaultDeadCodeContextLines = 3

	// DefaultDeadCodeSortBy defines the default sorting criteria
	DefaultDeadCodeSortBy = "severity"
)

Default dead code detection settings

Variables

View Source
var DefaultConfigJSON string

DefaultConfigJSON contains the embedded default configuration file

Functions

func BoolPtr

func BoolPtr(b bool) *bool

BoolPtr returns a pointer to the given bool value This helper function is used to create *bool values in struct literals

func BoolValue

func BoolValue(b *bool, defaultVal bool) bool

BoolValue safely dereferences a boolean pointer, returning defaultVal if nil This allows safe access to pointer booleans with explicit defaults

func GetFullConfigTemplate

func GetFullConfigTemplate(projectType ProjectType, strictness Strictness) string

GetFullConfigTemplate returns a full config template as valid JSON.

func GetMinimalConfigTemplate

func GetMinimalConfigTemplate() string

GetMinimalConfigTemplate returns a minimal config template as valid JSON.

func GetProjectPresets

func GetProjectPresets() map[ProjectType]ProjectPreset

GetProjectPresets returns presets for different project types

func GetStrictnessPresets

func GetStrictnessPresets() map[Strictness]StrictnessPreset

GetStrictnessPresets returns presets for different strictness levels

func SaveConfig

func SaveConfig(config *Config, path string) error

SaveConfig saves configuration to a YAML file

Types

type AnalysisConfig

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

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

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

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

AnalysisConfig holds general analysis configuration

type ArchitectureConfig

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

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

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

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

	// Violation severity levels
	LayerViolationSeverity          string `json:"layer_violation_severity" mapstructure:"layer_violation_severity" yaml:"layer_violation_severity"`
	CohesionViolationSeverity       string `json:"cohesion_violation_severity" mapstructure:"cohesion_violation_severity" yaml:"cohesion_violation_severity"`
	ResponsibilityViolationSeverity string `` /* 130-byte string literal not displayed */

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

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

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

ArchitectureConfig holds configuration for architecture validation

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"`

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

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 ComplexityConfig

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

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

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

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

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

ComplexityConfig holds configuration for cyclomatic complexity analysis

func (*ComplexityConfig) AssessRiskLevel

func (c *ComplexityConfig) AssessRiskLevel(complexity int) string

AssessRiskLevel determines risk level based on complexity and 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 Config

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

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

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

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

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

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

	// ModuleAnalysis holds module analysis configuration
	ModuleAnalysis ModuleAnalysisConfig `json:"module_analysis,omitempty" mapstructure:"module_analysis" yaml:"module_analysis"`

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

	// Analysis holds general analysis configuration
	Analysis AnalysisConfig `json:"analysis,omitempty" 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

func LoadConfigWithTarget

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

LoadConfigWithTarget loads configuration with target path context Orchestrates discovery and loading but delegates specific concerns

func LoadDefaultConfig

func LoadDefaultConfig() (*Config, error)

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

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration values

type DeadCodeConfig

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

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

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

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

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

	// Detection options
	DetectAfterReturn         bool `json:"detect_after_return" mapstructure:"detect_after_return" yaml:"detect_after_return"`
	DetectAfterBreak          bool `json:"detect_after_break" mapstructure:"detect_after_break" yaml:"detect_after_break"`
	DetectAfterContinue       bool `json:"detect_after_continue" mapstructure:"detect_after_continue" yaml:"detect_after_continue"`
	DetectAfterThrow          bool `json:"detect_after_throw" mapstructure:"detect_after_throw" yaml:"detect_after_throw"`
	DetectUnreachableBranches bool `json:"detect_unreachable_branches" mapstructure:"detect_unreachable_branches" yaml:"detect_unreachable_branches"`

	// IgnorePatterns specifies patterns for code to ignore (e.g., comments, debug code)
	IgnorePatterns []string `json:"ignore_patterns" 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 DependencyAnalysisConfig

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

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

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

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

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

	// Cycle analysis
	CycleReporting  string `json:"cycle_reporting" mapstructure:"cycle_reporting" yaml:"cycle_reporting"` // all, critical, summary
	MaxCyclesToShow int    `json:"max_cycles_to_show" mapstructure:"max_cycles_to_show" yaml:"max_cycles_to_show"`
	ShowCyclePaths  bool   `json:"show_cycle_paths" 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   `json:"name" mapstructure:"name" yaml:"name"`
	Packages    []string `json:"packages" mapstructure:"packages" yaml:"packages"`
	Description string   `json:"description" mapstructure:"description" yaml:"description"`
	IsAbstract  bool     `json:"is_abstract" mapstructure:"is_abstract" yaml:"is_abstract"`
}

LayerDefinition defines an architectural layer

type LayerRule

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

LayerRule defines dependency rules between layers

type ModuleAnalysisConfig

type ModuleAnalysisConfig struct {
	// Enabled controls whether module analysis is performed
	Enabled bool `json:"enabled" mapstructure:"enabled" yaml:"enabled"`

	// IncludeBuiltins includes Node.js builtin modules in analysis
	IncludeBuiltins bool `json:"include_builtins" mapstructure:"include_builtins" yaml:"include_builtins"`

	// ResolveRelative enables resolution of relative import paths
	ResolveRelative bool `json:"resolve_relative" mapstructure:"resolve_relative" yaml:"resolve_relative"`

	// IncludeTypeImports includes TypeScript type imports
	IncludeTypeImports bool `json:"include_type_imports" mapstructure:"include_type_imports" yaml:"include_type_imports"`

	// AliasPatterns are path alias patterns to recognize (@/, ~/, etc.)
	AliasPatterns []string `json:"alias_patterns" mapstructure:"alias_patterns" yaml:"alias_patterns"`
}

ModuleAnalysisConfig holds configuration for module import/export analysis

type OutputConfig

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

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

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

	// MinComplexity is the minimum complexity to report (filters low values)
	MinComplexity int `json:"min_complexity" 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 `json:"directory" mapstructure:"directory" yaml:"directory"`
}

OutputConfig holds configuration for output formatting

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 ProjectPreset

type ProjectPreset struct {
	IncludePatterns []string
	ExcludePatterns []string
}

ProjectPreset holds configuration presets for different project types

type ProjectType

type ProjectType string

ProjectType represents the type of JavaScript/TypeScript project

const (
	ProjectTypeGeneric     ProjectType = "generic"
	ProjectTypeReact       ProjectType = "react"
	ProjectTypeVue         ProjectType = "vue"
	ProjectTypeNodeBackend ProjectType = "node"
)

type PyscnConfig

type PyscnConfig struct {
	// 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)
	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"`
	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"`
	DeadCodeDetectAfterThrow          *bool    `mapstructure:"dead_code_detect_after_throw" yaml:"dead_code_detect_after_throw" json:"dead_code_detect_after_throw"`
	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"`

	// 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"`

	// 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 */

	// 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"`
}

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

func DefaultPyscnConfig() *PyscnConfig

DefaultPyscnConfig returns a configuration with sensible defaults

func (*PyscnConfig) Validate

func (c *PyscnConfig) Validate() error

Validate checks if the configuration is valid

type Strictness

type Strictness string

Strictness represents the analysis strictness level

const (
	StrictnessRelaxed  Strictness = "relaxed"
	StrictnessStandard Strictness = "standard"
	StrictnessStrict   Strictness = "strict"
)

type StrictnessPreset

type StrictnessPreset struct {
	LowThreshold    int
	MediumThreshold int
	MaxComplexity   int
}

StrictnessPreset holds threshold values for different strictness levels

type SystemAnalysisConfig

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

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

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

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

SystemAnalysisConfig holds configuration for system-level analysis

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

Jump to

Keyboard shortcuts

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