hint

package
v0.0.0-...-0e783f1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2016 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package lint contains a linter for Go source code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCheckstyleReporter

func NewCheckstyleReporter(indent bool) *checkstyleReporter

NewCheckstyleReporter creates initialized Checkstyle report generator

Types

type Config

type Config struct {
	Package            bool `json:"package"`
	Imports            bool `json:"imports"`
	Names              bool `json:"names"`
	Exported           bool `json:"exported"`
	VarDecls           bool `json:"var-decls"`
	Elses              bool `json:"elses"`
	MakeSlice          bool `json:"make-slice"`
	ErrorReturn        bool `json:"error-return"`
	IgnoredReturn      bool `json:"ignored-return"`
	PackageUnderscore  bool `json:"package-underscore"`
	NamedReturn        bool `json:"named-return"`
	PackagePrefixNames bool `json:"package-prefix-names"`
	Ranges             bool `json:"ranges"`
	ReceiverNames      bool `json:"receiver-names"`
	Errorf             bool `json:"errorf"`
	Errors             bool `json:"errors"`
	ErrorStrings       bool `json:"error-strings"`
	IncDec             bool `json:"inc-dec"`

	MinConfidence float64 `json:"min-confidence"`

	IgnoreFiles []string `json:"ignore-files"`

	IgnorePackages []string `json:"ignore-packages"`

	IgnoreTypes []string `json:"ignore-types"`

	Initialisms      map[string]bool `json:"initialisms"`
	BadReceiverNames map[string]bool `json:"bad-receivers"`
	// contains filtered or unexported fields
}

Config defines configuration options for linter

func NewConfig

func NewConfig(file string) (*Config, error)

NewConfig reads config from given file. If filename is empty, default config will be returned

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig creates linter config with predefined options

type Linter

type Linter struct {
}

A Linter lints Go source code.

func (*Linter) Lint

func (l *Linter) Lint(filename string, config *Config, src []byte) ([]Problem, error)

Lint lints src.

type PlainReporter

type PlainReporter struct {
	// contains filtered or unexported fields
}

PlainReporter defines reporter that output problems as plain text

func (*PlainReporter) Collect

func (r *PlainReporter) Collect(ps []Problem)

Collect receives problems for further report generation

func (*PlainReporter) Flush

func (r *PlainReporter) Flush() (report string, err error)

Flush outputs collected problems one by one in plain text Expect no errors here

func (*PlainReporter) NumProblems

func (r *PlainReporter) NumProblems() int

type Problem

type Problem struct {
	File       string         // name of the sourcefile
	Position   token.Position // position in source file
	Text       string         // the prose that describes the problem
	Link       string         // (optional) the link to the style guide for the problem
	Confidence float64        // a value in (0,1] estimating the confidence in this problem's correctness
	LineText   string         // the source line
	Category   string         // a short name for the general category of the problem
}

Problem represents a problem in some source code.

func (*Problem) String

func (p *Problem) String() string

type Reporter

type Reporter interface {
	Collect(problems []Problem)
	Flush() (string, error)
	NumProblems() int
}

Reporter defines interface that should be implemented to generate a report.

Jump to

Keyboard shortcuts

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