checks

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CIWorkflowCheck added in v0.2.0

type CIWorkflowCheck struct{}

CIWorkflowCheck ensures the repository has at least one workflow in .github/workflows.

func (CIWorkflowCheck) Description added in v0.2.0

func (CIWorkflowCheck) Description() string

func (CIWorkflowCheck) Key added in v0.2.0

func (CIWorkflowCheck) Key() string

func (CIWorkflowCheck) Run added in v0.2.0

func (CIWorkflowCheck) Run(ctx context.Context, root string, opts Options) ([]Finding, error)

type ChangelogCheck

type ChangelogCheck struct{}

ChangelogCheck ensures a project includes a CHANGELOG.md file. A changelog helps consumers understand what changed across versions.

Behavior

  • If CHANGELOG.md exists, no findings are emitted.
  • If missing, a warning is reported with guidance.

func (ChangelogCheck) Description

func (ChangelogCheck) Description() string

Description provides a one-line explanation of this check.

func (ChangelogCheck) Key

func (ChangelogCheck) Key() string

Key returns the unique identifier for this check.

func (ChangelogCheck) Run

func (ChangelogCheck) Run(ctx context.Context, root string, opts Options) ([]Finding, error)

Run performs the changelog validation and optional remediation.

type Check

type Check interface {
	Key() string
	Description() string
	Run(ctx context.Context, root string, opts Options) ([]Finding, error)
}

Check is the interface that all yardstick checks must implement.

Each check:

  • returns a unique Key identifying itself.
  • provides a Description for listing and documentation.
  • implements Run, which performs the check and returns one or more Findings.

Example usage pattern:

type MyCheck struct {}
func (MyCheck) Key() string         { return "mycheck" }
func (MyCheck) Description() string { return "verifies something important" }
func (MyCheck) Run(ctx context.Context, root string, opts Options) ([]Finding, error) {
    // perform validation logic here
    return []Finding{{Check: "mycheck", Level: LevelWarn, Message: "example"}}, nil
}

func All

func All() []Check

All returns the complete list of registered checks.

This registry is how yardstick discovers which checks to execute. Each check implements the Check interface (see types.go), and must be explicitly listed here to be included in the scanning process.

When you create a new check:

  1. Define it in a new file under internal/checks (e.g., mycheck.go).
  2. Implement the Check interface (Key, Description, Run).
  3. Add an instance to the slice below.

Keeping this list explicit helps ensure that all checks are intentionally loaded, rather than automatically discovered, which improves predictability and makes CI output easier to reason about.

type CodeownersCheck added in v0.2.0

type CodeownersCheck struct{}

CodeownersCheck ensures a repository defines ownership rules in CODEOWNERS.

func (CodeownersCheck) Description added in v0.2.0

func (CodeownersCheck) Description() string

func (CodeownersCheck) Key added in v0.2.0

func (CodeownersCheck) Key() string

func (CodeownersCheck) Run added in v0.2.0

func (CodeownersCheck) Run(ctx context.Context, root string, opts Options) ([]Finding, error)

type ContributingCheck added in v0.2.0

type ContributingCheck struct{}

ContributingCheck ensures contribution guidelines are present.

func (ContributingCheck) Description added in v0.2.0

func (ContributingCheck) Description() string

func (ContributingCheck) Key added in v0.2.0

func (ContributingCheck) Key() string

func (ContributingCheck) Run added in v0.2.0

func (ContributingCheck) Run(ctx context.Context, root string, opts Options) ([]Finding, error)

type Finding

type Finding struct {
	// Check is the unique key of the check that produced this finding.
	Check string `json:"check"`

	// Level indicates how severe the finding is (info, warn, or error).
	Level Level `json:"level"`

	// Path points to the file or directory the finding concerns.
	// For project-wide findings, this may be the repository root path.
	Path string `json:"path"`

	// Message provides a short human-readable description of the issue.
	Message string `json:"message"`

	// Fixed is true if the issue was automatically corrected when --fix was used.
	Fixed bool `json:"fixed"`
}

Finding describes the result of a single check. It represents one piece of evidence found by a rule execution.

type GitIgnoreCheck

type GitIgnoreCheck struct{}

GitIgnoreCheck ensures a repository has a .gitignore file with a reasonable starter set of entries. This avoids committing build artifacts, editor settings, and OS files.

Behavior

  • If .gitignore exists, no findings are emitted.
  • If missing, a warning is reported with guidance.

func (GitIgnoreCheck) Description

func (GitIgnoreCheck) Description() string

Description provides a short explanation of what this check validates.

func (GitIgnoreCheck) Key

func (GitIgnoreCheck) Key() string

Key returns the unique identifier for this check.

func (GitIgnoreCheck) Run

func (GitIgnoreCheck) Run(ctx context.Context, root string, opts Options) ([]Finding, error)

Run executes the .gitignore validation.

type Guidance added in v0.3.0

type Guidance struct {
	WhyImportant string
	HowToResolve string
}

Guidance captures why a check matters and how to resolve failures.

func GuidanceForCheck added in v0.3.0

func GuidanceForCheck(key string) (Guidance, bool)

GuidanceForCheck returns guidance for a check key.

type JavaScriptFrameworkCheck added in v0.4.0

type JavaScriptFrameworkCheck struct{}

JavaScriptFrameworkCheck validates baseline structure for JavaScript framework projects. It applies broad checks for framework projects and adds Next.js-specific compatibility checks.

func (JavaScriptFrameworkCheck) Description added in v0.4.0

func (JavaScriptFrameworkCheck) Description() string

func (JavaScriptFrameworkCheck) Key added in v0.4.0

func (JavaScriptFrameworkCheck) Run added in v0.4.0

type Level

type Level string

Level represents the severity level of a finding. Each check can report results at different levels depending on importance. - info: informational, no action required. - warn: something is suboptimal but not a failure. - error: policy violation or missing critical element.

const (
	LevelInfo  Level = "info"
	LevelWarn  Level = "warn"
	LevelError Level = "error"
)

Common severity constants used across all checks. Adding a new Level requires updating reports and tests accordingly.

type LicenseCheck

type LicenseCheck struct{}

LicenseCheck ensures that a LICENSE file is present in the repository.

Licensing clarity is essential for both internal and external code sharing. This check verifies that a LICENSE file exists. Yardstick is read-only and does not create files; it provides guidance when the license is missing.

func (LicenseCheck) Description

func (LicenseCheck) Description() string

Description provides a short explanation of what this check validates.

func (LicenseCheck) Key

func (LicenseCheck) Key() string

Key returns the unique identifier for this check.

func (LicenseCheck) Run

func (LicenseCheck) Run(ctx context.Context, root string, opts Options) ([]Finding, error)

Run executes the license file validation.

Behavior:

  • If LICENSE exists, no findings are produced.
  • If missing, a warning is emitted.
  • If --fix is used, a default MIT license is created.

type ManifestCheck

type ManifestCheck struct{}

ManifestCheck attempts to detect a project's primary ecosystem by looking for common manifest files. It is intentionally neutral so yardstick can be used across Go, Node, Python, Ruby, Rust, and static site projects.

Behavior

  • If a known manifest is found, emit an info finding stating which ecosystem was detected and which file triggered it.
  • If no known manifests are found, emit a warn finding suggesting the user add an appropriate manifest for their stack.
  • This check does not auto-create manifests, since that choice is project specific and harder to do safely.

Extending detection

  • Add new entries to the candidates slice with the filename and a short label. Keep the check simple and fast.
  • If needed later, we can add per-ecosystem subchecks, for example NodeLockfileCheck, PythonVenvCheck, etc.

Examples of files detected

  • Go: go.mod
  • Node: package.json
  • Python: pyproject.toml or requirements.txt
  • Ruby: Gemfile
  • Rust: Cargo.toml
  • PHP: composer.json
  • Static: _config.yml, .eleventy.js, mkdocs.yml
  • Docs only: README.md without a manifest will still pass other checks but this one will warn.

func (ManifestCheck) Description

func (ManifestCheck) Description() string

Description provides a short explanation of what this check validates.

func (ManifestCheck) Key

func (ManifestCheck) Key() string

Key returns the unique identifier for this check.

func (ManifestCheck) Run

func (ManifestCheck) Run(ctx context.Context, root string, opts Options) ([]Finding, error)

Run performs the manifest detection logic.

type Options

type Options struct {
	// AutoFix is reserved for potential future use. Yardstick is read-only
	// and does not write; checks must not modify files regardless of this flag.
	AutoFix bool
}

Options contains runtime flags passed into each check. Used to control whether a check should attempt auto-remediation.

type PythonProjectCheck added in v0.4.0

type PythonProjectCheck struct{}

PythonProjectCheck validates baseline conventions for Python projects.

func (PythonProjectCheck) Description added in v0.4.0

func (PythonProjectCheck) Description() string

func (PythonProjectCheck) Key added in v0.4.0

func (PythonProjectCheck) Key() string

func (PythonProjectCheck) Run added in v0.4.0

func (PythonProjectCheck) Run(ctx context.Context, root string, opts Options) ([]Finding, error)

type ReadmeCheck

type ReadmeCheck struct{}

ReadmeCheck verifies that a project contains a README.md file and that it includes key sections for documentation consistency.

This check encourages projects to maintain minimal structure for clarity when others view the repository, ensuring discoverability and maintainability.

func (ReadmeCheck) Description

func (ReadmeCheck) Description() string

Description provides a one-line explanation of what this check does.

func (ReadmeCheck) Key

func (ReadmeCheck) Key() string

Key returns the unique identifier for this check.

func (ReadmeCheck) Run

func (ReadmeCheck) Run(ctx context.Context, root string, opts Options) ([]Finding, error)

Run executes the README validation logic.

Behavior:

  • If README.md is missing, a warning with guidance is reported.
  • If present, it verifies required sections exist.
  • Missing sections are reported as warnings.

type ReadmeLinksCheck added in v0.2.0

type ReadmeLinksCheck struct{}

ReadmeLinksCheck validates local links in README.md.

func (ReadmeLinksCheck) Description added in v0.2.0

func (ReadmeLinksCheck) Description() string

func (ReadmeLinksCheck) Key added in v0.2.0

func (ReadmeLinksCheck) Key() string

func (ReadmeLinksCheck) Run added in v0.2.0

func (ReadmeLinksCheck) Run(ctx context.Context, root string, opts Options) ([]Finding, error)

type SecurityPolicyCheck added in v0.2.0

type SecurityPolicyCheck struct{}

SecurityPolicyCheck ensures a repository provides a vulnerability disclosure policy.

func (SecurityPolicyCheck) Description added in v0.2.0

func (SecurityPolicyCheck) Description() string

func (SecurityPolicyCheck) Key added in v0.2.0

func (SecurityPolicyCheck) Run added in v0.2.0

func (SecurityPolicyCheck) Run(ctx context.Context, root string, opts Options) ([]Finding, error)

type StaticSiteCheck

type StaticSiteCheck struct{}

StaticSiteCheck validates minimal structure for static-site projects. Currently focuses on Jekyll-style repos (detected via _config.yml). If no static-site config is detected, this check is a no-op.

func (StaticSiteCheck) Description

func (StaticSiteCheck) Description() string

func (StaticSiteCheck) Key

func (StaticSiteCheck) Key() string

func (StaticSiteCheck) Run

func (StaticSiteCheck) Run(ctx context.Context, root string, opts Options) ([]Finding, error)

Jump to

Keyboard shortcuts

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