lint

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package lint checks that a codebase follows the inceptools layering rules.

A convention nothing enforces is a convention that decays. These are the rules this framework's shape depends on, each stated with the failure it prevents — because a lint rule whose reason nobody remembers gets disabled the first time it is inconvenient.

Index

Constants

This section is empty.

Variables

View Source
var Rules = []string{
	"service-imports-http",
	"controller-imports-db",
	"dto-imports-db",
	"entity-imports-layer",
	"cross-module-internals",
	"module-has-no-module-file",
	"app-has-no-root-file",
}

Rules are the rule names, so a configuration file can be checked against them rather than silently ignoring a typo.

Functions

This section is empty.

Types

type Finding

type Finding struct {
	Severity Severity
	Rule     string
	Path     string
	Line     int
	Message  string
	// Why explains the failure the rule prevents. Printed with the finding,
	// because "layering violation" teaches nobody anything.
	Why string
}

Finding is one rule violation.

func Run

func Run(opt Options) ([]Finding, error)

Run checks the tree and returns findings, most severe first.

func (Finding) String

func (f Finding) String() string

type Options

type Options struct {
	// Config carries the repository's conventions — which directories are
	// which layer, where the domains live, which rules are on. Loaded from
	// icpt.json; nil means the defaults.
	Config *project.Config
	// Root overrides the configuration's root.
	Root string
	// AppsDir overrides the configuration's domains directory.
	AppsDir string
	// Skip are extra path fragments to ignore.
	Skip []string
}

Options configures a run.

type Severity

type Severity string

Severity of a finding.

const (
	// Error breaks a rule the architecture depends on. Fail the build.
	Error Severity = "error"
	// Warn is a smell: probably wrong, occasionally justified.
	Warn Severity = "warn"
	// Off suppresses a rule. Set it in icpt.json under "rules".
	Off Severity = "off"
)

Jump to

Keyboard shortcuts

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