rt

package
v0.0.0-...-5dce4d2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2019 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package rt contains the runtime code which will support a generated enforcer binary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Enforcer

type Enforcer struct {
	// If true, we will only consider types to implement an interface
	// if there is an explicit assertion of the form:
	//   var _ Intf = &Impl{}
	AssertedInterfaces bool
	// Contracts contains providers for the various Contract types.
	// This map is the primary point of code-generation.
	Contracts contract.Providers
	// Allows the working directory to be overridden.
	Dir string
	// The name of the generated linter.
	Name string
	// An optional Logger to receive diagnostic messages.
	Logger *log.Logger
	// The package-patterns to enforce contracts upon.
	Packages []string
	// If true, Main() will call os.Exit(1) if any reports are generated.
	SetExitStatus bool
	// If true, the test sources for the package will be included.
	Tests bool
	// contains filtered or unexported fields
}

Enforcer is the main entrypoint for a generated linter binary. The generated code will just configure an instance of Enforcer and call its Main() method.

func (*Enforcer) Execute

func (e *Enforcer) Execute(ctx context.Context) (Results, error)

Execute allows an Enforcer to be called programmatically.

func (*Enforcer) Main

func (e *Enforcer) Main()

Main is called by the generated main() code.

type Result

type Result struct {
	// Nested Results.
	Children Results
	// The position of the contract declaration which caused the Result.
	Contract token.Position
	// The data written by the Contract.
	Data bytes.Buffer
	// The position that the message is associated with.
	Pos token.Position
	// The name of the contract which produced the result.
	Producer string
}

A Result describes a message associated with a position in an input file.

func (Result) String

func (r Result) String() string

String is suitable for human consumption.

func (Result) StringRelative

func (r Result) StringRelative(basePath string) string

StringRelative is suitable for human consumption and makes all emitted file paths relative to the given base path.

type Results

type Results []*Result

Results is a sortable slice of Result.

func (Results) Len

func (r Results) Len() int

Len implements sort.Interface.

func (Results) Less

func (r Results) Less(i, j int) bool

Less implements sort.Interface. It orders results by their filenames, position within the file, producer, and then by data.

func (Results) String

func (r Results) String() string

String is for debugging use only.

func (Results) Swap

func (r Results) Swap(i, j int)

Swap implements sort.Interface.

Jump to

Keyboard shortcuts

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