quality

package
v0.7.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: MIT Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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",
	Example:       `  contextvibes product quality`,
	Args:          cobra.NoArgs,
	SilenceUsage:  true,
	SilenceErrors: true,
	RunE: func(cmd *cobra.Command, _ []string) error {
		presenter := ui.NewPresenter(cmd.OutOrStdout(), cmd.ErrOrStderr())
		ctx := cmd.Context()

		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.Newline()

		runner := pipeline.NewRunner(presenter, globals.ExecClient)
		var checks []pipeline.Check

		switch projType {
		case project.Go:
			checks = []pipeline.Check{
				&pipeline.GoModTidyCheck{},
				&pipeline.GoVetCheck{},
				&pipeline.GolangCILintCheck{},
				&pipeline.GoVulnCheck{},
				&pipeline.GitleaksCheck{},
				&pipeline.DeadcodeCheck{},
			}
		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.

Jump to

Keyboard shortcuts

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