aristath/kirki

View on GitHub
packages/kirki-framework/module-field-dependencies/src/script.js

Summary

Maintainability
D
2 days
Test Coverage

Function evaluate has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    evaluate: function( value1, value2, operator, choice ) {
        var found = false;

        if ( choice && 'object' === typeof value2 ) {
            value2 = value2[ choice ];
Severity: Minor
Found in packages/kirki-framework/module-field-dependencies/src/script.js - About 4 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 evaluate has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    evaluate: function( value1, value2, operator, choice ) {
        var found = false;

        if ( choice && 'object' === typeof value2 ) {
            value2 = value2[ choice ];
Severity: Major
Found in packages/kirki-framework/module-field-dependencies/src/script.js - About 2 hrs to fix

Function checkCondition has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    checkCondition: function( requirement, control, isOption, relation ) {
        var self          = this,
            childRelation = ( 'AND' === relation ) ? 'OR' : 'AND',
            nestedItems,
            value,
Severity: Minor
Found in packages/kirki-framework/module-field-dependencies/src/script.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 checkCondition has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    checkCondition: function( requirement, control, isOption, relation ) {
        var self          = this,
            childRelation = ( 'AND' === relation ) ? 'OR' : 'AND',
            nestedItems,
            value,
Severity: Minor
Found in packages/kirki-framework/module-field-dependencies/src/script.js - About 1 hr to fix

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

    init: function() {
        var self = this;

        _.each( window.kirkiControlDependencies, function( requires, controlID ) {
            var control = wp.customize.control( controlID );
Severity: Minor
Found in packages/kirki-framework/module-field-dependencies/src/script.js - About 1 hr to fix

Function showKirkiControl has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    showKirkiControl: function( control ) {
        var self     = this,
            show     = true,
            isOption = (
                control.params && // Check if control.params exists.
Severity: Minor
Found in packages/kirki-framework/module-field-dependencies/src/script.js - 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 value2 >= value1;
Severity: Major
Found in packages/kirki-framework/module-field-dependencies/src/script.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                return found;
Severity: Major
Found in packages/kirki-framework/module-field-dependencies/src/script.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return ( ! this.evaluate( value1, value2, 'contains', choice ) );
Severity: Major
Found in packages/kirki-framework/module-field-dependencies/src/script.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return value2 > value1;
Severity: Major
Found in packages/kirki-framework/module-field-dependencies/src/script.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                return -1 < value1.indexOf( value2 );
Severity: Major
Found in packages/kirki-framework/module-field-dependencies/src/script.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                return found;
Severity: Major
Found in packages/kirki-framework/module-field-dependencies/src/script.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                    return ( -1 < value1.indexOf( value2 ) && -1 < value2.indexOf( value1 ) );
Severity: Major
Found in packages/kirki-framework/module-field-dependencies/src/script.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                return found;
Severity: Major
Found in packages/kirki-framework/module-field-dependencies/src/script.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return value1 == value2;
Severity: Major
Found in packages/kirki-framework/module-field-dependencies/src/script.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return value2 <= value1;
Severity: Major
Found in packages/kirki-framework/module-field-dependencies/src/script.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return value2 < value1;
Severity: Major
Found in packages/kirki-framework/module-field-dependencies/src/script.js - About 30 mins to fix

There are no issues that match your filters.

Category
Status