Documentation
¶
Overview ¶
Package checker provides functionality for checking and validating Protocol Buffer (protobuf) files and their contents against predefined rules and conventions.
Index ¶
Constants ¶
const ( // MethodHasVersion checks whether a method specifies a version. MethodHasVersion = "method_has_version" // MethodHasCorrectInputName checks if the method input is named correctly. MethodHasCorrectInputName = "method_has_correct_input_name" // MethodHasHTTPPath checks if an HTTP path is specified for the method. MethodHasHTTPPath = "method_has_http_path" // MethodHasBodyTag checks if methods with a required body have the correct body tag. MethodHasBodyTag = "method_has_body_tag" // MethodHasSwaggerTags checks if a method has appropriate Swagger tags. MethodHasSwaggerTags = "method_has_swagger_tags" // MethodHasSwaggerSummary checks if a method has a valid Swagger summary. MethodHasSwaggerSummary = "method_has_swagger_summary" // MethodHasSwaggerDescription checks if a method has a valid Swagger description. MethodHasSwaggerDescription = "method_has_swagger_description" // MethodHasDefaultErrorResponse checks if a default error response is defined in the method. MethodHasDefaultErrorResponse = "method_has_default_error_response" // FieldNameIsSnakeCase checks if a field's name is in snake_case. FieldNameIsSnakeCase = "field_name_is_snake_case" // FieldHasCorrectJSONName checks if a field's JSON name tag is correct. FieldHasCorrectJSONName = "field_has_correct_json_name" // FieldHasNoDescription checks if a field has no description. FieldHasNoDescription = "field_has_no_description" // FieldDescriptionStartsWithCapital checks if a field's description starts with a capital letter. FieldDescriptionStartsWithCapital = "field_description_starts_with_capital" // FieldDescriptionEndsWithDotOrQuestionMark checks if a field's description ends with a dot or a question mark. FieldDescriptionEndsWithDotOrQuestionMark = "field_description_ends_with_dot_or_question_mark" // EnumValueHasComments checks if an enum value has leading comments. EnumValueHasComments = "enum_value_has_comments" )
Variables ¶
This section is empty.
Functions ¶
func ExecuteCheck ¶
ExecuteCheck runs the "check" subcommand.
func ExecutePrintConfig ¶ added in v1.1.6
func ExecutePrintConfig(patterns []string, configPath, githubURL string, isMimirFile, printAllDescriptors bool)
ExecutePrintConfig runs the "print-config" subcommand.
Types ¶
type ArtifactoryError ¶ added in v1.1.6
type ArtifactoryError struct {
Status int `json:"status"` // HTTP status code of the error.
Message string `json:"message"` // Message attached to the error.
}
ArtifactoryError represents an individual error received from artifactory.big-freaking-company.com.
type ArtifactoryErrorResponse ¶ added in v1.1.6
type ArtifactoryErrorResponse struct {
Errors []*ArtifactoryError `json:"errors"` // List of errors
}
ArtifactoryErrorResponse represents the structure of an error response from artifactory.big-freaking-company.com.
type MimirConfig ¶
type MimirConfig struct {
ProtoPaths []string `yaml:"proto_paths"`
}
MimirConfig defines the structure of the mimir file.
type OperationResult ¶ added in v1.1.6
type OperationResult struct {
File linker.File // The protobuf file that was operated on.
Messages []string // List of informational messages related to the operation.
Errors []string // List of errors. If empty, the operation is considered successful.
// contains filtered or unexported fields
}
OperationResult holds the results of an operation (check or list) on a single protobuf file.
func NewOperationResult ¶ added in v1.1.6
func NewOperationResult(parsedFile linker.File, cfg *config.Config) *OperationResult
NewOperationResult creates a new OperationResult based on the given parsed file and configuration.
func (*OperationResult) AddError ¶ added in v1.1.6
func (c *OperationResult) AddError(desc protoreflect.Descriptor, v string)
AddError appends an error message to the OperationResult's errors.
func (*OperationResult) AddErrorf ¶ added in v1.1.6
func (c *OperationResult) AddErrorf(desc protoreflect.Descriptor, format string, args ...any)
AddErrorf appends a formatted error message to the OperationResult's errors.
func (*OperationResult) AddMessage ¶ added in v1.1.6
func (c *OperationResult) AddMessage(v string)
AddMessage appends an informational message to the OperationResult's messages.
func (*OperationResult) AddMessagef ¶ added in v1.1.6
func (c *OperationResult) AddMessagef(format string, args ...any)
AddMessagef appends a formatted informational message to the OperationResult's messages.
type ProtoChecker ¶
type ProtoChecker struct {
// contains filtered or unexported fields
}
ProtoChecker represents a structure that wraps the compiler and parser for protobuf files.
func NewProtoChecker ¶
NewProtoChecker creates a new ProtoChecker instance.
func (*ProtoChecker) CheckFiles ¶
func (c *ProtoChecker) CheckFiles(ctx context.Context, files []string) ([]*OperationResult, error)
CheckFiles performs check operation on the provided protobuf files and returns a list of OperationResult instances, each containing the results for a single file.