Showing 28 of 36 total issues
Method schemaGenerator.generateDeclaredType
has 6 return statements (exceeds 4 allowed). Open
Open
func (g *schemaGenerator) generateDeclaredType(
t *schemas.Type, scope nameScope,
) (codegen.Type, error) {
if decl, ok := g.output.declsBySchema[t]; ok {
return &codegen.NamedType{Decl: decl}, nil
Method HTTPLoader.Load
has 6 return statements (exceeds 4 allowed). Open
Open
func (l *HTTPLoader) Load(uri, parentURI string) (*Schema, error) {
u, err := url.Parse(uri)
if err != nil {
return nil, fmt.Errorf("failed to parse url: %w", err)
}
Method numericValidator.genBoundary
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
out *codegen.Emitter,
checkPointer,
pointerPrefix,
value string,
boundary *float64,
Function QualifiedFileName
has 5 return statements (exceeds 4 allowed). Open
Open
func QualifiedFileName(fileName, parentFileName string, resolveExtensions []string) (string, error) {
r, err := GetRefType(fileName)
if err != nil {
return "", err
}
Method Package.Generate
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *Package) Generate(out *Emitter) {
out.Comment(p.Comment)
out.Printlnf("package %s", p.Name())
if len(p.Imports) > 0 {
Method schemaGenerator.generateRootType
has 5 return statements (exceeds 4 allowed). Open
Open
func (g *schemaGenerator) generateRootType() error {
if g.schema.ObjectAsType == nil {
return errSchemaHasNoRoot
}
Function NormalizeBounds
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func NormalizeBounds(
minimum, maximum *float64, exclusiveMinimum, exclusiveMaximum *any,
) (*float64, *float64, bool, bool) {
var minBound, maxBound *float64
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method schemaGenerator.generateStructType
has 5 return statements (exceeds 4 allowed). Open
Open
func (g *schemaGenerator) generateStructType(
t *schemas.Type,
scope nameScope,
) (codegen.Type, error) {
if len(t.Properties) == 0 {