epoberezkin/ajv

View on GitHub
lib/compile/index.ts

Summary

Maintainability
C
1 day
Test Coverage

Function compileSchema has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function compileSchema(this: Ajv, sch: SchemaEnv): SchemaEnv {
  // TODO refactor - remove compilations
  const _sch = getCompilingSchema.call(this, sch)
  if (_sch) return _sch
  const rootId = getFullPath(this.opts.uriResolver, sch.root.baseId) // TODO if getFullPath removed 1 tests fails
Severity: Major
Found in lib/compile/index.ts - About 3 hrs to fix

    File index.ts has 281 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import type {
      AnySchema,
      AnySchemaObject,
      AnyValidateFunction,
      AsyncValidateFunction,
    Severity: Minor
    Found in lib/compile/index.ts - About 2 hrs to fix

      Function compileSchema has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      export function compileSchema(this: Ajv, sch: SchemaEnv): SchemaEnv {
        // TODO refactor - remove compilations
        const _sch = getCompilingSchema.call(this, sch)
        if (_sch) return _sch
        const rootId = getFullPath(this.opts.uriResolver, sch.root.baseId) // TODO if getFullPath removed 1 tests fails
      Severity: Minor
      Found in lib/compile/index.ts - About 2 hrs 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

      Function getJsonPointer has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      function getJsonPointer(
        this: Ajv,
        parsedRef: URIComponent,
        {baseId, schema, root}: SchemaEnv
      ): SchemaEnv | undefined {
      Severity: Minor
      Found in lib/compile/index.ts - About 1 hr 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

      Function resolveSchema has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      export function resolveSchema(
        this: Ajv,
        root: SchemaEnv, // root object with properties schema, refs TODO below SchemaEnv is assigned to it
        ref: string // reference to resolve
      ): SchemaEnv | undefined {
      Severity: Minor
      Found in lib/compile/index.ts - About 1 hr 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

      Avoid too many return statements within this function.
      Open

        return getJsonPointer.call(this, p, schOrRef)
      Severity: Major
      Found in lib/compile/index.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

          return undefined
        Severity: Major
        Found in lib/compile/index.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return new SchemaEnv({schema, schemaId, root, baseId})
          Severity: Major
          Found in lib/compile/index.ts - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status