Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAnalyzer ¶
func NewAnalyzer(config *Configuration) *analysis.Analyzer
Types ¶
type Configuration ¶
type Configuration struct { // StrictAppend will do strict checking when assigning from append (x = // append(x, y)). If this is set to true the append call must append either // a variable assigned, called or used on the line above. Example on not // allowed when this is true: // // x := []string{} // y := "not going in X" // x = append(x, "not y") // This is not allowed with StrictAppend // z := "going in X" // // x = append(x, z) // This is allowed with StrictAppend // // m := transform(z) // x = append(x, z) // So is this because Z is used above. StrictAppend bool // AllowAssignAndCallCuddle allows assignments to be cuddled with variables // used in calls on line above and calls to be cuddled with assignments of // variables used in call on line above. // Example supported with this set to true: // // x.Call() // x = Assign() // x.AnotherCall() // x = AnotherAssign() AllowAssignAndCallCuddle bool // AllowAssignAndAnythingCuddle allows assignments to be cuddled with anything. // Example supported with this set to true: // if x == 1 { // x = 0 // } // z := x + 2 // fmt.Println("x") // y := "x" AllowAssignAndAnythingCuddle bool // AllowMultiLineAssignCuddle allows cuddling to assignments even if they // span over multiple lines. This defaults to true which allows the // following example: // // err := function( // "multiple", "lines", // ) // if err != nil { // // ... // } AllowMultiLineAssignCuddle bool // If the number of lines in a case block is equal to or lager than this // number, the case *must* end white a newline. ForceCaseTrailingWhitespaceLimit int // AllowTrailingComment will allow blocks to end with comments. AllowTrailingComment bool // AllowSeparatedLeadingComment will allow multiple comments in the // beginning of a block separated with newline. Example: // func () { // // Comment one // // // Comment two // fmt.Println("x") // } AllowSeparatedLeadingComment bool // AllowCuddleDeclaration will allow multiple var/declaration statements to // be cuddled. This defaults to false but setting it to true will enable the // following example: // var foo bool // var err error AllowCuddleDeclaration bool // AllowCuddleWithCalls is a list of call idents that everything can be // cuddled with. Defaults to calls looking like locks to support a flow like // this: // // mu.Lock() // allow := thisAssignment AllowCuddleWithCalls []string // AllowCuddleWithRHS is a list of right hand side variables that is allowed // to be cuddled with anything. Defaults to assignments or calls looking // like unlocks to support a flow like this: // // allow := thisAssignment() // mu.Unlock() AllowCuddleWithRHS []string // ForceCuddleErrCheckAndAssign will cause an error when an If statement that // checks an error variable doesn't cuddle with the assignment of that variable. // This defaults to false but setting it to true will cause the following // to generate an error: // // err := ProduceError() // // if err != nil { // return err // } ForceCuddleErrCheckAndAssign bool // When ForceCuddleErrCheckAndAssign is enabled this is a list of names // used for error variables to check for in the conditional. // Defaults to just "err" ErrorVariableNames []string // ForceExclusiveShortDeclarations will cause an error if a short declaration // (:=) cuddles with anything other than another short declaration. For example // // a := 2 // b := 3 // // is allowed, but // // a := 2 // b = 3 // // is not allowed. This logic overrides ForceCuddleErrCheckAndAssign among others. ForceExclusiveShortDeclarations bool // IncludeGenerated will include generated files in the analysis and report // errors even for generated files. Can be useful when developing // generators. IncludeGenerated bool }
Configuration represents configurable settings for the linter.
Click to show internal directories.
Click to hide internal directories.