Gapminder/vizabi

View on GitHub
src/base/model.js

Summary

Maintainability
F
3 days
Test Coverage

File model.js has 447 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import * as utils from "base/utils";
import EventSource, { DefaultEvent, ChangeEvent } from "base/events";
import Intervals from "base/intervals";

const ModelLeaf = EventSource.extend({
Severity: Minor
Found in src/base/model.js - About 6 hrs to fix

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

    const Model = EventSource.extend({
    
      getClassDefaults: () => ({}),
    
      /**
    Severity: Minor
    Found in src/base/model.js - About 5 hrs to fix

      Function set has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

        set(attr, val, force, persistent, caller) {
          const setting = this._setting;
          let attrs;
          let freezeCall = false; // boolean, indicates if this .set()-call froze the modelTree
      
      
      Severity: Minor
      Found in src/base/model.js - About 5 hrs 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 set has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        set(attr, val, force, persistent, caller) {
          const setting = this._setting;
          let attrs;
          let freezeCall = false; // boolean, indicates if this .set()-call froze the modelTree
      
      
      Severity: Major
      Found in src/base/model.js - About 2 hrs to fix

        Function initSubmodel has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        function initSubmodel(attr, val, ctx, persistent) {
        
          let submodel;
        
          // if value is a value -> leaf
        Severity: Minor
        Found in src/base/model.js - 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 initSubmodel has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function initSubmodel(attr, val, ctx, persistent) {
        
          let submodel;
        
          // if value is a value -> leaf
        Severity: Minor
        Found in src/base/model.js - About 1 hr to fix

          Function init has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            init(name, value, parent, binds, persistent) {
          Severity: Minor
          Found in src/base/model.js - About 35 mins to fix

            Function set has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              set(attr, val, force, persistent, caller) {
            Severity: Minor
            Found in src/base/model.js - About 35 mins to fix

              Function setReady has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                setReady(value) {
                  if (value === false) {
                    this._ready = false;
                    if (this._parent && this._parent.setReady) {
                      this._parent.setReady(false);
              Severity: Minor
              Found in src/base/model.js - About 25 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

              There are no issues that match your filters.

              Category
              Status