Showing 33 of 33 total issues
Function validateProperty
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
validateProperty<T extends object>(prop: EntityProperty, givenValue: any, entity: T) {
if (givenValue === null || givenValue === undefined) {
return givenValue;
}
- 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 foreign
has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring. Open
foreign(this: any, foreignInfo: Dictionary) {
foreignInfo.column = Array.isArray(foreignInfo.column)
? foreignInfo.column
: [foreignInfo.column];
foreignInfo.column = foreignInfo.column.map((column: unknown) =>
- 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
Avoid too many return
statements within this function. Open
return entity[prop.name] = validator.validateProperty(prop, value, entity);
Avoid too many return
statements within this function. Open
return wrapped ? wrapped.toJSON() as EntityValue<Entity> : value;
Avoid too many return
statements within this function. Open
return customType.toJSON(value, wrapped.__platform);
Avoid too many return
statements within this function. Open
return meta.properties[k].customType!.convertToJSValue(data[k], this.platform);
Avoid too many return
statements within this function. Open
return data[k];
Avoid too many return
statements within this function. Open
return EntityAssigner.assignEmbeddable(entity, value, prop, options.em, options);
Avoid too many return
statements within this function. Open
return value;
Avoid too many return
statements within this function. Open
return wrapped.__platform.normalizePrimaryKey(value as unknown as IPrimaryKey) as unknown as EntityValue<Entity>;
Function initPropertyType
has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring. Open
protected initPropertyType(meta: EntityMetadata, prop: EntityProperty) {
const type = Reflect.getMetadata('design:type', meta.prototype, prop.name);
if (!prop.type && (!type || (type === Object && prop.kind !== ReferenceKind.SCALAR)) && !(prop.enum && (prop.items?.length ?? 0) > 0)) {
throw new Error(`Please provide either 'type' or 'entity' attribute in ${meta.className}.${prop.name}. If you are using decorators, ensure you have 'emitDecoratorMetadata' enabled in your tsconfig.json.`);
- 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 isMarkedAsPopulated
has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring. Open
isMarkedAsPopulated(entityName: string, prop: string): boolean {
let populate: PopulateOptions<T>[] | undefined = this.populate;
for (const segment of this.path) {
if (!populate) {
- 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 initProperties
has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring. Open
protected initProperties(meta: EntityMetadata): void {
// load types and column names
for (const prop of meta.props) {
if (typeof prop.entity === 'string') {
prop.type = prop.entity;
- 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"