Documentation
¶
Index ¶
- Variables
- func GetImportPathFromFullPath(path string) string
- func GetOpFromType(spec *ast.TypeSpec, name string) *ast.CallExpr
- func GetPackageNameFromImportPath(importPath string) string
- func IsMethod(expr ast.Decl) bool
- type ArrayTypeRule
- type ArrayTypeRules
- type AssignStmtRule
- type AssignStmtRules
- type BatchError
- type BinaryExprRule
- type BinaryExprRules
- type BlockStmtRule
- type BlockStmtRules
- type Cache
- type CacheOption
- type CallExprRule
- type CallExprRules
- type ChanTypeRule
- type ChanTypeRules
- type CopyRuler
- type ErrorWrap
- type Errors
- type FieldListRule
- type FieldListRules
- type FieldRule
- type FieldRules
- type File
- type FileError
- type FileRule
- type FileRules
- type FileSetOption
- type Filename
- type Files
- type FuncDeclRule
- type FuncDeclRules
- type FuncTypeRule
- type FuncTypeRules
- type GenDeclRule
- type GenDeclRules
- type Helper
- func (h Helper) GetFieldByIndex(index int, spec *ast.TypeSpec) *ast.Field
- func (h Helper) GetFieldByName(fieldName string, spec *ast.TypeSpec) *ast.Field
- func (h Helper) GetStructName(expr ast.Expr) string
- func (h Helper) GetStructType(expr ast.Expr) *ast.StructType
- func (h Helper) GetTypeSpec(expr ast.Expr) *ast.TypeSpec
- func (h Helper) IsStruct(expr ast.Expr) bool
- type IncDecStmtRule
- type IncDecStmtRules
- type InterfaceTypeRule
- type InterfaceTypeRules
- type LineNumber
- type MapTypeRule
- type MapTypeRules
- type OpInfo
- type OpInfos
- type Option
- type Package
- type PackageRule
- type PackageRules
- type Packages
- type RangeStmtRule
- type RangeStmtRules
- type ReturnStmtRule
- type ReturnStmtRules
- type Rule
- type Rules
- type RulesAdder
- type StructTypeRule
- type StructTypeRules
- type TypeInfo
- type TypeInfos
- type TypeSpecRule
- type TypeSpecRules
- type ValueSpecRule
- type ValueSpecRules
- type Visitor
Constants ¶
This section is empty.
Variables ¶
var Log func(format string, args ...interface{})
Log will be used to log only if PEPPERLINT_DEBUG is set
Functions ¶
func GetImportPathFromFullPath ¶
GetImportPathFromFullPath will return the import path from the given full path
func GetOpFromType ¶
GetOpFromType will iterate and find the field of name 'name'. Once that field has been found, it will return the call expr. If that field is not found, nil will be returned
func GetPackageNameFromImportPath ¶
GetPackageNameFromImportPath will return the package name from the import path
Types ¶
type ArrayTypeRule ¶
ArrayTypeRule represents an interface that will allow for validation to occur on an ast.ArrayType.
type ArrayTypeRules ¶
type ArrayTypeRules []ArrayTypeRule
ArrayTypeRules is a list of type ArrayTypeRule.
func (ArrayTypeRules) ValidateArrayType ¶
func (rules ArrayTypeRules) ValidateArrayType(array *ast.ArrayType) error
ValidateArrayType will iterate through the list of array types and call ValidateArrayType. If an error is returned, then that error will be added to the batch of errors.
type AssignStmtRule ¶
type AssignStmtRule interface {
ValidateAssignStmt(*ast.AssignStmt) error
}
AssignStmtRule represents an interface that will allow for validation to occur on an ast.AssignStmt.
type AssignStmtRules ¶
type AssignStmtRules []AssignStmtRule
AssignStmtRules is a list of type AssignStmtRule.
func (AssignStmtRules) ValidateAssignStmt ¶
func (rules AssignStmtRules) ValidateAssignStmt(stmt *ast.AssignStmt) error
ValidateAssignStmt will iterate through the list of array types and call ValidateAssignStmt. If an error is returned, then that error will be added to the batch of errors.
type BatchError ¶
type BatchError struct {
// contains filtered or unexported fields
}
BatchError groups a set of errors together usually to organize them by Validator but is not limited to.
func NewBatchError ¶
func NewBatchError(errs ...error) *BatchError
NewBatchError returns a new BatchError
func (*BatchError) Add ¶
func (e *BatchError) Add(errs ...error)
Add will add a new error to the BatchError
func (BatchError) Error ¶
func (e BatchError) Error() string
func (*BatchError) Errors ¶
func (e *BatchError) Errors() []error
Errors returns the list of errors back
func (*BatchError) Len ¶
func (e *BatchError) Len() int
Len returns the length of the errors contained in the BatchError
func (*BatchError) Return ¶
func (e *BatchError) Return() error
Return will return BatchError if there is at least 1 error in the container. If not, nil will be returned
type BinaryExprRule ¶
type BinaryExprRule interface {
ValidateBinaryExpr(*ast.BinaryExpr) error
}
BinaryExprRule represents an interface that will allow for validation to occur on an ast.BinaryExpr.
type BinaryExprRules ¶
type BinaryExprRules []BinaryExprRule
BinaryExprRules is a list of type BinaryExprRule.
func (BinaryExprRules) ValidateBinaryExpr ¶
func (rules BinaryExprRules) ValidateBinaryExpr(fn *ast.BinaryExpr) error
ValidateBinaryExpr will iterate through the list of array types and call ValidateBinaryExpr. If an error is returned, then that error will be added to the batch of errors.
type BlockStmtRule ¶
BlockStmtRule represents an interface that will allow for validation to occur on an ast.BlockStmt.
type BlockStmtRules ¶
type BlockStmtRules []BlockStmtRule
BlockStmtRules is a list of type BlockStmtRule.
func (BlockStmtRules) ValidateBlockStmt ¶
func (rules BlockStmtRules) ValidateBlockStmt(stmt *ast.BlockStmt) error
ValidateBlockStmt will iterate through the list of array types and call ValidateBlockStmt. If an error is returned, then that error will be added to the batch of errors.
type Cache ¶
Cache defintion that contain type information per package.
func NewCache ¶
func NewCache() *Cache
NewCache will return a new cache along with initializing any fields.
func (Cache) CurrentFile ¶
CurrentFile will attempt to return the current file that is being visited. If the file could not be found, then false will be returned.
func (Cache) CurrentPackage ¶
CurrentPackage will attempt to return the current package. If CurrentPkgImportPath was not found in the map, then false will be returned.
type CacheOption ¶
type CacheOption interface {
WithCache(*Cache)
}
CacheOption will allow rules to perform action based on what is in the cache.
type CallExprRule ¶
CallExprRule represents an interface that will allow for validation to occur on an ast.CallExpr.
type CallExprRules ¶
type CallExprRules []CallExprRule
CallExprRules is a list of type CallExprRule.
func (CallExprRules) ValidateCallExpr ¶
func (rules CallExprRules) ValidateCallExpr(expr *ast.CallExpr) error
ValidateCallExpr will iterate through the list of array types and call ValidateCallExpr. If an error is returned, then that error will be added to the batch of errors.
type ChanTypeRule ¶
ChanTypeRule represents an interface that will allow for validation to occur on an ast.ChanType.
type ChanTypeRules ¶
type ChanTypeRules []ChanTypeRule
ChanTypeRules is a list of type ChanTypeRule.
func (ChanTypeRules) ValidateChanType ¶
func (rules ChanTypeRules) ValidateChanType(ch *ast.ChanType) error
ValidateChanType will iterate through the list of array types and call ValidateChanType. If an error is returned, then that error will be added to the batch of errors.
type CopyRuler ¶
type CopyRuler interface {
CopyRule() Rule
}
CopyRuler is used to copy a pre-existing rule allowing for a new rule to be acted upon indenpendently from the rule it is copied from.
type ErrorWrap ¶
type ErrorWrap struct {
// contains filtered or unexported fields
}
ErrorWrap will extract the line number from the ast.Node provided. The prefix usually represents the file name that the lint error was found in.
func NewErrorWrap ¶
NewErrorWrap will return a new error and construct a prefix based on the node and file set. TODO: Wrap all returned errors in visitor.go with line number and file name
func (*ErrorWrap) LineNumber ¶
LineNumber return the line number to which the error occurred
type Errors ¶
type Errors []error
Errors is a list of errors. This type is mostly used for pretty printing the error message.
type FieldListRule ¶
FieldListRule represents an interface that will allow for validation to occur on an ast.FieldList.
type FieldListRules ¶
type FieldListRules []FieldListRule
FieldListRules is a list of type FieldListRule.
func (FieldListRules) ValidateFieldList ¶
func (rules FieldListRules) ValidateFieldList(fields *ast.FieldList) error
ValidateFieldList will iterate through the list of array types and call ValidateFieldList. If an error is returned, then that error will be added to the batch of errors.
type FieldRule ¶
FieldRule represents an interface that will allow for validation to occur on an ast.Field.
type FieldRules ¶
type FieldRules []FieldRule
FieldRules is a list of type FieldRule.
func (FieldRules) ValidateField ¶
func (rules FieldRules) ValidateField(field *ast.Field) error
ValidateField will iterate through the list of array types and call ValidateField. If an error is returned, then that error will be added to the batch of errors.
type File ¶
type File struct { ASTFile *ast.File TypeInfos TypeInfos OpInfos OpInfos Imports map[string]string }
File contains the file scope of types and operation infos
type FileError ¶
type FileError interface { error LineNumber Filename }
FileError is an error interface that will represent an error and where it occurred.
type FileRule ¶
FileRule represents an interface that will allow for validation to occur on an ast.File.
type FileSetOption ¶
FileSetOption will set the token.FileSet to a given rule.
type Filename ¶
type Filename interface {
Filename() string
}
Filename is the filename of where the error occurred.
type Files ¶
type Files []*File
Files is a list of Files
type FuncDeclRule ¶
FuncDeclRule represents an interface that will allow for validation to occur on an ast.FuncDecl.
type FuncDeclRules ¶
type FuncDeclRules []FuncDeclRule
FuncDeclRules is a list of type FuncDeclRule.
func (FuncDeclRules) ValidateFuncDecl ¶
func (rules FuncDeclRules) ValidateFuncDecl(decl *ast.FuncDecl) error
ValidateFuncDecl will iterate through the list of array types and call ValidateFuncDecl. If an error is returned, then that error will be added to the batch of errors.
type FuncTypeRule ¶
FuncTypeRule represents an interface that will allow for validation to occur on an ast.FuncType.
type FuncTypeRules ¶
type FuncTypeRules []FuncTypeRule
FuncTypeRules is a list of type FuncTypeRule.
func (FuncTypeRules) ValidateFuncType ¶
func (rules FuncTypeRules) ValidateFuncType(fn *ast.FuncType) error
ValidateFuncType will iterate through the list of array types and call ValidateFuncType. If an error is returned, then that error will be added to the batch of errors.
type GenDeclRule ¶
GenDeclRule represents an interface that will allow for validation to occur on an ast.GenDecl.
type GenDeclRules ¶
type GenDeclRules []GenDeclRule
GenDeclRules is a list of type GenDeclRule.
func (GenDeclRules) ValidateGenDecl ¶
func (rules GenDeclRules) ValidateGenDecl(decl *ast.GenDecl) error
ValidateGenDecl will iterate through the list of array types and call ValidateGenDecl. If an error is returned, then that error will be added to the batch of errors.
type Helper ¶
type Helper struct {
PackagesCache *Cache
}
Helper is used to make determing properties of an ast.Node
func (Helper) GetFieldByIndex ¶
GetFieldByIndex will retrieve the ast.Field off of an ast.TypeSpec and field index.
func (Helper) GetFieldByName ¶
GetFieldByName will retrieve the ast.Field off of an ast.TypeSpec and field name.
func (Helper) GetStructName ¶
GetStructName will return a struct from the given expr.
func (Helper) GetStructType ¶
func (h Helper) GetStructType(expr ast.Expr) *ast.StructType
GetStructType will return a struct from the given expr.
func (Helper) GetTypeSpec ¶
GetTypeSpec will return the given type spec for an expression. nil will be returned if one could not be found
type IncDecStmtRule ¶
type IncDecStmtRule interface {
ValidateIncDecStmt(*ast.IncDecStmt) error
}
IncDecStmtRule represents an interface that will allow for validation to occur on an ast.IncDecStmt.
type IncDecStmtRules ¶
type IncDecStmtRules []IncDecStmtRule
IncDecStmtRules is a list of type IncDecStmtRule.
func (IncDecStmtRules) ValidateIncDecStmt ¶
func (rules IncDecStmtRules) ValidateIncDecStmt(fn *ast.IncDecStmt) error
ValidateIncDecStmt will iterate through the list of array types and call ValidateIncDecStmt. If an error is returned, then that error will be added to the batch of errors.
type InterfaceTypeRule ¶
type InterfaceTypeRule interface {
ValidateInterfaceType(*ast.InterfaceType) error
}
InterfaceTypeRule represents an interface that will allow for validation to occur on an ast.InterfaceType.
type InterfaceTypeRules ¶
type InterfaceTypeRules []InterfaceTypeRule
InterfaceTypeRules is a list of type InterfaceTypeRule.
func (InterfaceTypeRules) ValidateInterfaceType ¶
func (rules InterfaceTypeRules) ValidateInterfaceType(iface *ast.InterfaceType) error
ValidateInterfaceType will iterate through the list of array types and call ValidateInterfaceType. If an error is returned, then that error will be added to the batch of errors.
type LineNumber ¶
type LineNumber interface {
LineNumber() int
}
LineNumber is used to return a line number of where an error occurred.
type MapTypeRule ¶
MapTypeRule represents an interface that will allow for validation to occur on an ast.MapType.
type MapTypeRules ¶
type MapTypeRules []MapTypeRule
MapTypeRules is a list of type MapTypeRule.
func (MapTypeRules) ValidateMapType ¶
func (rules MapTypeRules) ValidateMapType(m *ast.MapType) error
ValidateMapType will iterate through the list of array types and call ValidateMapType. If an error is returned, then that error will be added to the batch of errors.
type OpInfos ¶
OpInfos is a map of key operation name and OpInfo containing relevant per package operation declarations.
type Option ¶
type Option interface{}
Option will allow rules to be prepped with defined visitor Rules or caching can be initialized during the 'With' call of the option
type PackageRule ¶
PackageRule represents an interface that will allow for validation to occur on an ast.Package.
type PackageRules ¶
type PackageRules []PackageRule
PackageRules is a list of type PackageRule.
func (PackageRules) ValidatePackage ¶
func (rules PackageRules) ValidatePackage(pkg *ast.Package) error
ValidatePackage will iterate through the list of array types and call ValidatePackage. If an error is returned, then that error will be added to the batch of errors.
type RangeStmtRule ¶
RangeStmtRule represents an interface that will allow for validation to occur on an ast.RangeStmt.
type RangeStmtRules ¶
type RangeStmtRules []RangeStmtRule
RangeStmtRules is a list of type RangeStmtRule.
func (RangeStmtRules) ValidateRangeStmt ¶
func (rules RangeStmtRules) ValidateRangeStmt(stmt *ast.RangeStmt) error
ValidateRangeStmt will iterate through the list of array types and call ValidateRangeStmt. If an error is returned, then that error will be added to the batch of errors.
type ReturnStmtRule ¶
type ReturnStmtRule interface {
ValidateReturnStmt(*ast.ReturnStmt) error
}
ReturnStmtRule represents an interface that will allow for validation to occur on an ast.ReturnStmt.
type ReturnStmtRules ¶
type ReturnStmtRules []ReturnStmtRule
ReturnStmtRules is a list of type ReturnStmtRule.
func (ReturnStmtRules) ValidateReturnStmt ¶
func (rules ReturnStmtRules) ValidateReturnStmt(stmt *ast.ReturnStmt) error
ValidateReturnStmt will iterate through the list of array types and call ValidateReturnStmt. If an error is returned, then that error will be added to the batch of errors.
type Rule ¶
type Rule interface{}
Rule is an empty interface but will allow for modifications later if this needs to be a more specific type.
type Rules ¶
type Rules struct { PackageRules PackageRules FileRules FileRules // Specifications TypeSpecRules TypeSpecRules ValueSpecRules ValueSpecRules // Declarations GenDeclRules GenDeclRules FuncDeclRules FuncDeclRules // Expressions CallExprRules CallExprRules BinaryExprRules BinaryExprRules // Statements AssignStmtRules AssignStmtRules BlockStmtRules BlockStmtRules ReturnStmtRules ReturnStmtRules IncDecStmtRules IncDecStmtRules RangeStmtRules RangeStmtRules // Complex Types StructTypeRules StructTypeRules FieldRules FieldRules FieldListRules FieldListRules FuncTypeRules FuncTypeRules InterfaceTypeRules InterfaceTypeRules // Container Types ArrayTypeRules ArrayTypeRules ChanTypeRules ChanTypeRules MapTypeRules MapTypeRules }
Rules contain a set of all rule types that will be ran during visitation.
type RulesAdder ¶
type RulesAdder interface {
AddRules(*Rules)
}
RulesAdder will add rules to sets of rules
type StructTypeRule ¶
type StructTypeRule interface {
ValidateStructType(*ast.StructType) error
}
StructTypeRule allows for rules to be handled on ast.StructType definitions
type StructTypeRules ¶
type StructTypeRules []StructTypeRule
StructTypeRules is a list of type StructTypeRule
func (StructTypeRules) ValidateStructType ¶
func (rules StructTypeRules) ValidateStructType(s *ast.StructType) error
ValidateStructType will iterate through all provided StructTypeRules and call the ValidateStructType. Errors will be added in the BatchError type
type TypeInfo ¶
type TypeInfo struct { Doc *ast.CommentGroup Spec *ast.TypeSpec PkgName string }
TypeInfo contains the type definition and documentation tied to that definition.
type TypeSpecRule ¶
TypeSpecRule represents an interface that will allow for validation to occur on an ast.TypeSpec.
type TypeSpecRules ¶
type TypeSpecRules []TypeSpecRule
TypeSpecRules is a list of type TypeSpecRule.
func (TypeSpecRules) ValidateTypeSpec ¶
func (rules TypeSpecRules) ValidateTypeSpec(spec *ast.TypeSpec) error
ValidateTypeSpec will iterate through the list of array types and call ValidateTypeSpec. If an error is returned, then that error will be added to the batch of errors.
type ValueSpecRule ¶
ValueSpecRule represents an interface that will allow for validation to occur on an ast.ValueSpec.
type ValueSpecRules ¶
type ValueSpecRules []ValueSpecRule
ValueSpecRules is a list of type ValueSpecRule.
func (ValueSpecRules) ValidateValueSpec ¶
func (rules ValueSpecRules) ValidateValueSpec(spec *ast.ValueSpec) error
ValidateValueSpec will iterate through the list of array types and call ValidateValueSpec. If an error is returned, then that error will be added to the batch of errors.
type Visitor ¶
type Visitor struct { Rules Rules Errors Errors PackagesCache *Cache FileSet *token.FileSet // contains filtered or unexported fields }
Visitor is used to traferse a node and run the proper validaters based on the node that is passed in.
func NewVisitor ¶
NewVisitor returns a new visitor and instantiates a new rule set from the adders parameter.
Source Files
¶
- cache.go
- error.go
- logger.go
- option.go
- rule_array_type.go
- rule_assign_stmt.go
- rule_binary_expr.go
- rule_block_stmt.go
- rule_call_expr.go
- rule_chan_type.go
- rule_field.go
- rule_field_list.go
- rule_file.go
- rule_func_decl.go
- rule_func_type.go
- rule_gen_decl.go
- rule_inc_dec_stmt.go
- rule_interface_type.go
- rule_map_type.go
- rule_package.go
- rule_range_stmt.go
- rule_return_stmt.go
- rule_struct_type.go
- rule_type_spec.go
- rule_value_spec.go
- rules.go
- utils.go
- visitor.go