kahwee/backbone-deep-model

View on GitHub

Showing 7 of 7 total issues

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

    set: function(key, val, options) {
        var attr, attrs, unset, changes, silent, changing, prev, current;
        if (key == null) return this;

        // Handle both `"key", value` and `{key: value}` -style arguments.
Severity: Minor
Found in src/index.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 setNested has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

function setNested(obj, path, val, options) {
    options = options || {};

    var separator = DeepModel.keyPathSeparator;

Severity: Minor
Found in src/index.js - About 3 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 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    set: function(key, val, options) {
        var attr, attrs, unset, changes, silent, changing, prev, current;
        if (key == null) return this;

        // Handle both `"key", value` and `{key: value}` -style arguments.
Severity: Major
Found in src/index.js - About 2 hrs to fix

    Function getNested has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    function getNested(obj, path, return_exists) {
        var separator = DeepModel.keyPathSeparator;
    
        var fields = path ? path.split(separator) : [];
        var result = obj;
    Severity: Minor
    Found in src/index.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 objToPaths has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function objToPaths(obj) {
        var ret = {},
            separator = DeepModel.keyPathSeparator;
    
        for (var key in obj) {
    Severity: Minor
    Found in src/index.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 changedAttributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        changedAttributes: function(diff) {
            //<custom code>: objToPaths
            if (!diff) return this.hasChanged() ? objToPaths(this.changed) : false;
            //</custom code>
    
    
    Severity: Minor
    Found in src/index.js - About 35 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 result;
    Severity: Major
    Found in src/index.js - About 30 mins to fix
      Severity
      Category
      Status
      Source
      Language