Skip to content

Latest commit

 

History

History
97 lines (66 loc) · 2.2 KB

checkers.md

File metadata and controls

97 lines (66 loc) · 2.2 KB

consistent_receiver_names

Checks that method receivers of a type are named consistently.

func (i *Item) Execute() {} // OK
func (t *Item) Cancel() {}  // not OK

exported_ident_doc

Checks that all exported identifiers are documented (including field names, variable, constant, function, struct and interface declarations). Optionally checks that each comment starts with the name of the item it describes.

Available options:

  • has_ident_prefix: bool - ensure that every doc comment begins with the name of the item it describes.
// Runner is documented.
type Runner interface {

    // Run is documented.
    Run()

    // This method is not documented properly.
    Stop() error
}

left_quantifiers

Checks that when a numerical quantifier appears in a binary expression it is the left operand.

_ = 5 * time.Minute // OK
_ = time.Minute * 5 // not OK

line_length

Checks that the code lines are within specific length limits.

Available options:

  • max_length: int - the maximum number of characters permitted on a single line.
  • tab_width: int - the number of characters equivalent to a single tab.

local_return

Checks that exported functions return exported (and internal) types only.

func (i *Item) Do() result {} // not OK, `result` should be exported

multi_word_ident_name

Checks the correctness of type names. Correct type names adhere to the following rules:

  • PascalCase for exported types.
  • camelCase for non-exported types.
type processTracker struct{}  // OK
type ProcessTracker struct{}  // OK
type process_tracker struct{} // not OK

pass_context_first

Checks function declarations which have context.Context in them. If the context is not the first argument, the checker will report an error.

func Get(id string, ctx context.Context) () {} // not OK, `ctx` should be first

return_error_last

Checks that error is the last value returned by a function.

func Create() (int, error, bool) {} // not OK, `error` should be last

test_package

Checks that tests are placed in *_test packages only.

package feature // not OK, should be `feature_test`

import "testing"

func TestFeature(t *testing.T) {}