epoberezkin/ajv

View on GitHub

Showing 130 of 215 total issues

Function failResult has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  failResult(condition: Code, successAction?: () => void, failAction?: () => void): void {
    this.gen.if(condition)
    if (failAction) failAction()
    else this.error()
    if (successAction) {
Severity: Minor
Found in lib/compile/validate/index.ts - 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

Function value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  value(nameOrPrefix: ValueScopeName | string, value: NameValue): ValueScopeName {
    if (value.ref === undefined) throw new Error("CodeGen: ref must be passed in value")
    const name = this.toName(nameOrPrefix) as ValueScopeName
    const {prefix} = name
    const valueKey = value.key ?? value.ref
Severity: Minor
Found in lib/compile/codegen/scope.ts - 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

Function validatePropertyDeps has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function validatePropertyDeps(
  cxt: KeywordCxt,
  propertyDeps: {[K in string]?: string[]} = cxt.schema
): void {
  const {gen, data, it} = cxt
Severity: Minor
Found in lib/vocabularies/applicator/dependencies.ts - 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

Function validateTuple has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function validateTuple(
  cxt: KeywordCxt,
  extraItems: string,
  schArr: AnySchema[] = cxt.schema
): void {
Severity: Minor
Found in lib/vocabularies/applicator/items.ts - 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

Function code has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  code(cxt: KeywordCxt) {
    const {gen, parentSchema, it} = cxt
    if (parentSchema.then === undefined && parentSchema.else === undefined) {
      checkStrictMode(it, '"if" without "then" and "else" is ignored')
    }
Severity: Minor
Found in lib/vocabularies/applicator/if.ts - 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

Function constructor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  constructor(it: SchemaObjCxt, def: AddedKeywordDefinition, keyword: string) {
    validateKeywordUsage(it, def, keyword)
    this.gen = it.gen
    this.allErrors = it.allErrors
    this.keyword = keyword
Severity: Minor
Found in lib/compile/validate/index.ts - 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

Function ucs2length has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export default function ucs2length(str: string): number {
  const len = str.length
  let length = 0
  let pos = 0
  let value: number
Severity: Minor
Found in lib/runtime/ucs2length.ts - 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

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
    Severity: Major
    Found in lib/compile/codegen/code.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

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

        Avoid too many return statements within this function.
        Open

          return str
        Severity: Major
        Found in lib/runtime/parseJson.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 +numStr
            Severity: Major
            Found in lib/runtime/parseJson.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                if (typeof b == "string" && b[0] === '"' && !(a instanceof Name)) return `"${a}${b.slice(1)}`
              Severity: Major
              Found in lib/compile/codegen/code.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

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

                  Avoid too many return statements within this function.
                  Open

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

                    Avoid too many return statements within this function.
                    Open

                        if (cond === false || !this.nodes.length) return undefined
                    Severity: Major
                    Found in lib/compile/codegen/index.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return this
                      Severity: Major
                      Found in lib/compile/codegen/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

                          Avoid too many return statements within this function.
                          Open

                              if (b[0] === '"') return a.slice(0, -1) + b.slice(1)
                          Severity: Major
                          Found in lib/compile/codegen/code.ts - About 30 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language