Showing 130 of 215 total issues
Function code
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
code(cxt: KeywordCxt, ruleType?: string) {
const {gen, data, $data, schema, schemaCode, it} = cxt
const {opts, errSchemaPath, schemaEnv, self} = it
if (!opts.validateFormats) return
Function coerceData
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
function coerceData(it: SchemaObjCxt, types: JSONType[], coerceTo: JSONType[]): void {
const {gen, data, opts} = it
const dataType = gen.let("dataType", _`typeof ${data}`)
const coerced = gen.let("coerced", _`undefined`)
if (opts.coerceTypes === "array") {
Function code
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
code(cxt: KeywordCxt) {
const {gen, schema, schemaCode, data, $data, it} = cxt
const {opts} = it
if (!$data && schema.length === 0) return
const useLoop = schema.length >= opts.loopRequired
- 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
Function code
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
code(cxt: KeywordCxt) {
const {gen, schema, data, parentSchema, it} = cxt
const {opts} = it
const patterns = allSchemaProperties(schema)
const alwaysValidPatterns = patterns.filter((p) =>
- 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
File index.ts
has 281 lines of code (exceeds 250 allowed). Consider refactoring. Open
import type {
AnySchema,
AnySchemaObject,
AnyValidateFunction,
AsyncValidateFunction,
Function code
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
code(cxt: KeywordCxt) {
const {gen, schema, parentSchema, data, it} = cxt
let min: number
let max: number | undefined
const {minContains, maxContains} = parentSchema
Ajv
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
export default class Ajv {
opts: InstanceOptions
errors?: ErrorObject[] | null // errors from the last validation
logger: Logger
// shared external scope values for compiled functions
Function code
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
code(cxt: KeywordCxt) {
const {gen, schema, data, parentSchema, it} = cxt
const {opts} = it
const patterns = allSchemaProperties(schema)
const alwaysValidPatterns = patterns.filter((p) =>
Function getData
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
export function getData(
$data: string,
{dataLevel, dataNames, dataPathArr}: SchemaCxt
): Code | number {
let jsonPointer
- 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
Function code
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
code(cxt) {
const {gen, schema, data, errsCount, it} = cxt
/* istanbul ignore if */
if (!errsCount) throw new Error("ajv implementation error")
const {allErrors, props} = it
- 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
Function code
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
code(cxt: KeywordCxt) {
const {gen, schema, schemaCode, data, $data, it} = cxt
const {opts} = it
if (!$data && schema.length === 0) return
const useLoop = schema.length >= opts.loopRequired
Function callRef
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function callRef(cxt: KeywordCxt, v: Code, sch?: SchemaEnv, $async?: boolean): void {
const {gen, it} = cxt
const {allErrors, schemaEnv: env, opts} = it
const passCxt = opts.passContext ? N.this : nil
if ($async) callAsyncRef()
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
- 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
Function compileAsync
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
compileAsync<T = unknown>(
schema: AnySchemaObject,
meta?: boolean
): Promise<AnyValidateFunction<T>> {
if (typeof this.opts.loadSchema != "function") {
- 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
Function parseJsonString
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function parseJsonString(s: string, pos: number): string | undefined {
let str = ""
let c: string | undefined
parseJsonString.message = undefined
// eslint-disable-next-line no-constant-condition, @typescript-eslint/no-unnecessary-condition
Function parseJsonNumber
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function parseJsonNumber(s: string, pos: number, maxDigits?: number): number | undefined {
let numStr = ""
let c: string
parseJsonNumber.message = undefined
if (s[pos] === "-") {
Function optimizeNodes
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
optimizeNodes(): If | ChildNode[] | undefined {
super.optimizeNodes()
const cond = this.condition
if (cond === true) return this.nodes // else is ignored here
let e = this.else
- 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
Function funcKeywordCode
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function funcKeywordCode(cxt: KeywordCxt, def: FuncKeywordDefinition): void {
const {gen, keyword, schema, parentSchema, $data, it} = cxt
checkAsyncKeyword(it, def)
const validate =
!$data && def.compile ? def.compile.call(it.self, schema, parentSchema, it) : def.validate
Function code
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
code(cxt) {
const {gen, schema, data, errsCount, it} = cxt
/* istanbul ignore if */
if (!errsCount) throw new Error("ajv implementation error")
const {allErrors, props} = it
Function getSchemaRefs
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function getSchemaRefs(this: Ajv, schema: AnySchema, baseId: string): LocalRefs {
if (typeof schema == "boolean") return {}
const {schemaId, uriResolver} = this.opts
const schId = normalizeId(schema[schemaId] || baseId)
const baseIds: {[JsonPtr in string]?: string} = {"": schId}