omissis/go-jsonschema

View on GitHub

Showing 28 of 36 total issues

Method schemaGenerator.generateDeclaredType has 6 return statements (exceeds 4 allowed).
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
Severity: Major
Found in pkg/generator/schema_generator.go - About 40 mins to fix

    Method HTTPLoader.Load has 6 return statements (exceeds 4 allowed).
    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)
        }
    Severity: Major
    Found in pkg/schemas/loaders.go - About 40 mins to fix

      Method numericValidator.genBoundary has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          out *codegen.Emitter,
          checkPointer,
          pointerPrefix,
          value string,
          boundary *float64,
      Severity: Minor
      Found in pkg/generator/validator.go - About 35 mins to fix

        Function QualifiedFileName has 5 return statements (exceeds 4 allowed).
        Open

        func QualifiedFileName(fileName, parentFileName string, resolveExtensions []string) (string, error) {
            r, err := GetRefType(fileName)
            if err != nil {
                return "", err
            }
        Severity: Major
        Found in pkg/schemas/loaders.go - About 35 mins to fix

          Method Package.Generate has 5 return statements (exceeds 4 allowed).
          Open

          func (p *Package) Generate(out *Emitter) {
              out.Comment(p.Comment)
              out.Printlnf("package %s", p.Name())
          
              if len(p.Imports) > 0 {
          Severity: Major
          Found in pkg/codegen/model.go - About 35 mins to fix

            Method schemaGenerator.generateRootType has 5 return statements (exceeds 4 allowed).
            Open

            func (g *schemaGenerator) generateRootType() error {
                if g.schema.ObjectAsType == nil {
                    return errSchemaHasNoRoot
                }
            
            
            Severity: Major
            Found in pkg/generator/schema_generator.go - About 35 mins to fix

              Function NormalizeBounds has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
              Open

              func NormalizeBounds(
                  minimum, maximum *float64, exclusiveMinimum, exclusiveMaximum *any,
              ) (*float64, *float64, bool, bool) {
                  var minBound, maxBound *float64
              
              
              Severity: Minor
              Found in pkg/mathutils/utils.go - About 35 mins to fix

              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

              func (g *schemaGenerator) generateStructType(
                  t *schemas.Type,
                  scope nameScope,
              ) (codegen.Type, error) {
                  if len(t.Properties) == 0 {
              Severity: Major
              Found in pkg/generator/schema_generator.go - About 35 mins to fix
                Severity
                Category
                Status
                Source
                Language