Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // AllLinters is the slice of all known Linters. AllLinters = []Linter{ commentsNoCStyleLinter, enumFieldNamesUppercaseLinter, enumFieldNamesUpperSnakeCaseLinter, enumFieldPrefixesLinter, enumNamesCamelCaseLinter, enumNamesCapitalizedLinter, enumZeroValuesInvalidLinter, enumsHaveCommentsLinter, enumsNoAllowAliasLinter, fileOptionsEqualGoPackagePbSuffixLinter, fileOptionsEqualJavaMultipleFilesTrueLinter, fileOptionsEqualJavaOuterClassnameProtoSuffixLinter, fileOptionsEqualJavaPackageComPrefixLinter, fileOptionsGoPackageSameInDirLinter, fileOptionsJavaMultipleFilesSameInDirLinter, fileOptionsJavaPackageSameInDirLinter, fileOptionsRequireGoPackageLinter, fileOptionsRequireJavaMultipleFilesLinter, fileOptionsRequireJavaOuterClassnameLinter, fileOptionsRequireJavaPackageLinter, fileOptionsUnsetJavaMultipleFilesLinter, fileOptionsUnsetJavaOuterClassnameLinter, messageFieldsNotFloatsLinter, messageFieldNamesLowerSnakeCaseLinter, messageFieldNamesLowercaseLinter, messageNamesCamelCaseLinter, messageNamesCapitalizedLinter, messagesHaveCommentsLinter, messagesHaveCommentsExceptRequestResponseTypesLinter, oneofNamesLowerSnakeCaseLinter, packageIsDeclaredLinter, packageLowerSnakeCaseLinter, packagesSameInDirLinter, rpcsHaveCommentsLinter, rpcNamesCamelCaseLinter, rpcNamesCapitalizedLinter, requestResponseTypesInSameFileLinter, requestResponseTypesUniqueLinter, requestResponseNamesMatchRPCLinter, servicesHaveCommentsLinter, serviceNamesCamelCaseLinter, serviceNamesCapitalizedLinter, syntaxProto3Linter, wktDirectlyImportedLinter, } // DefaultLinters is the slice of default Linters. DefaultLinters = copyLintersWithout( AllLinters, enumFieldNamesUppercaseLinter, enumsHaveCommentsLinter, fileOptionsUnsetJavaMultipleFilesLinter, fileOptionsUnsetJavaOuterClassnameLinter, messageFieldsNotFloatsLinter, messagesHaveCommentsLinter, messagesHaveCommentsExceptRequestResponseTypesLinter, messageFieldNamesLowercaseLinter, requestResponseNamesMatchRPCLinter, rpcsHaveCommentsLinter, servicesHaveCommentsLinter, ) // DefaultGroup is the default group. DefaultGroup = "default" // AllGroup is the group of all known linters. AllGroup = "all" // GroupToLinters is the map from linter group to the corresponding slice of linters. GroupToLinters = map[string][]Linter{ DefaultGroup: DefaultLinters, AllGroup: AllLinters, } )
Functions ¶
Types ¶
type Linter ¶
type Linter interface { // Return the ID of this Linter. This should be all UPPER_SNAKE_CASE. ID() string // Return the purpose of this Linter. This should be a human-readable string. Purpose() string // Check the file data for the descriptors in a common directgory. // If there is a lint failure, this returns it in the // slice and does not return an error. An error is returned if something // unexpected happens. Callers should verify the files are compilable // before running this. Check(dirPath string, descriptors []*proto.Proto) ([]*text.Failure, error) }
Linter is a linter for Protobuf files.
func GetLinters ¶
func GetLinters(config settings.LintConfig) ([]Linter, error)
GetLinters returns the Linters for the LintConfig.
The configuration is expected to be valid, deduplicated, and all upper-case. IncludeIDs and ExcludeIDs MUST NOT have an intersection.
If the config came from the settings package, this is already validated.
func NewLinter ¶
func NewLinter(id string, purpose string, addCheck func(func(*text.Failure), string, []*proto.Proto) error) Linter
NewLinter is a convenience function that returns a new Linter for the given parameters, using a function to record failures.
The ID will be upper-cased.
Failures returned from check do not need to set the ID, this will be overwritten.
type RunnerOption ¶
type RunnerOption func(*runner)
RunnerOption is an option for a new Runner.
func RunnerWithLogger ¶
func RunnerWithLogger(logger *zap.Logger) RunnerOption
RunnerWithLogger returns a RunnerOption that uses the given logger.
The default is to use zap.NewNop().
Source Files ¶
- base_linter.go
- base_visitor.go
- check_comments_no_c_style.go
- check_enum_field_names_upper_snake_case.go
- check_enum_field_names_uppercase.go
- check_enum_field_prefixes.go
- check_enum_names_camel_case.go
- check_enum_names_capitalized.go
- check_enum_zero_values_invalid.go
- check_enums_have_comments.go
- check_enums_no_allow_alias.go
- check_file_options_equal.go
- check_file_options_required.go
- check_file_options_same_in_dir.go
- check_file_options_unset.go
- check_message_field_names_lower_snake_case.go
- check_message_field_names_lowercase.go
- check_message_fields_not_floats.go
- check_message_names_camel_case.go
- check_message_names_capitalized.go
- check_messages_have_comments.go
- check_messages_have_comments_except_request_response_types.go
- check_oneof_names_lower_snake_case.go
- check_package_is_declared.go
- check_package_lower_snake_case.go
- check_packages_same_in_dir.go
- check_request_response_names_match_rpc.go
- check_request_response_types_in_same_file.go
- check_request_response_types_unique.go
- check_rpc_names_camel_case.go
- check_rpc_names_capitalized.go
- check_rpcs_have_comments.go
- check_service_names_camel_case.go
- check_service_names_capitalized.go
- check_services_have_comments.go
- check_syntax_proto3.go
- check_wkt_directly_imported.go
- lint.go
- runner.go