infinum/mobx-collection-store

View on GitHub
src/Model.ts

Summary

Maintainability
C
1 day
Test Coverage

File Model.ts has 300 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  action, computed, extendObservable,
  IArrayChange, IArraySplice, IComputedValue,
  intercept, IObservableArray, IObservableObject,
  isObservableArray, observable, toJS,
Severity: Minor
Found in src/Model.ts - About 3 hrs to fix

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

    export class Model implements IModel {
    
      /**
       * The attribute that should be used as the unique identifier
       *
    Severity: Minor
    Found in src/Model.ts - About 3 hrs to fix

      Function constructor has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        constructor(initialData: object = {}, opts?: IOpts|Collection, collection?: Collection) {
          const data = assign({}, this.static.defaults, this.static.preprocess(initialData));
      
          let collectionInstance = collection;
          const idAttribute = this.static.idAttribute;
      Severity: Minor
      Found in src/Model.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 __setRef has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        private __setRef<T>(ref: string, val: T|Array<T>): IModel|Array<IModel> {
          const isArray = val instanceof Array || isObservableArray(val);
          const hasModelInstances = isArray
            ? (val as Array<T>).some((item) => item instanceof Model)
            : val instanceof Model;
      Severity: Minor
      Found in src/Model.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 __ensureId has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        private __ensureId(data: IDictionary, collection?: ICollection) {
          const idAttribute = this.static.idAttribute;
          const id = getProp<string|number>(data, idAttribute);
          if (!id) {
            if (!this.static.enableAutoId) {
      Severity: Minor
      Found in src/Model.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

      TODO found
      Open

            // TODO: Could be optimised based on __initializedProps?
      Severity: Minor
      Found in src/Model.ts by fixme

      TODO found
      Open

          // TODO: Could be optimised based on __initializedProps?
      Severity: Minor
      Found in src/Model.ts by fixme

      There are no issues that match your filters.

      Category
      Status