models

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileInfo

type FileInfo struct {
	Path         string    `json:"path"`
	Name         string    `json:"name"`
	Extension    string    `json:"extension"`
	Size         int64     `json:"size"`
	Lines        int       `json:"lines"`
	ModifiedTime time.Time `json:"modified_time"`
	Language     string    `json:"language"`
	Scanned      bool      `json:"scanned"`
	Error        string    `json:"error,omitempty"`
}

FileInfo represents metadata about a scanned file

type FileMetrics

type FileMetrics struct {
	TotalLines      int `json:"total_lines"`
	CodeLines       int `json:"code_lines"`
	CommentLines    int `json:"comment_lines"`
	BlankLines      int `json:"blank_lines"`
	FunctionCount   int `json:"function_count"`
	ClassCount      int `json:"class_count"`
	ComplexityScore int `json:"complexity_score"`
}

FileMetrics contains basic metrics about a file

type FileTreeNode

type FileTreeNode struct {
	Name       string          `json:"name"`
	Path       string          `json:"path"`
	Type       string          `json:"type"` // "file" or "directory"
	Size       int64           `json:"size,omitempty"`
	Violations int             `json:"violations"`
	Children   []*FileTreeNode `json:"children,omitempty"`
	Language   string          `json:"language,omitempty"`
	Scanned    bool            `json:"scanned"`
}

FileTreeNode represents a file tree structure for navigation

type FileViolationSummary

type FileViolationSummary struct {
	File                 string                `json:"file"`
	TotalViolations      int                   `json:"total_violations"`
	ViolationsByType     map[ViolationType]int `json:"violations_by_type"`
	ViolationsBySeverity map[Severity]int      `json:"violations_by_severity"`
	Lines                int                   `json:"lines"`
}

FileViolationSummary summarizes violations for a single file

type HTMLOptions

type HTMLOptions struct {
	AutoRefresh     bool   `json:"auto_refresh"`
	RefreshInterval int    `json:"refresh_interval"`
	Theme           string `json:"theme"`
}

HTMLOptions contains HTML-specific report options

type Location

type Location struct {
	File      string `json:"file"`
	Line      int    `json:"line"`
	Column    int    `json:"column"`
	EndLine   int    `json:"end_line,omitempty"`
	EndColumn int    `json:"end_column,omitempty"`
}

Location represents a position in source code

type Report

type Report struct {
	ID          string        `json:"id"`
	GeneratedAt time.Time     `json:"generated_at"`
	Config      *ReportConfig `json:"config"`
	Summary     *ScanSummary  `json:"summary"`
	Files       []*ScanResult `json:"files"`
	Statistics  *Statistics   `json:"statistics"`
}

Report represents a complete scan report

func NewReport

func NewReport(summary *ScanSummary, files []*ScanResult, config *ReportConfig) *Report

NewReport creates a new report with the given data

func (*Report) BuildFileTree

func (r *Report) BuildFileTree() *FileTreeNode

BuildFileTree creates a hierarchical file tree structure

func (*Report) GetViolationsByFile

func (r *Report) GetViolationsByFile() map[string][]*Violation

GetViolationsByFile returns violations grouped by file

type ReportConfig

type ReportConfig struct {
	Paths        []string     `json:"paths"`
	FileTypes    []string     `json:"file_types"`
	Thresholds   *Thresholds  `json:"thresholds"`
	HTMLSettings *HTMLOptions `json:"html_settings"`
}

ReportConfig contains configuration settings used for this report

type ScanResult

type ScanResult struct {
	File       *FileInfo    `json:"file"`
	Violations []*Violation `json:"violations"`
	Metrics    *FileMetrics `json:"metrics"`
	ASTInfo    interface{}  `json:"ast_info,omitempty"` // Go AST info when available
}

ScanResult represents the result of scanning a single file

type ScanSummary

type ScanSummary struct {
	TotalFiles       int            `json:"total_files"`
	ScannedFiles     int            `json:"scanned_files"`
	SkippedFiles     int            `json:"skipped_files"`
	TotalViolations  int            `json:"total_violations"`
	ViolationsByType map[string]int `json:"violations_by_type"`
	StartTime        time.Time      `json:"start_time"`
	EndTime          time.Time      `json:"end_time"`
	Duration         time.Duration  `json:"duration"`
}

ScanSummary provides an overview of the entire scan operation

type Severity

type Severity int

Severity represents the severity level of a violation

const (
	SeverityInfo Severity = iota
	SeverityLow
	SeverityMedium
	SeverityHigh
	SeverityCritical
)

func (Severity) GetColor

func (s Severity) GetColor() string

GetSeverityColor returns the CSS class for a severity level

func (Severity) String

func (s Severity) String() string

type Statistics

type Statistics struct {
	ViolationsByType     map[ViolationType]int   `json:"violations_by_type"`
	ViolationsBySeverity map[Severity]int        `json:"violations_by_severity"`
	FilesByLanguage      map[string]int          `json:"files_by_language"`
	TopViolatedFiles     []*FileViolationSummary `json:"top_violated_files"`
	ViolationTrends      []*ViolationTrend       `json:"violation_trends"`
}

Statistics provides detailed statistics about violations and files

type Thresholds

type Thresholds struct {
	FunctionLines        int `json:"function_lines"`
	CyclomaticComplexity int `json:"cyclomatic_complexity"`
	Parameters           int `json:"parameters"`
	NestingDepth         int `json:"nesting_depth"`
	ClassLines           int `json:"class_lines"`
}

Thresholds contains the clean code thresholds used for this scan

type Violation

type Violation struct {
	ID          string        `json:"id"`
	Type        ViolationType `json:"type"`
	Severity    Severity      `json:"severity"`
	Message     string        `json:"message"`
	Description string        `json:"description"`
	File        string        `json:"file"`
	Line        int           `json:"line"`
	Column      int           `json:"column"`
	EndLine     int           `json:"end_line,omitempty"`
	EndColumn   int           `json:"end_column,omitempty"`
	Context     string        `json:"context,omitempty"`
	Rule        string        `json:"rule"`
	Suggestion  string        `json:"suggestion,omitempty"`
	CodeSnippet string        `json:"code_snippet,omitempty"`
}

Violation represents a clean code violation found during scanning

type ViolationTrend

type ViolationTrend struct {
	Date  time.Time     `json:"date"`
	Type  ViolationType `json:"type"`
	Count int           `json:"count"`
}

ViolationTrend represents historical trend data (for future use)

type ViolationType

type ViolationType string

ViolationType represents the category of violation

const (
	ViolationTypeFunctionLength       ViolationType = "function_length"
	ViolationTypeCyclomaticComplexity ViolationType = "cyclomatic_complexity"
	ViolationTypeParameterCount       ViolationType = "parameter_count"
	ViolationTypeNestingDepth         ViolationType = "nesting_depth"
	ViolationTypeNaming               ViolationType = "naming_convention"
	ViolationTypeClassSize            ViolationType = "class_size"
	ViolationTypeMissingDocumentation ViolationType = "missing_documentation"
	ViolationTypeMagicNumbers         ViolationType = "magic_numbers"
	ViolationTypeDuplication          ViolationType = "code_duplication"
	ViolationTypeMagicNumber          ViolationType = "magic_number"
	ViolationTypeCommentedCode        ViolationType = "commented_code"
	ViolationTypeTodo                 ViolationType = "todo_marker"
	ViolationTypeDocumentation        ViolationType = "documentation_quality"
)

func (ViolationType) GetDisplayName

func (vt ViolationType) GetDisplayName() string

GetTypeDisplayName returns a human-readable name for violation types

Jump to

Keyboard shortcuts

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