Help us shape the future of Go! Take the 2026 Go Developer Survey

constants

package
v1.3.2 Latest Latest
Warning

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

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

Documentation

Overview

Package constants defines configuration defaults and thresholds.

This package centralizes all magic numbers and default values used throughout the application. By extracting constants to a dedicated package, we improve maintainability and make it easier to understand and modify thresholds.

Threshold Categories

- Analysis thresholds: Default values for file size, function length, complexity - Anti-pattern thresholds: Limits for parameters, nesting, return statements - Coverage settings: Defaults for test coverage analysis - Dependency settings: Limits for imports and external dependencies - Reporting constants: Limits for top-N reports, percentile calculations

Usage

Import and reference constants:

import "github.com/daniel-munoz/code-review-assistant/internal/constants"

if functionLength > constants.DefaultLongFunctionThreshold {
    // Function is too long
}

p95 := calculatePercentile(values, constants.Percentile95)

All constants are exported and can be used throughout the codebase to ensure consistent threshold application.

Index

Constants

View Source
const (
	SectionSeparatorLength = 60 // Length of separator lines in console output
	TableColumnPadding     = 2  // Padding between table columns
	MinColumnWidth         = 10 // Minimum column width for tables
)

Console output formatting constants

View Source
const (
	PercentageMultiplier = 100.0 // Multiplier to convert ratio to percentage
	DecimalPlaces        = 1     // Number of decimal places for percentages
)

Number formatting constants

View Source
const (
	DefaultLargeFileThreshold    = 500  // Lines beyond which a file is considered large
	DefaultLongFunctionThreshold = 50   // Lines beyond which a function is considered long
	DefaultMinCommentRatio       = 0.15 // Minimum recommended comment to code ratio (15%)
	DefaultComplexityThreshold   = 10   // McCabe cyclomatic complexity threshold
)

Default analysis thresholds for Phase 1 (basic metrics)

View Source
const (
	DefaultMaxParameters         = 5 // Maximum recommended function parameters
	DefaultMaxNestingDepth       = 4 // Maximum recommended nesting depth
	DefaultMaxReturnStatements   = 3 // Maximum recommended return statements per function
	DefaultDetectMagicNumbers    = true
	DefaultDetectDuplicateErrors = true
)

Default anti-pattern detection thresholds for Phase 2.2

View Source
const (
	DefaultEnableCoverage       = true
	DefaultMinCoverageThreshold = 50.0 // Minimum test coverage percentage (50%)
	DefaultCoverageTimeout      = 30   // Timeout in seconds for coverage analysis per package
)

Default test coverage settings for Phase 2.3

View Source
const (
	DefaultMaxImports              = 10 // Maximum imports per package before flagging
	DefaultMaxExternalDependencies = 10 // Maximum external dependencies before flagging
	DefaultDetectCircularDeps      = true
)

Default dependency analysis settings for Phase 2.4

View Source
const (
	TopFilesLimit            = 10   // Number of largest files to report
	TopComplexFunctionsLimit = 10   // Number of most complex functions to report
	Percentile95             = 0.95 // 95th percentile for statistical calculations
)

Reporting and calculation constants

View Source
const (
	CoverageRegexCaptureGroup = 2 // Index of the capture group containing coverage percentage
)

Coverage parsing constants

View Source
const (
	MinDuplicateErrorOccurrences = 5 // Minimum occurrences before flagging duplicate errors
)

Duplicate error detection threshold

Variables

View Source
var DefaultExcludePatterns = []string{
	"vendor/**",
	"**/*_test.go",
	"**/testdata/**",
	"**/*.pb.go",
}

Package exclusion patterns

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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