Documentation
¶
Overview ¶
Package quality provides the command to run code quality checks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var QualityCmd = &cobra.Command{ Use: "quality [paths...]", Example: ` contextvibes product quality --mode essential # Run basic checks (default) contextvibes product quality --mode strict # Run all checks contextvibes product quality --mode security # Run security checks only contextvibes product quality --mode complexity # Run complexity checks only contextvibes product quality --mode style # Run style checks only`, Args: cobra.ArbitraryArgs, SilenceUsage: true, SilenceErrors: true, RunE: func(cmd *cobra.Command, args []string) error { presenter := ui.NewPresenter(cmd.OutOrStdout(), cmd.ErrOrStderr()) ctx := cmd.Context() knownModes := map[string]bool{ "essential": true, "strict": true, "security": true, "complexity": true, "style": true, } for _, arg := range args { if knownModes[arg] { presenter.Error("'%s' is a mode, not a path.", arg) presenter.Advice("Did you mean to use the flag? --mode %s", arg) return fmt.Errorf("invalid argument '%s'", arg) } } presenter.Summary("Running Code Quality Pipeline") cwd, err := os.Getwd() if err != nil { return fmt.Errorf("failed to get working directory: %w", err) } projType, err := project.Detect(cwd) if err != nil { return fmt.Errorf("failed to detect project type: %w", err) } presenter.Info("Detected project type: %s", presenter.Highlight(string(projType))) presenter.Info("Mode: %s", presenter.Highlight(qualityMode)) if len(args) > 0 { presenter.Info("Targeting paths: %v", args) } presenter.Newline() runner := pipeline.NewRunner(presenter, globals.ExecClient) var checks []pipeline.Check switch projType { case project.Go: switch qualityMode { case "security": checks = append(checks, &pipeline.GolangCILintCheck{Paths: args, ConfigType: config.AssetLintSecurity}, &pipeline.GoVulnCheck{Paths: args}, &pipeline.GitleaksCheck{}, ) case "complexity": checks = append(checks, &pipeline.GolangCILintCheck{Paths: args, ConfigType: config.AssetLintComplexity}, ) case "style": checks = append(checks, &pipeline.GolangCILintCheck{Paths: args, ConfigType: config.AssetLintStyle}, ) case "strict": checks = append(checks, &pipeline.GoVetCheck{Paths: args}, &pipeline.GolangCILintCheck{Paths: args, ConfigType: config.AssetLintStrict}, &pipeline.GoVulnCheck{Paths: args}, &pipeline.GitleaksCheck{}, &pipeline.DeadcodeCheck{}, ) case "essential": fallthrough default: checks = append(checks, &pipeline.GoVetCheck{Paths: args}, &pipeline.GolangCILintCheck{Paths: args, ConfigType: ""}, &pipeline.GoVulnCheck{Paths: args}, ) } case project.Terraform, project.Pulumi, project.Python, project.Unknown: fallthrough default: presenter.Info("No specific quality checks configured for %s.", projType) return nil } results, err := runner.Run(ctx, checks) if err != nil || hasWarnings(results) { if genErr := generateContextFile(results); genErr != nil { presenter.Error("Failed to generate context file: %v", genErr) } else { presenter.Newline() presenter.Info("Generated AI Context: %s", contextFile) presenter.Advice("Pass this file to your AI to fix the issues.") } } else { if _, err := os.Stat(contextFile); err == nil { if removeErr := os.Remove(contextFile); removeErr == nil { presenter.Info("Removed stale AI Context file: %s (all checks passed)", contextFile) } } } if err != nil { presenter.Error("Pipeline failed.") return err } presenter.Success("All quality checks passed.") return nil }, }
QualityCmd represents the quality command.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.