models

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnalyzerTypeStrings

func AnalyzerTypeStrings() []string

AnalyzerTypeStrings returns a slice of all String values of the enum

func IssueTypeStrings

func IssueTypeStrings() []string

IssueTypeStrings returns a slice of all String values of the enum

func SeverityLevelStrings

func SeverityLevelStrings() []string

SeverityLevelStrings returns a slice of all String values of the enum

Types

type AnalyzerType

type AnalyzerType uint8

AnalyzerType represents the type of analyzer

const (
	AnalyzerLoop AnalyzerType = iota
	AnalyzerDeferOptimization
	AnalyzerSlice
	AnalyzerMap
	AnalyzerString
	AnalyzerReflection
	AnalyzerInterface
	AnalyzerRegex
	AnalyzerTime
	AnalyzerMemoryLeak
	AnalyzerGCPressure
	AnalyzerSyncPool
	AnalyzerGoroutine
	AnalyzerChannel
	AnalyzerRaceCondition
	AnalyzerConcurrencyPatterns
	AnalyzerHTTPClient
	AnalyzerHTTPReuse
	AnalyzerIOBuffer
	AnalyzerNetworkPatterns
	AnalyzerDatabase
	AnalyzerSerialization
	AnalyzerCrypto
	AnalyzerPrivacy
	AnalyzerContext
	AnalyzerErrorHandling
	AnalyzerAPIMisuse
	AnalyzerAIBullshit
	AnalyzerCGO
	AnalyzerTestCoverage
	AnalyzerDependency
	AnalyzerCPUOptimization
	AnalyzerTypeMax
)

func AnalyzerTypeString

func AnalyzerTypeString(s string) (AnalyzerType, error)

AnalyzerTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func AnalyzerTypeValues

func AnalyzerTypeValues() []AnalyzerType

AnalyzerTypeValues returns all values of the enum

func (AnalyzerType) IsAAnalyzerType

func (i AnalyzerType) IsAAnalyzerType() bool

IsAAnalyzerType returns "true" if the value is listed in the enum definition. "false" otherwise

func (AnalyzerType) String

func (i AnalyzerType) String() string

type Issue

type Issue struct {
	ID         string         `json:"id,omitempty"`
	File       string         `json:"file,omitempty"`
	Line       int            `json:"line,omitempty"`
	Column     int            `json:"column,omitempty"`
	Position   token.Position `json:"position"`
	Type       IssueType      `json:"type,omitempty"`
	Severity   SeverityLevel  `json:"severity,omitempty"`
	Message    string         `json:"message,omitempty"`
	Suggestion string         `json:"suggestion,omitempty"`
	Code       string         `json:"code,omitempty"`
	CanBeFixed bool           `json:"can_be_fixed,omitempty"`
	FixedAt    time.Time      `json:"fixed_at,omitempty"`
	CreatedAt  time.Time      `json:"created_at,omitempty"`
	UpdatedAt  time.Time      `json:"updated_at,omitempty"`
	IgnoredAt  time.Time      `json:"ignored_at,omitempty"`
	IgnoreType IssueType      `json:"ignore_type,omitempty"`
	WhyBad     string         `json:"why_bad,omitempty"`
}

Issue represents a performance issue found in the code

type IssueType

type IssueType uint16

IssueType represents specific issue types as an enum

const (
	// Loop issues (0-19)
	IssueNestedLoop IssueType = iota
	IssueAllocInLoop
	IssueAppendInLoop
	IssueDeferInLoop
	IssueRegexInLoop
	IssueTimeInLoop
	IssueSQLInLoop
	IssueDNSInLoop
	IssueReflectionInLoop
	IssueCPUIntensiveLoop

	// Memory issues (20-39)
	IssueMemoryLeak IssueType = 20 + iota - 11
	IssueGlobalVar
	IssueLargeAllocation
	IssueHighGCPressure
	IssueFrequentAllocation
	IssueLargeHeapAlloc
	IssuePointerHeavyStruct
	IssueMissingDefer
	IssueMissingClose

	// Slice issues (40-49)
	IssueSliceCapacity IssueType = 40 + iota - 20
	IssueSliceCopy
	IssueSliceAppend
	IssueSliceRangeCopy
	IssueSliceAppendInLoop
	IssueSlicePrealloc

	// Map issues (50-59)
	IssueMapCapacity IssueType = 50 + iota - 26
	IssueMapClear
	IssueMapPrealloc

	// String issues (60-69)
	IssueStringConcat IssueType = 60 + iota - 29
	IssueStringBuilder
	IssueStringInefficient

	// Defer issues (70-79)
	IssueDeferInShortFunc IssueType = 70 + iota - 32
	IssueDeferOverhead
	IssueUnnecessaryDefer
	IssueDeferAtEnd
	IssueMultipleDefers
	IssueDeferInHotPath
	IssueDeferLargeCapture
	IssueUnnecessaryMutexDefer
	IssueMissingDeferUnlock
	IssueMissingDeferClose

	// Concurrency issues (80-109)
	IssueRaceCondition IssueType = 80 + iota - 42
	IssueRaceConditionGlobal
	IssueUnsyncMapAccess
	IssueRaceClosure
	IssueGoroutineLeak
	IssueUnbufferedChannel
	IssueGoroutineOverhead
	IssueSyncMutexValue
	IssueWaitgroupMisuse
	IssueRaceInDefer
	IssueAtomicMisuse
	IssueGoroutineNoRecover
	IssueGoroutineCapturesLoop
	IssueWaitGroupAddInLoop
	IssueWaitGroupWaitBeforeStart
	IssueMutexForReadOnly
	IssueSelectWithSingleCase
	IssueBusyWait
	IssueContextBackgroundInGoroutine
	IssueGoroutinePerRequest
	IssueNoWorkerPool
	IssueUnbufferedSignalChan
	IssueSelectDefault
	IssueChannelSize
	IssueRangeOverChannel
	IssueChannelDeadlock
	IssueChannelMultipleClose
	IssueChannelSendOnClosed

	// Network & HTTP issues (110-129)
	IssueHTTPNoTimeout IssueType = 110 + iota - 59
	IssueHTTPNoClose
	IssueHTTPDefaultClient
	IssueHTTPNoContext
	IssueKeepaliveMissing
	IssueConnectionPool
	IssueNoReuseConnection
	IssueHTTPNoConnectionReuse

	// Database issues (130-139)
	IssueNoPreparedStmt IssueType = 130 + iota - 67
	IssueMissingDBClose
	IssueSQLNPlusOne

	// Interface & Reflection issues (140-149)
	IssueReflection IssueType = 140 + iota - 70
	IssueInterfaceAllocation
	IssueEmptyInterface
	IssueInterfacePollution

	// Time & Regex issues (150-159)
	IssueTimeAfterLeak IssueType = 150 + iota - 74
	IssueTimeFormat
	IssueTimeNowInLoop
	IssueRegexCompile
	IssueRegexCompileInLoop

	// Context issues (160-169)
	IssueContextBackground IssueType = 160 + iota - 79
	IssueContextValue
	IssueMissingContextCancel
	IssueContextLeak
	IssueContextInStruct
	IssueContextNotFirst
	IssueContextMisuse

	// Error handling issues (170-179)
	IssueErrorIgnored IssueType = 170 + iota - 86
	IssueErrorCheckMissing
	IssuePanicRecover
	IssueErrorStringFormat
	IssuePanicRisk
	IssuePanicInLibrary

	// AI Bullshit issues (200-229)
	IssueAIBullshitConcurrency IssueType = 200 + iota - 99
	IssueAIReflectionOverkill
	IssueAIPatternAbuse
	IssueAIEnterpriseHelloWorld
	IssueAICaptainObvious
	IssueAIOverengineeredSimple
	IssueAIGeneratedComment
	IssueAIUnnecessaryComplexity
	IssueAIOverAbstraction
	IssueAIVariable
	IssueAIErrorHandling
	IssueAIStructure
	IssueAIRepetition
	IssueAIFactorySimple
	IssueAIRedundantElse
	IssueAIGoroutineOverkill
	IssueAIUnnecessaryReflection
	IssueAIUnnecessaryInterface

	// GC Pressure issues - continuing from AI issues
	IssueHighGCPressureDetected
	IssueFrequentAllocationDetected
	IssueLargeHeapAllocDetected
	IssuePointerHeavyStructDetected

	// Sync Pool issues
	IssueSyncPoolOpportunity
	IssueSyncPoolPutMissing
	IssueSyncPoolTypeAssert
	IssueSyncPoolMisuse

	// API Misuse issues
	IssueAPIMisuse
	IssueWGMisuse
	IssuePprofInProd
	IssuePprofNilWriter
	IssueDebugInProd
	IssueWaitgroupAddInGoroutine
	IssueContextBackgroundMisuse
	IssueSleepInLoop
	IssueSprintfConcatenation
	IssueLogInHotPath
	IssueRecoverWithoutDefer
	IssueJSONMarshalInLoop
	IssueRegexCompileInFunc
	IssueMutexByValue

	// Privacy issues
	IssuePrivacyHardcodedSecret
	IssuePrivacyAWSKey
	IssuePrivacyJWTToken
	IssuePrivacyEmailPII
	IssuePrivacySSNPII
	IssuePrivacyCreditCardPII
	IssuePrivacyLoggingSensitive
	IssuePrivacyPrintingSensitive
	IssuePrivacyExposedField
	IssuePrivacyUnencryptedDBWrite
	IssuePrivacyDirectInputToDB

	// Dependency issues
	IssueDependencyDeprecated
	IssueDependencyVulnerable
	IssueDependencyOutdated
	IssueDependencyCGO
	IssueDependencyUnsafe
	IssueDependencyInternal
	IssueDependencyIndirect
	IssueDependencyLocalReplace
	IssueDependencyNoChecksum
	IssueDependencyEmptyChecksum
	IssueDependencyVersionConflict

	// Test Coverage issues
	IssueMissingTest
	IssueMissingExample
	IssueMissingBenchmark
	IssueUntestedExport
	IssueUntestedType
	IssueUntestedError
	IssueUntestedConcurrency
	IssueUntestedIOFunction

	// Crypto issues
	IssueWeakCrypto
	IssueInsecureRandom
	IssueWeakHash

	// Serialization issues
	IssueJSONInLoop
	IssueXMLInLoop
	IssueSerializationInLoop

	// IO Buffer issues
	IssueUnbufferedIO
	IssueSmallBuffer
	IssueMissingBuffering

	// Network Pattern issues
	IssueNetworkInLoop
	IssueDNSLookupInLoop
	IssueNoConnectionPool

	// CGO issues
	IssueCGOCall
	IssueCGOInLoop
	IssueCGOMemoryLeak

	// CPU Optimization issues
	IssueCPUIntensive
	IssueUnnecessaryCopy
	IssueBoundsCheckElimination
	IssueInefficientAlgorithm
	IssueCacheUnfriendly
	IssueHighComplexityO2
	IssueHighComplexityO3
	IssuePreventsInlining
	IssueExpensiveOpInHotPath
	IssueModuloPowerOfTwo

	// Misc issues
	IssueMagicNumber
	IssueUselessCondition
	IssueEmptyElse
	IssueSleepInsteadOfSync
	IssueConsoleLogDebugging
	IssueHardcodedConfig
	IssueGlobalVariable
	IssuePointerToSlice

	// Struct Layout issues
	IssueStructLayoutUnoptimized
	IssueStructLargePadding
	IssueStructFieldAlignment

	// CPU Cache optimization issues
	IssueCacheFalseSharing
	IssueCacheLineWaste
	IssueCacheLineAlignment
	IssueOversizedType
	IssueUnspecificIntType
	IssueSoAPattern
	IssueNestedRangeCache
	IssueMapRangeCache

	// Sentinel
	IssueTypeMax
)

func IssueTypeString

func IssueTypeString(s string) (IssueType, error)

IssueTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func IssueTypeValues

func IssueTypeValues() []IssueType

IssueTypeValues returns all values of the enum

func (IssueType) GetAnalyzer

func (i IssueType) GetAnalyzer() AnalyzerType

GetAnalyzer returns the analyzer type that detects this issue

func (IssueType) GetPVEID

func (i IssueType) GetPVEID() string

GetPVEID returns the PVE-ID for this issue type (e.g., PVE-001)

func (IssueType) IsAIssueType

func (i IssueType) IsAIssueType() bool

IsAIssueType returns "true" if the value is listed in the enum definition. "false" otherwise

func (IssueType) Severity

func (i IssueType) Severity() SeverityLevel

func (IssueType) String

func (i IssueType) String() string

type SeverityLevel

type SeverityLevel uint8

SeverityLevel represents the severity of an issue

const (
	SeverityLevelLow    SeverityLevel = iota // 🟢 Low priority issues
	SeverityLevelMedium                      // 🟡 Medium priority issues
	SeverityLevelHigh                        // 🔴 High priority issues
)

func SeverityLevelString

func SeverityLevelString(s string) (SeverityLevel, error)

SeverityLevelString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func SeverityLevelValues

func SeverityLevelValues() []SeverityLevel

SeverityLevelValues returns all values of the enum

func (SeverityLevel) IsASeverityLevel

func (i SeverityLevel) IsASeverityLevel() bool

IsASeverityLevel returns "true" if the value is listed in the enum definition. "false" otherwise

func (SeverityLevel) String

func (i SeverityLevel) String() string

Jump to

Keyboard shortcuts

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