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},
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") {
Function schemaKeywords
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function schemaKeywords(
it: SchemaObjCxt,
types: JSONType[],
typeErrors: boolean,
errsCount?: Name
- 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 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) : []
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)
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)
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)
- 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 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
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"`)
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')
}
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++) {
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"))
}
- 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 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)
- 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 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)
Function compileSerializer
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function compileSerializer(
this: Ajv,
sch: SchemaEnv,
definitions: SchemaObjectMap
): SchemaEnv {
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"))
}
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
Function compileParser
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function compileParser(
this: Ajv,
sch: SchemaEnv,
definitions: SchemaObjectMap
): SchemaEnv {
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)) {
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()