//go:build ignore

package main

import (
	"fmt"
	"time"

	"github.com/yourorg/devour/internal/quality"
)

func main() {
	// Create sample quality state with some findings
	state := &quality.State{
		Findings: []quality.Finding{
			{
				ID:          "complexity-1",
				Type:        "complexity",
				Title:       "High cyclomatic complexity",
				Description: "Function has too many nested loops and conditionals",
				File:        "src/main.go",
				Line:        42,
				Severity:    quality.SeverityT3,
				Score:       15,
				Status:      quality.StatusOpen,
				CreatedAt:   time.Now().Add(-2 * time.Hour),
				UpdatedAt:   time.Now().Add(-2 * time.Hour),
			},
			{
				ID:          "naming-1",
				Type:        "naming",
				Title:       "Inconsistent naming convention",
				Description: "Variable name doesn't follow project conventions",
				File:        "src/utils.go",
				Line:        15,
				Severity:    quality.SeverityT2,
				Score:       8,
				Status:      quality.StatusOpen,
				CreatedAt:   time.Now().Add(-1 * time.Hour),
				UpdatedAt:   time.Now().Add(-1 * time.Hour),
			},
			{
				ID:          "duplication-1",
				Type:        "duplication",
				Title:       "Code duplication detected",
				Description: "Similar code blocks found in multiple files",
				File:        "src/helper.go",
				Line:        78,
				Severity:    quality.SeverityT2,
				Score:       10,
				Status:      quality.StatusOpen,
				CreatedAt:   time.Now().Add(-30 * time.Minute),
				UpdatedAt:   time.Now().Add(-30 * time.Minute),
			},
			{
				ID:          "security-1",
				Type:        "security",
				Title:       "Potential security vulnerability",
				Description: "SQL injection possibility detected",
				File:        "src/database.go",
				Line:        120,
				Severity:    quality.SeverityT4,
				Score:       25,
				Status:      quality.StatusOpen,
				CreatedAt:   time.Now().Add(-4 * time.Hour),
				UpdatedAt:   time.Now().Add(-4 * time.Hour),
			},
			{
				ID:          "unused_import-1",
				Type:        "unused_import",
				Title:       "Unused import detected",
				Description: "Import statement is not used in the file",
				File:        "src/types.go",
				Line:        5,
				Severity:    quality.SeverityT1,
				Score:       3,
				Status:      quality.StatusOpen,
				CreatedAt:   time.Now().Add(-15 * time.Minute),
				UpdatedAt:   time.Now().Add(-15 * time.Minute),
			},
		},
		LastScan: time.Now(),
		Scorecard: &quality.Scorecard{
			TotalScore:  72,
			StrictScore: 68,
			FindingsByType: map[string]int{
				"complexity":    1,
				"naming":        1,
				"duplication":   1,
				"security":      1,
				"unused_import": 1,
			},
			FindingsByTier: map[quality.Severity]int{
				quality.SeverityT1: 1,
				quality.SeverityT2: 2,
				quality.SeverityT3: 1,
				quality.SeverityT4: 1,
			},
		},
	}

	// Generate scorecard data
	scoreData := scorecard.FromQualityState(state, "Devour Demo", "1.0.0")

	// Generate different types of scorecards
	fmt.Println("Generating sample scorecards...")

	// Generate standard badge
	if err := scorecard.Generate(scoreData, "scorecard_badge.png"); err != nil {
		fmt.Printf("Error generating badge: %v\n", err)
	} else {
		fmt.Println("✓ Generated scorecard_badge.png")
	}

	// Generate compact scorecard
	if err := scorecard.GenerateCompact(scoreData, "scorecard_compact.png"); err != nil {
		fmt.Printf("Error generating compact: %v\n", err)
	} else {
		fmt.Println("✓ Generated scorecard_compact.png")
	}

	// Generate detailed scorecard
	if err := scorecard.GenerateDetailed(scoreData, "scorecard_detailed.png"); err != nil {
		fmt.Printf("Error generating detailed: %v\n", err)
	} else {
		fmt.Println("✓ Generated scorecard_detailed.png")
	}

	// Generate dark theme versions
	if err := scorecard.GenerateDark(scoreData, "scorecard_badge_dark.png"); err != nil {
		fmt.Printf("Error generating dark badge: %v\n", err)
	} else {
		fmt.Println("✓ Generated scorecard_badge_dark.png")
	}

	if err := scorecard.GenerateCompactDark(scoreData, "scorecard_compact_dark.png"); err != nil {
		fmt.Printf("Error generating dark compact: %v\n", err)
	} else {
		fmt.Println("✓ Generated scorecard_compact_dark.png")
	}

	if err := scorecard.GenerateDetailedDark(scoreData, "scorecard_detailed_dark.png"); err != nil {
		fmt.Printf("Error generating dark detailed: %v\n", err)
	} else {
		fmt.Println("✓ Generated scorecard_detailed_dark.png")
	}

	fmt.Println("\nScorecard generation complete!")
	fmt.Printf("Project: %s\n", scoreData.ProjectName)
	fmt.Printf("Version: %s\n", scoreData.Version)
	fmt.Printf("Overall Score: %.1f\n", scoreData.OverallScore)
	fmt.Printf("Strict Score: %.1f\n", scoreData.StrictScore)
	fmt.Printf("Grade: %s\n", scoreData.Grade)
	fmt.Printf("Total Findings: %d\n", scoreData.FindingsTotal)
	fmt.Printf("Open Findings: %d\n", scoreData.FindingsOpen)
}
