Showing 130 of 215 total issues
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 {
- 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 $dataMetaSchema
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
$dataMetaSchema(metaSchema: AnySchemaObject, keywordsJsonPointers: string[]): AnySchemaObject {
const rules = this.RULES.all
metaSchema = JSON.parse(JSON.stringify(metaSchema))
for (const jsonPointer of keywordsJsonPointers) {
const segments = jsonPointer.split("/").slice(1) // first segment is an empty string
- 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 _addSchema
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
_addSchema(
schema: AnySchema,
meta?: boolean,
baseId?: string,
validateSchema = this.opts.validateSchema,
- 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 addKeyword
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
addKeyword(
kwdOrDef: string | KeywordDefinition,
def?: KeywordDefinition // deprecated
): Ajv {
let keyword: string | string[]
Function removeSchema
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
removeSchema(schemaKeyRef?: AnySchema | string | RegExp): Ajv {
if (schemaKeyRef instanceof RegExp) {
this._removeAllSchemas(this.schemas, schemaKeyRef)
this._removeAllSchemas(this.refs, schemaKeyRef)
return this
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 {
- 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 mergeExprItems
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function mergeExprItems(a: CodeItem, b: CodeItem): CodeItem | undefined {
if (b === '""') return a
if (a === '""') return b
if (typeof a == "string") {
if (b instanceof Name || a[a.length - 1] !== '"') return
- 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 parseDiscriminator
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parseDiscriminator(cxt: ParseCxt): void {
const {gen, data, schema} = cxt
const {discriminator, mapping} = schema
parseToken(cxt, "{")
gen.assign(data, _`{}`)
Function validateCode
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function validateCode(usedValues: UsedScopeValues, s?: SourceCode): Code {
if (!s) throw new Error('moduleCode: function does not have "source" property')
if (usedState(s.validateName) === UsedValueState.Completed) return nil
setUsedState(s.validateName, UsedValueState.Started)
Function validateTuple
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function validateTuple(
cxt: KeywordCxt,
extraItems: string,
schArr: AnySchema[] = cxt.schema
): void {
Function parseSchemaProperties
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parseSchemaProperties(cxt: ParseCxt, discriminator?: string): void {
const {gen, schema, data} = cxt
const {properties, optionalProperties, additionalProperties} = schema
parseItems(cxt, "}", () => {
const key = gen.let("key")
Function code
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
code(cxt: KeywordCxt) {
checkMetadata(cxt)
const {data, schema, parentSchema, it} = cxt
let cond: Code
switch (schema) {
Function getErrorPath
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function getErrorPath(
dataProp: Name | string | number,
dataPropType?: Type,
jsPropertySyntax?: boolean
): Code | string {
- 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 validateKeywordUsage
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function validateKeywordUsage(
{schema, opts, self, errSchemaPath}: SchemaObjCxt,
def: AddedKeywordDefinition,
keyword: string
): void {
- 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 10 (exceeds 5 allowed). Consider refactoring. Open
code(cxt: KeywordCxt) {
const {gen, data, $data, schema, schemaCode, it} = cxt
if (!$data && schema.length === 0) throw new Error("enum must have non-empty array")
const useLoop = schema.length >= it.opts.loopEnum
let eql: Name | undefined
- 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 10 (exceeds 5 allowed). Consider refactoring. Open
code(cxt: KeywordCxt) {
checkMetadata(cxt)
const {data, schema, parentSchema, it} = cxt
let cond: Code
switch (schema) {
- 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 addKeyword
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
addKeyword(
kwdOrDef: string | KeywordDefinition,
def?: KeywordDefinition // deprecated
): Ajv {
let keyword: string | string[]
- 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 hasRef
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function hasRef(schema: AnySchemaObject): boolean {
for (const key in schema) {
if (REF_KEYWORDS.has(key)) return true
const sch = schema[key]
if (Array.isArray(sch) && sch.some(hasRef)) return true
- 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 invalid$data
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
invalid$data(): Code {
const {gen, schemaCode, schemaType, def, it} = this
return or(wrong$DataType(), invalid$DataSchema())
function wrong$DataType(): Code {
- 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 validateOneOf
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function validateOneOf(): void {
schArr.forEach((sch: AnySchema, i: number) => {
let schCxt: SchemaCxt | undefined
if (alwaysValidSchema(it, sch)) {
gen.var(schValid, true)