Documentation ¶
Index ¶
- type BreakComments
- type ConstsValidator
- type FileSection
- type FileSectionMachine
- type FileSectionTransition
- type FuncsValidator
- type ImportsSection
- type ImportsSectionMachine
- type ImportsTransition
- type ImportsValidator
- type MethodsValidator
- type Nitpicker
- type TypesFound
- type TypesValidator
- type VarsValidator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BreakComments ¶ added in v0.2.0
type BreakComments struct {
// contains filtered or unexported fields
}
BreakComments defines all the found break-like comments in the file.
func NewBreakComments ¶ added in v0.2.0
func NewBreakComments(fset *token.FileSet, comments []*ast.CommentGroup) *BreakComments
NewBreakComments returns all the valid break-like comments.
func (*BreakComments) HasGeneratedCode ¶ added in v0.4.0
func (c *BreakComments) HasGeneratedCode() bool
HasGeneratedCode indicates whether the current file contains a "code generated expression".
func (*BreakComments) MoveTo ¶ added in v0.2.0
func (c *BreakComments) MoveTo(line int)
Moves current line cursor to the received line.
func (*BreakComments) Next ¶ added in v0.2.0
func (c *BreakComments) Next() int
Returns the next break line if any, when no more left it returns -1.
type ConstsValidator ¶ added in v0.1.3
type ConstsValidator struct {
// contains filtered or unexported fields
}
ConstsValidator defines the type including the rules used for validating the `const` sections.
type FileSection ¶ added in v0.3.0
type FileSection uint8
FileSection represents a code section.
const ( // FileSectionImports defines the `imports` state. FileSectionImports FileSection = iota // FIXME kill // FileSectionTypes defines the `type` state. FileSectionTypes // FileSectionConsts defines the `const` state. FileSectionConsts // FileSectionVars defines the `var` state. FileSectionVars // FileSectionFuncs defines the `func` state. FileSectionFuncs // SectionMethods defines the `method` state. FileSectionMethods )
func NewFuncDeclFileSection ¶ added in v0.3.0
func NewFuncDeclFileSection(decl *ast.FuncDecl) (FileSection, error)
NewFuncDeclFileSection returns a new State that matches the decl type.
func NewGenDeclFileSection ¶ added in v0.3.0
func NewGenDeclFileSection(decl *ast.GenDecl) (FileSection, error)
NewGenDeclFileSection returns a new State that matches the decl type.
type FileSectionMachine ¶ added in v0.3.0
type FileSectionMachine struct {
// contains filtered or unexported fields
}
FileSectionMachine represents the state machine determining the right order for the sections in file.
func NewFileSectionMachine ¶ added in v0.3.0
func NewFileSectionMachine(start FileSection) (*FileSectionMachine, error)
NewFileSectionTransition returns a new transition corresponding to the received value.
func (*FileSectionMachine) Transition ¶ added in v0.3.0
func (v *FileSectionMachine) Transition(next FileSection) error
Transition updates the internal state.
type FileSectionTransition ¶ added in v0.3.0
type FileSectionTransition interface { Imports() (FileSectionTransition, error) Types() (FileSectionTransition, error) Consts() (FileSectionTransition, error) Vars() (FileSectionTransition, error) Funcs() (FileSectionTransition, error) Methods() (FileSectionTransition, error) }
FileSectionTransition represents one of the 6 valid sections in the current file, it defines the State Machine transition rules for that concrete section, the order to be expected is:
"Imports" -> "Types" -> "Consts" -> "Vars" -> "Funcs" -> "Methods"
func NewFileSectionTransition ¶ added in v0.3.0
func NewFileSectionTransition(s FileSection) (FileSectionTransition, error)
NewFileSectionTransition returns a new transition corresponding to the received value.
type FuncsValidator ¶ added in v0.2.0
type FuncsValidator struct {
// contains filtered or unexported fields
}
FuncsValidator defines the type including the rules used for validating functions.
func NewFuncsValidator ¶ added in v0.3.0
func NewFuncsValidator(c *BreakComments) *FuncsValidator
NewFuncsValidator returns a correctly initialized FuncsValidator.
func (*FuncsValidator) Validate ¶ added in v0.2.0
Validate makes sure the implemented function satisfies the following rules considering all previous declared functions: * Sorted exported functions are declared first, * Sorted unexported functions are declared next, and * Both groups can declare their own sorted subgroups,
type ImportsSection ¶
type ImportsSection uint8
ImportsSection represents one of the 3 valid `imports` sections.
const ( // ImportsSectionStd represents the Standard Library Packages `imports` section. ImportsSectionStd ImportsSection = iota // ImportsSectionExternal represents the External Packages `imports` section. ImportsSectionExternal // ImportsSectionLocal represents the local Packages `imports` section. ImportsSectionLocal )
func NewImportsSection ¶
func NewImportsSection(path, localPathPrefix string) ImportsSection
NewImportsSection returns the value representing the corresponding Imports section.
type ImportsSectionMachine ¶
type ImportsSectionMachine struct {
// contains filtered or unexported fields
}
ImportsSectionMachine represents the `imports` code organization state machine.
func NewImportsSectionMachine ¶
func NewImportsSectionMachine(start ImportsSection) (*ImportsSectionMachine, error)
NewImportsSectionMachine returns a new ImportsSectionMachine with the initial state as `start`.
func (*ImportsSectionMachine) Current ¶
func (s *ImportsSectionMachine) Current() ImportsTransition
Current returns the current state.
func (*ImportsSectionMachine) Previous ¶
func (s *ImportsSectionMachine) Previous() ImportsTransition
Previous returns the previous state.
func (*ImportsSectionMachine) Transition ¶
func (s *ImportsSectionMachine) Transition(next ImportsSection) error
Transition updates the internal state.
type ImportsTransition ¶ added in v0.3.0
type ImportsTransition interface { External() (ImportsTransition, error) Local() (ImportsTransition, error) Standard() (ImportsTransition, error) }
ImportsTransition represents one of the 3 valid `imports` sections, it defines the State Machine transition rules for that concrete section, the order to be expected is: "Standard" -> "External" -> "Local".
func NewImportsTransition ¶ added in v0.3.0
func NewImportsTransition(s ImportsSection) (ImportsTransition, error)
NewImportsTransition returns a new transition corresponding to the received value.
type ImportsValidator ¶
type ImportsValidator struct {
// contains filtered or unexported fields
}
ImportsValidator defines the type including the rules used for validating the `imports` section as a whole.
func NewImportsValidator ¶ added in v0.3.0
func NewImportsValidator(localPath string) ImportsValidator
NewImportsValidator returns a new instalce of ImporstValidator with the local path prefix set.
type MethodsValidator ¶ added in v0.3.0
type MethodsValidator struct {
// contains filtered or unexported fields
}
MethodsValidator defines the type including the rules used for validating methods.
func NewMethodsValidator ¶ added in v0.3.0
func NewMethodsValidator(c *BreakComments, t TypesFound) (*MethodsValidator, error)
NewMethodsValidator returns a correctly initialized MethodsValidator.
func (*MethodsValidator) Validate ¶ added in v0.3.0
Validate makes sure the implemented methods satisfies the following rules considering all previous declared methods: * Methods for exported types are declared first, then unexported ones, * Sorted exported methods are declared first, * Sorted unexported methods are declared next, and * Both groups can declare their own sorted subgroups.
type Nitpicker ¶
type Nitpicker struct { LocalPath string SkipGeneratedFile bool // contains filtered or unexported fields }
Nitpicker defines the linter.
type TypesFound ¶ added in v0.3.0
type TypesFound interface {
Types() []string
}
TypesFound defines the type returning the types found in the file.
type TypesValidator ¶ added in v0.1.3
type TypesValidator struct {
// contains filtered or unexported fields
}
TypesValidator defines the type including the rules used for validating the `type` sections.
func NewTypesValidator ¶ added in v0.5.0
func NewTypesValidator(c *BreakComments) *TypesValidator
NewTypesValidator returns a correctly initialized TypesValidator.
func (*TypesValidator) Types ¶ added in v0.3.0
func (tv *TypesValidator) Types() []string
Types returns the names of all found types.
type VarsValidator ¶ added in v0.1.3
type VarsValidator struct {
// contains filtered or unexported fields
}
VarsValidator defines the type including the rules used for validating the `var` sections.