mikro-orm/mikro-orm

View on GitHub
packages/core/src/serialization/EntityTransformer.ts

Summary

Maintainability
B
5 hrs
Test Coverage
A
100%

Function processProperty has a Cognitive Complexity of 14 (exceeds 7 allowed). Consider refactoring.
Open

  private static processProperty<Entity extends object>(prop: EntityKey<Entity>, entity: Entity, raw: boolean, populated: boolean): EntityValue<Entity> | undefined {
    const wrapped = helper(entity);
    const property = wrapped.__meta.properties[prop];
    const serializer = property?.serializer;
    const value = entity[prop];
Severity: Minor
Found in packages/core/src/serialization/EntityTransformer.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 toObject has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring.
Open

  static toObject<Entity extends object, Ignored extends EntityKey<Entity> = never>(entity: Entity, ignoreFields: Ignored[] = [], raw = false): Omit<EntityDTO<Entity>, Ignored> {
    if (!Array.isArray(ignoreFields)) {
      ignoreFields = [];
    }

Severity: Minor
Found in packages/core/src/serialization/EntityTransformer.ts - About 55 mins 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 processEntity has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
Open

  private static processEntity<Entity extends object>(prop: keyof Entity, entity: Entity, platform: Platform, raw: boolean, populated: boolean): EntityValue<Entity> | undefined {
    const child = entity[prop] as unknown as Entity | Reference<Entity>;
    const wrapped = helper(child as Entity);
    const meta = wrapped.__meta;
    const visible = meta.primaryKeys.filter(prop => isVisible(meta, prop));
Severity: Minor
Found in packages/core/src/serialization/EntityTransformer.ts - About 45 mins 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

Avoid too many return statements within this function.
Open

    return value;
Severity: Major
Found in packages/core/src/serialization/EntityTransformer.ts - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

          return wrapped.__platform.normalizePrimaryKey(value as unknown as IPrimaryKey) as unknown as EntityValue<Entity>;
    Severity: Major
    Found in packages/core/src/serialization/EntityTransformer.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            return customType.toJSON(value, wrapped.__platform);
      Severity: Major
      Found in packages/core/src/serialization/EntityTransformer.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return wrapped ? wrapped.toJSON() as EntityValue<Entity> : value;
        Severity: Major
        Found in packages/core/src/serialization/EntityTransformer.ts - About 30 mins to fix

          There are no issues that match your filters.

          Category
          Status