epoberezkin/ajv

View on GitHub

Showing 130 of 215 total issues

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

  code(cxt: KeywordCxt) {
    checkMetadata(cxt)
    const {gen, data, schema: ref, parentSchema, it} = cxt
    const {
      schemaEnv: {root},
Severity: Minor
Found in lib/vocabularies/jtd/ref.ts - About 1 hr to fix

    Function compileAsync has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      compileAsync<T = unknown>(
        schema: AnySchemaObject,
        meta?: boolean
      ): Promise<AnyValidateFunction<T>> {
        if (typeof this.opts.loadSchema != "function") {
    Severity: Minor
    Found in lib/core.ts - About 1 hr to fix

      Function schemaKeywords has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      function schemaKeywords(
        it: SchemaObjCxt,
        types: JSONType[],
        typeErrors: boolean,
        errsCount?: Name
      Severity: Minor
      Found in lib/compile/validate/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 code has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        code(cxt: KeywordCxt) {
          const {gen, data, $data, schema, parentSchema, schemaCode, it} = cxt
          if (!$data && !schema) return
          const valid = gen.let("valid")
          const itemTypes = parentSchema.items ? getSchemaTypes(parentSchema.items) : []
      Severity: Minor
      Found in lib/vocabularies/validation/uniqueItems.ts - About 1 hr to fix

        Function serializeSchemaProperties has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function serializeSchemaProperties(cxt: SerializeCxt, discriminator?: string): void {
          const {gen, schema, data} = cxt
          const {properties, optionalProperties} = schema
          const props = keys(properties)
          const optProps = keys(optionalProperties)
        Severity: Minor
        Found in lib/compile/jtd/serialize.ts - About 1 hr to fix

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

            code(cxt: KeywordCxt) {
              checkMetadata(cxt)
              const {gen, data, schema, parentSchema} = cxt
              const [valid, cond] = checkNullableObject(cxt, data)
          
          
          Severity: Minor
          Found in lib/vocabularies/jtd/discriminator.ts - About 1 hr to fix

            Function serializeSchemaProperties has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

            function serializeSchemaProperties(cxt: SerializeCxt, discriminator?: string): void {
              const {gen, schema, data} = cxt
              const {properties, optionalProperties} = schema
              const props = keys(properties)
              const optProps = keys(optionalProperties)
            Severity: Minor
            Found in lib/compile/jtd/serialize.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 code has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              code(cxt: KeywordCxt) {
                const {gen, schema, parentSchema, it} = cxt
                /* istanbul ignore if */
                if (!Array.isArray(schema)) throw new Error("ajv implementation error")
                if (it.opts.discriminator && parentSchema.discriminator) return
            Severity: Minor
            Found in lib/vocabularies/applicator/oneOf.ts - About 1 hr to fix

              Function coerceSpecificType has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                function coerceSpecificType(t: string): void {
                  switch (t) {
                    case "string":
                      gen
                        .elseIf(_`${dataType} == "number" || ${dataType} == "boolean"`)
              Severity: Minor
              Found in lib/compile/validate/dataType.ts - About 1 hr to fix

                Function code has 42 lines of code (exceeds 25 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 1 hr to fix

                  Function getMapping has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      function getMapping(): {[T in string]?: number} {
                        const oneOfMapping: {[T in string]?: number} = {}
                        const topRequired = hasRequired(parentSchema)
                        let tagRequired = true
                        for (let i = 0; i < oneOf.length; i++) {
                  Severity: Minor
                  Found in lib/vocabularies/discriminator/index.ts - About 1 hr to fix

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

                      code(cxt: KeywordCxt) {
                        const {gen, schema, parentSchema, data, it} = cxt
                        if (it.opts.removeAdditional === "all" && parentSchema.additionalProperties === undefined) {
                          apDef.code(new KeywordCxt(it, apDef, "additionalProperties"))
                        }
                    Severity: Minor
                    Found in lib/vocabularies/applicator/properties.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 parseType has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function parseType(cxt: ParseCxt): void {
                      const {gen, schema, data, self} = cxt
                      switch (schema.type) {
                        case "boolean":
                          parseBoolean(cxt)
                    Severity: Minor
                    Found in lib/compile/jtd/parse.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 parseType has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function parseType(cxt: ParseCxt): void {
                      const {gen, schema, data, self} = cxt
                      switch (schema.type) {
                        case "boolean":
                          parseBoolean(cxt)
                    Severity: Minor
                    Found in lib/compile/jtd/parse.ts - About 1 hr to fix

                      Function compileSerializer has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export default function compileSerializer(
                        this: Ajv,
                        sch: SchemaEnv,
                        definitions: SchemaObjectMap
                      ): SchemaEnv {
                      Severity: Minor
                      Found in lib/compile/jtd/serialize.ts - About 1 hr to fix

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

                          code(cxt: KeywordCxt) {
                            const {gen, schema, parentSchema, data, it} = cxt
                            if (it.opts.removeAdditional === "all" && parentSchema.additionalProperties === undefined) {
                              apDef.code(new KeywordCxt(it, apDef, "additionalProperties"))
                            }
                        Severity: Minor
                        Found in lib/vocabularies/applicator/properties.ts - About 1 hr to fix

                          Function validateFormat has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              function validateFormat(): void {
                                const formatDef: AddedFormat | undefined = self.formats[schema]
                                if (!formatDef) {
                                  unknownFormat()
                                  return
                          Severity: Minor
                          Found in lib/vocabularies/format/format.ts - About 1 hr to fix

                            Function compileParser has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export default function compileParser(
                              this: Ajv,
                              sch: SchemaEnv,
                              definitions: SchemaObjectMap
                            ): SchemaEnv {
                            Severity: Minor
                            Found in lib/compile/jtd/parse.ts - About 1 hr to fix

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

                                code(cxt: KeywordCxt) {
                                  checkMetadata(cxt)
                                  const {gen, data, schema, it} = cxt
                                  const [valid, cond] = checkNullableObject(cxt, data)
                                  if (alwaysValidSchema(it, schema)) {
                              Severity: Minor
                              Found in lib/vocabularies/jtd/values.ts - About 1 hr to fix

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

                                  code(cxt: KeywordCxt): void {
                                    const {gen, schema: $ref, it} = cxt
                                    const {baseId, schemaEnv: env, validateName, opts, self} = it
                                    const {root} = env
                                    if (($ref === "#" || $ref === "#/") && baseId === root.baseId) return callRootRef()
                                Severity: Minor
                                Found in lib/vocabularies/core/ref.ts - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language