Documentation
¶
Index ¶
- func FuncCanBeConstructor(n *ast.FuncDecl) bool
- func FuncIsMethod(n *ast.FuncDecl) (*ast.Ident, bool)
- func GetIdent(expr ast.Expr) (*ast.Ident, bool)
- func GetStartingPos(function *ast.FuncDecl) token.Pos
- func NewAdjacentConstructorsNotSortedAlphabetically(structSpec *ast.TypeSpec, constructorNotSorted *ast.FuncDecl, ...) analysis.Diagnostic
- func NewAdjacentStructMethodsNotSortedAlphabetically(structSpec *ast.TypeSpec, method *ast.FuncDecl, otherMethod *ast.FuncDecl) analysis.Diagnostic
- func NewConstructorNotAfterStructType(structSpec *ast.TypeSpec, constructor *ast.FuncDecl) analysis.Diagnostic
- func NewConstructorNotBeforeStructMethod(structSpec *ast.TypeSpec, constructor *ast.FuncDecl, method *ast.FuncDecl) analysis.Diagnostic
- func NewUnexportedMethodBeforeExportedForStruct(structSpec *ast.TypeSpec, privateMethod *ast.FuncDecl, ...) analysis.Diagnostic
- func NodeToBytes(fset *token.FileSet, node ast.Node) ([]byte, error)
- func SplitExportedUnexported(funcDecls []*ast.FuncDecl) (exported, unexported []*ast.FuncDecl)
- type ExportedMethods
- type Feature
- type FileProcessor
- type StructConstructor
- type StructHolder
- type UnexportedMethods
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FuncCanBeConstructor ¶
func GetStartingPos ¶
GetStartingPos returns the token starting position of the function taking into account if there are comments.
func NodeToBytes ¶
NodeToBytes convert the ast.Node in bytes.
Types ¶
type ExportedMethods ¶
type FileProcessor ¶
type FileProcessor struct {
// contains filtered or unexported fields
}
FileProcessor Holder to store all the functions that are potential to be constructors and all the structs.
func NewFileProcessor ¶
func NewFileProcessor(fset *token.FileSet, checkers Feature) *FileProcessor
NewFileProcessor creates a new file processor.
func (*FileProcessor) Analyze ¶
func (fp *FileProcessor) Analyze() []analysis.Diagnostic
Analyze check whether the order of the methods in the constructor is correct.
func (*FileProcessor) NewFileNode ¶
func (fp *FileProcessor) NewFileNode(_ *ast.File)
func (*FileProcessor) NewFuncDecl ¶
func (fp *FileProcessor) NewFuncDecl(n *ast.FuncDecl)
func (*FileProcessor) NewTypeSpec ¶
func (fp *FileProcessor) NewTypeSpec(n *ast.TypeSpec)
type StructConstructor ¶
type StructConstructor struct {
// contains filtered or unexported fields
}
func NewStructConstructor ¶
func NewStructConstructor(funcDec *ast.FuncDecl) (StructConstructor, bool)
func (StructConstructor) GetConstructor ¶
func (sc StructConstructor) GetConstructor() *ast.FuncDecl
func (StructConstructor) GetStructReturn ¶
func (sc StructConstructor) GetStructReturn() *ast.Ident
GetStructReturn Return the struct linked to this "constructor".
type StructHolder ¶
type StructHolder struct {
// The fileset
Fset *token.FileSet
// The features to be analyzed
Features Feature
// The struct declaration
Struct *ast.TypeSpec
// A Struct constructor is considered if starts with `New...` and the 1st output parameter is a struct
Constructors []*ast.FuncDecl
// Struct methods
StructMethods []*ast.FuncDecl
}
StructHolder contains all the information around a Go struct.
func (*StructHolder) AddConstructor ¶
func (sh *StructHolder) AddConstructor(fn *ast.FuncDecl)
func (*StructHolder) AddMethod ¶
func (sh *StructHolder) AddMethod(fn *ast.FuncDecl)
func (*StructHolder) Analyze ¶
func (sh *StructHolder) Analyze() []analysis.Diagnostic
Analyze applies the linter to the struct holder.
type UnexportedMethods ¶
Click to show internal directories.
Click to hide internal directories.