diaspora-orm/diaspora

View on GitHub

Showing 15 of 46 total issues

File entity.ts has 339 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { keys, reduce, isNil, cloneDeep, difference, forEach, castArray, isUndefined, isNull, defaults, chain, isEqual, mapValues, isObject, isString, isInteger, slice, concat, uniq, reject, transform, isEmpty, without, values } from 'lodash';
import { SequentialEvent } from 'sequential-event';

import { Adapter } from '../adapters';
import AAdapterEntity = Adapter.Base.AAdapterEntity;
Severity: Minor
Found in src/entities/entity.ts - About 4 hrs to fix

Entity has 29 functions (exceeds 20 allowed). Consider refactoring.
Open

export abstract class Entity<TEntity extends IEntityAttributes> extends SequentialEvent {
    public get attributes() {
        return this.getAttributes();
    }
    
Severity: Minor
Found in src/entities/entity.ts - About 3 hrs to fix

File dataAccessLayer.ts has 298 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { isString, isNumber, map, isNil, Dictionary, chain, castArray, forEach } from 'lodash';

import { Adapter as _Base } from './base';
import AAdapterEntity = _Base.Base.AAdapterEntity;
import AAdapter = _Base.Base.AAdapter;
Severity: Minor
Found in src/adapters/dataAccessLayer.ts - About 3 hrs to fix

File adapter.ts has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { pick, assign, isNil, cloneDeep, forOwn, defaults, mapKeys, forEach, isNumber, isDate, chain, isUndefined, Dictionary, invert, first, compact, mapValues } from 'lodash';
import { SequentialEvent } from 'sequential-event';

import { Adapter as _AAdapterEntity } from './entity';
import AAdapterEntity = _AAdapterEntity.Base.AAdapterEntity;
Severity: Minor
Found in src/adapters/base/adapter.ts - About 2 hrs to fix

File adapter.ts has 273 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { map, forIn, assign, omit, isArray, isUndefined, isNil, get } from 'lodash';

import { Adapter as _AAdapter } from '../base';
import AAdapter = _AAdapter.Base.AAdapter;
import { Adapter as _WebApiEntity } from './entity';
Severity: Minor
Found in src/adapters/webApi/adapter.ts - About 2 hrs to fix

DataAccessLayer has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

    export class DataAccessLayer<
        TEntity extends AAdapterEntity = AAdapterEntity,
        TAdapter extends AAdapter<TEntity> = AAdapter<TEntity>
    > extends SequentialEvent implements IDataSourceQuerier<
        TEntity,
Severity: Minor
Found in src/adapters/dataAccessLayer.ts - About 2 hrs to fix

AAdapter has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

    export abstract class AAdapter<TAdapterEntity extends AAdapterEntity = AAdapterEntity>
    extends SequentialEvent
    implements IDataSourceQuerier<IEntityAttributes, IEntityProperties> {
        public get classEntity() {
            return this._classEntity;
Severity: Minor
Found in src/adapters/base/adapter.ts - About 2 hrs to fix

File checkTransformer.ts has 262 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { get, isInteger, map, isEmpty, some, isNil, compact, flatten, values, every, chain, assign, defaults, forEach, Dictionary, isString, isNumber, isDate, isBoolean, isObject, isArray, castArray, mapValues, omitBy } from 'lodash';

import { EntityTransformers as EntityTransformers_EntityTransformer } from './entityTransformer';
import EntityTransformer = EntityTransformers_EntityTransformer.AEntityTransformer;
import { PathStack } from './pathStack';
Severity: Minor
Found in src/entityTransformers/checkTransformer.ts - About 2 hrs to fix

Model has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

export class Model<TEntity extends IEntityAttributes> {
    public attributes: { [key: string]: _ModelDescription.FieldDescriptor };
    
    private readonly _dataSources: IDataSourceRegistry;
    public modelDesc: _ModelDescription.IModelDescription;
Severity: Minor
Found in src/model.ts - About 2 hrs to fix

Function applyField has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public applyField(
            value: any,
            propPath: PathStack | string[],
            options: { getProps: boolean } = { getProps: false }
        ): any {
Severity: Minor
Found in src/entityTransformers/defaultTransformer.ts - About 1 hr to fix

Function constructor has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public constructor() {
        const voidFct = () => {
            return;
        };
        super( {
Severity: Minor
Found in src/logger/browserLogger.ts - About 1 hr to fix

Function applyField has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring.
Open

        public applyField(
            value: any,
            propPath: PathStack | string[],
            options: { getProps: boolean } = { getProps: false }
        ): any {
Severity: Minor
Found in src/entityTransformers/defaultTransformer.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 EFieldType.ARRAY has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            [EFieldType.ARRAY](
                this: CheckTransformer,
                keys: PathStack,
                fieldDesc: _ModelDescription.FieldDescriptor.IArrayFieldDescriptor,
                values: any[]
Severity: Minor
Found in src/entityTransformers/checkTransformer.ts - About 1 hr to fix

Function DefaultQueryTransformerFactory has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    export const DefaultQueryTransformerFactory: IEventProviderFactory = (
        config: any
    ) => {
        /**
         * Get the plural name of an endpoint.
Severity: Minor
Found in src/adapters/webApi/defaultQueryTransformer.ts - About 1 hr to fix

Function persist has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public async persist( sourceName?: string ): Promise<Set<TEntity>> {
        const suffixes = map( this, entity => ( 'orphan' === entity.state ? 'Create' : 'Update' ) );
        const _allEmit = partial( allEmit, this );
        await _allEmit( 'Persist', 'before' );
        await _allEmit( 'Validate', 'before' );
Severity: Minor
Found in src/entities/set.ts - About 1 hr to fix
Severity
Category
Status
Source
Language