aristath/kirki

View on GitHub

Showing 644 of 644 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    public static function getPrettyVersion($packageName)
    {
        foreach (self::getInstalled() as $installed) {
            if (!isset($installed['versions'][$packageName])) {
                continue;
Severity: Major
Found in packages/composer/InstalledVersions.php and 2 other locations - About 45 mins to fix
packages/composer/InstalledVersions.php on lines 153..168
packages/composer/InstalledVersions.php on lines 195..210

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 96.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    public static function getReference($packageName)
    {
        foreach (self::getInstalled() as $installed) {
            if (!isset($installed['versions'][$packageName])) {
                continue;
Severity: Major
Found in packages/composer/InstalledVersions.php and 2 other locations - About 45 mins to fix
packages/composer/InstalledVersions.php on lines 153..168
packages/composer/InstalledVersions.php on lines 174..189

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 96.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Avoid deeply nested control flow statements.
Open

                                    if ( 'background-color' === property ) {
                                        processedValue = 'unset';
                                    } else if ( 'background-image' === property ) {
                                        processedValue = 'none';
                                    }
Severity: Major
Found in packages/kirki-framework/module-postmessage/src/postMessage.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                                if ( 'background-color' === output.property ) {
                                    processedValue = 'unset';
                                } else if ( 'background-image' === output.property ) {
                                    processedValue = 'none';
                                }
Severity: Major
Found in packages/kirki-framework/module-postmessage/src/postMessage.js - About 45 mins to fix

Function exports has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
Severity: Minor
Found in packages/kirki-framework/compatibility/src/scripts/wp-polyfill.js - About 45 mins to fix

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

},{"40":40,"67":67}],168:[function(_dereq_,module,exports){
// 20.2.2.17 Math.hypot([value1[, value2[, … ]]])
var $export = _dereq_(40);
var abs = Math.abs;

Severity: Minor
Found in packages/kirki-framework/compatibility/src/scripts/wp-polyfill.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 deeply nested control flow statements.
Open

                        if ( ! _.isUndefined( control.params.fields[ this.label.field ].type ) ) {
                            if ( 'select' === control.params.fields[ this.label.field ].type ) {
                                if ( ! _.isUndefined( control.params.fields[ this.label.field ].choices ) && ! _.isUndefined( control.params.fields[ this.label.field ].choices[ rowLabelField.val() ] ) ) {
                                    rowLabel = control.params.fields[ this.label.field ].choices[ rowLabelField.val() ];
                                }
Severity: Major
Found in packages/kirki-framework/control-repeater/src/control.js - About 45 mins to fix

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

function set(view, bytes, index, conversion, value, isLittleEndian) {
Severity: Minor
Found in packages/kirki-framework/compatibility/src/scripts/wp-polyfill.js - About 45 mins 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

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

},{"109":109,"117":117,"35":35}],109:[function(_dereq_,module,exports){
'use strict';
var toInteger = _dereq_(115);
var defined = _dereq_(35);

Severity: Minor
Found in packages/kirki-framework/compatibility/src/scripts/wp-polyfill.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

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

},{"113":113,"117":117,"118":118}],18:[function(_dereq_,module,exports){
// 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
'use strict';
var toObject = _dereq_(118);
var toAbsoluteIndex = _dereq_(113);
Severity: Minor
Found in packages/kirki-framework/compatibility/src/scripts/wp-polyfill.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

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

},{"35":35}],119:[function(_dereq_,module,exports){
// 7.1.1 ToPrimitive(input [, PreferredType])
var isObject = _dereq_(57);
// instead of the ES6 spec version, we didn't implement @@toPrimitive case
// and the second argument - flag - preferred type is a string
Severity: Minor
Found in packages/kirki-framework/compatibility/src/scripts/wp-polyfill.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

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

},{"107":107}],241:[function(_dereq_,module,exports){
var $export = _dereq_(40);
var toAbsoluteIndex = _dereq_(113);
var fromCharCode = String.fromCharCode;
var $fromCodePoint = String.fromCodePoint;
Severity: Minor
Found in packages/kirki-framework/compatibility/src/scripts/wp-polyfill.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

Function mustBeCropped has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    mustBeCropped: function( flexW, flexH, dstW, dstH, imgW, imgH ) {
Severity: Minor
Found in packages/kirki-framework/control-repeater/src/control.js - About 45 mins to fix

Function getSubstitution has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {
Severity: Minor
Found in packages/kirki-framework/compatibility/src/scripts/wp-polyfill.js - About 45 mins to fix

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

},{"35":35,"40":40,"42":42}],108:[function(_dereq_,module,exports){
// https://github.com/tc39/proposal-string-pad-start-end
var toLength = _dereq_(117);
var repeat = _dereq_(109);
var defined = _dereq_(35);
Severity: Minor
Found in packages/kirki-framework/compatibility/src/scripts/wp-polyfill.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 deeply nested control flow statements.
Open

        else if (res) switch (TYPE) {
          case 3: return true;             // some
          case 5: return val;              // find
          case 6: return index;            // findIndex
          case 2: result.push(val);        // filter
Severity: Major
Found in packages/kirki-framework/compatibility/src/scripts/wp-polyfill.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if (arg == undefined) {
                            throw new Error(sprintf('[sprintf] Cannot access property "%s" of undefined value "%s"', ph.keys[k], ph.keys[k-1]))
                        }
Severity: Major
Found in packages/kirki-framework/compatibility/src/scripts/i18n.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

    if (explicit) for (key in $iterators) if (!proto[key]) redefine(proto, key, $iterators[key], true);
Severity: Major
Found in packages/kirki-framework/compatibility/src/scripts/wp-polyfill.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

          } else if (hasFinally) {
            if (this.prev < entry.finallyLoc) {
              return handle(entry.finallyLoc);
            }

Severity: Major
Found in packages/kirki-framework/compatibility/src/scripts/wp-polyfill.js - About 45 mins to fix
Severity
Category
Status
Source
Language