checks

package
v0.0.0-...-1365ae2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2017 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package checks contains default checks included with the Thrift linter.

Index

Constants

This section is empty.

Variables

View Source
var (

	// CheckNamesDefaults is a map of Thrift AST node type to a regular expression for
	// validating names of that type.
	CheckNamesDefaults = map[reflect.Type]NamingStyle{
		thriftlint.ServiceType:   upperCamelCaseStyle,
		thriftlint.EnumType:      upperCamelCaseStyle,
		thriftlint.StructType:    upperCamelCaseStyle,
		thriftlint.EnumValueType: upperSnakeCaseStyle,
		thriftlint.FieldType:     lowerCamelCaseStyle,
		thriftlint.MethodType:    lowerCamelCaseStyle,
		thriftlint.ConstantType:  upperSnakeCaseStyle,
	}

	// CheckNamesDefaultBlacklist is names that should never be used for symbols.
	CheckNamesDefaultBlacklist = map[string]bool{
		"class": true,
		"int":   true,
	}
)

Functions

func CheckAnnotations

func CheckAnnotations(patterns []*AnnotationPattern, checks thriftlint.Checks) thriftlint.Check

CheckAnnotations validates Thrift annotations against regular expressions.

All supported annotations must be represented.

NOTE: This should be the last check added in order to correctly validate the allowed values for "nolint".

func CheckDefaultValues

func CheckDefaultValues() thriftlint.Check

CheckDefaultValues checks that default values are not provided.

func CheckEnumSequence

func CheckEnumSequence() thriftlint.Check

CheckEnumSequence checks that enums start with 0 and increment sequentially.

func CheckIndentation

func CheckIndentation() thriftlint.Check

CheckIndentation checks indentation is a multiple of 2.

func CheckMapKeys

func CheckMapKeys() thriftlint.Check

CheckMapKeys verifies that map keys are valid types.

func CheckNames

func CheckNames(matches map[reflect.Type]NamingStyle, blacklist map[string]bool) thriftlint.Check

CheckNames checks Thrift symbols comply with a set of regular expressions.

If matches or blacklist are nil, global defaults will be used.

func CheckOptional

func CheckOptional() thriftlint.Check

CheckOptional ensures that all Thrift fields are optional, as is generally accepted best practice for Thrift.

func CheckStructFieldOrder

func CheckStructFieldOrder() thriftlint.Check

CheckStructFieldOrder ensures that struct field IDs are present in-order in the file.

func CheckTypeReferences

func CheckTypeReferences() thriftlint.Check

CheckTypeReferences checks that types referenced in Thrift files are actually imported and exist.

Types

type AnnotationPattern

type AnnotationPattern struct {
	//AST nodes this annotation pattern should apply to.
	Nodes      []reflect.Type
	Annotation string
	Regex      string
}

type NamingStyle

type NamingStyle struct {
	Name    string
	Pattern *regexp.Regexp
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL