apicheck

package
v1.18.2 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: BSD-3-Clause Imports: 13 Imported by: 0 modules, 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 apicheck implements the `glutter-gen apicheck` subcommand, which reads the public packages and reports what breaks the API conventions of SPEC §12.

Flutter: no counterpart.

Index

Constants

View Source
const (
	// RuleCtorShape says that an exported NewX takes its optional parameters in a trailing
	// variadic options value (SPEC §12.1).
	RuleCtorShape = "ctor-shape"
	// RuleCtorOrder says that child, children, sliver and slivers come last among the
	// positional parameters (SPEC §12.2).
	RuleCtorOrder = "ctor-order"
	// RuleCtorSize says that a constructor has at most six required parameters (SPEC §12.1).
	RuleCtorSize = "ctor-size"
	// RuleDocRef says that the doc comment of a constructor, a function or a type ends with
	// a "Flutter:", "Glutter-specific:" or "flutter_svg:" paragraph (the last one is the reference
	// of package svg, which ports the flutter_svg package, SPEC §26).
	RuleDocRef = "doc-ref"
	// RuleEnumZero says that the zero value of an enum is <Enum>Unspecified (SPEC §12.3).
	RuleEnumZero = "enum-zero"
	// RuleMutableVar says that no exported package variable exists, as it could be
	// reassigned (CLAUDE.md, "No global mutable state").
	RuleMutableVar = "mutable-var"
	// RuleSDLName says that no identifier of the module, in a public package or an internal one, uses SDL's names: no SDL_
	// prefix, no name that starts with SDL and no Sdl inside a name (SPEC §28.1, D32; the owner's rule of 2026-11-05).
	RuleSDLName = "sdl-name"
)

The rules, as they are named in a report and in an allow file.

Variables

View Source
var DefaultPackages = []string{
	"foundation", "scheduler", "animation", "physics", "gestures", "painting", "rendering",
	"semantics", "services", "widgets", "material", "cupertino", "ui", "desktop", "gluttertest", "svg", "gpu", "vecmath", "viewport3d", "gamepad",
}

DefaultPackages are the public packages of the module, as directories below its root.

Flutter: no counterpart.

Functions

func ReadAllow

func ReadAllow(path string) (map[string]bool, error)

ReadAllow reads an allow file: each line is "rule pkg.Name", optionally followed by "# why". Blank lines and lines that start with # are skipped.

Flutter: no counterpart.

func Run

func Run(args []string) error

Run is the subcommand. It prints the violations that the allow file does not list and fails with ApiCheckViolations when there are some.

Flutter: no counterpart.

Types

type Violation

type Violation struct {
	// Rule is one of the Rule constants.
	Rule string
	// Pkg is the directory of the package below the root, such as "widgets".
	Pkg string
	// Name is the identifier, such as "NewPadding".
	Name string
	// File and Line are where the identifier is declared.
	File string
	Line int
	// Message says what is wrong.
	Message string
}

Violation is one place where the API breaks a rule.

Flutter: no counterpart.

func CheckDir

func CheckDir(root, pkg string) ([]Violation, error)

CheckDir reads the Go files of root/pkg (not the tests) and returns the violations, in the order of their files and lines.

Flutter: no counterpart.

func CheckNames

func CheckNames(root string) ([]Violation, error)

CheckNames reads every Go file of the module below root, tests included, and reports the identifiers that use SDL's names (RuleSDLName). The code that is ported from SDL 3 says so in its comments and in its strings, which this does not look at: only the names of Go identifiers count.

Flutter: no counterpart.

func (Violation) Key

func (v Violation) Key() string

Key is how an allow file names the violation: "rule pkg.Name".

Flutter: no counterpart.

func (Violation) String

func (v Violation) String() string

String is the line of the report.

Flutter: no counterpart.

Jump to

Keyboard shortcuts

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