aristath/kirki

View on GitHub

Showing 644 of 644 total issues

Function add_sub_fields has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private function add_sub_fields( $args ) {

        $args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : 'global';

        $defaults = isset( $args['default'] ) ? $args['default'] : [];
Severity: Minor
Found in packages/kirki-framework/field-typography/src/Field/Typography.php - 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 add_settings has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    final function add_settings( $args = [] ) {

        // Get the classname we'll be using to create our setting(s).
        $classname = false;
        if ( isset( $args['option_type'] ) && array_key_exists( $args['option_type'], $this->setting_types ) ) {
Severity: Minor
Found in packages/kirki-framework/compatibility/src/Settings.php - 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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

      if (2 === val.length) {
        if (!val.includes("#") && !val.includes("rg") && !val.includes("hs")) {
          val = "#" + val;
        }
      } else if (3 === val.length || 6 === val.length) {
packages/kirki-framework/control-react-colorful/src/js/components/KirkiReactColorfulInput.js on lines 16..20

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 60.

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

Function runHooks has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  return function runHooks(hookName) {
    if (!hooks[hookName]) {
      hooks[hookName] = {
        handlers: [],
        runs: 0
Severity: Minor
Found in packages/kirki-framework/compatibility/src/scripts/hooks.js - About 1 hr to fix

Function postfix has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function postfix( expression ) {
    var terms = [],
        stack = [],
        match, operator, term, element;

Severity: Minor
Found in packages/kirki-framework/compatibility/src/scripts/i18n.js - About 1 hr to fix

Function updateClassName has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  DomHelper.prototype.updateClassName = function (e, opt_add, opt_remove) {
    var add = opt_add || [],
        remove = opt_remove || [];

    var classes = e.className.split(/\s+/);

Method init_filesystem has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function init_filesystem() {
        $credentials = [];

        if ( ! defined( 'FS_METHOD' ) ) {
            define( 'FS_METHOD', 'direct' );
Severity: Minor
Found in packages/kirki-framework/util/src/Helper.php - About 1 hr to fix

Method default_control_types has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function default_control_types( $control_types = [] ) {
        $this->control_types = [
            'kirki-composite'       => '\Kirki\Control\Composite',
            'checkbox'              => '\Kirki\Control\Checkbox',
            'kirki-color'           => '\Kirki\Control\ReactColorful',
Severity: Minor
Found in packages/kirki-framework/compatibility/src/Init.php - About 1 hr to fix

Function exports has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function (TYPE, $create) {
  var IS_MAP = TYPE == 1;
  var IS_FILTER = TYPE == 2;
  var IS_SOME = TYPE == 3;
  var IS_EVERY = TYPE == 4;
Severity: Minor
Found in packages/kirki-framework/compatibility/src/scripts/wp-polyfill.js - About 1 hr to fix

Method getLoader has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function getLoader()
    {
        if (null !== self::$loader) {
            return self::$loader;
        }
Severity: Minor
Found in packages/composer/autoload_real.php - About 1 hr to fix

Function run has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    var run = function (reaction) {
      var handler = ok ? reaction.ok : reaction.fail;
      var resolve = reaction.resolve;
      var reject = reaction.reject;
      var domain = reaction.domain;
Severity: Minor
Found in packages/kirki-framework/compatibility/src/scripts/wp-polyfill.js - About 1 hr to fix

Function parse has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  FontApiParser.prototype.parse = function() {
    var length = this.fontFamilies_.length;

    for (var i = 0; i < length; i++) {
      var elements = this.fontFamilies_[i].split(":");

Method field_add_control_args has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function field_add_control_args( $args ) {
        if ( isset( $args['active_callback'] ) ) {
            if ( is_array( $args['active_callback'] ) ) {
                if ( ! is_callable( $args['active_callback'] ) ) {

Function getSubstitution has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {
    var tailPos = position + matched.length;
    var m = captures.length;
    var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
    if (namedCaptures !== undefined) {
Severity: Minor
Found in packages/kirki-framework/compatibility/src/scripts/wp-polyfill.js - About 1 hr to fix

Method addPsr4 has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function addPsr4($prefix, $paths, $prepend = false)
    {
        if (!$prefix) {
            // Register directories for the root namespace.
            if ($prepend) {
Severity: Minor
Found in packages/composer/ClassLoader.php - About 1 hr to fix

Function kirkiTooltipAdd has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function kirkiTooltipAdd( control ) {
    _.each( kirkiTooltips, function ( tooltip ) {
        if ( tooltip.id !== control.id ) {
            return;
        }
Severity: Minor
Found in packages/kirki-framework/module-tooltips/src/control.js - About 1 hr to fix

Method add has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function add($prefix, $paths, $prepend = false)
    {
        if (!$prefix) {
            if ($prepend) {
                $this->fallbackDirsPsr0 = array_merge(
Severity: Minor
Found in packages/composer/ClassLoader.php - About 1 hr to fix

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

        control.container.on( 'click keypress', '.repeater-field-image .upload-button,.repeater-field-cropped_image .upload-button,.repeater-field-upload .upload-button', function( e ) {
            e.preventDefault();
            control.$thisButton = jQuery( this );
            control.openFrame( e );
        } );
Severity: Major
Found in packages/kirki-framework/control-repeater/src/control.js and 1 other location - About 1 hr to fix
packages/kirki-framework/control-repeater/src/control.js on lines 149..153

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 59.

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 2 locations. Consider refactoring.
Open

        control.container.on( 'click keypress', '.repeater-field-image .remove-button,.repeater-field-cropped_image .remove-button', function( e ) {
            e.preventDefault();
            control.$thisButton = jQuery( this );
            control.removeImage( e );
        } );
Severity: Major
Found in packages/kirki-framework/control-repeater/src/control.js and 1 other location - About 1 hr to fix
packages/kirki-framework/control-repeater/src/control.js on lines 143..147

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 59.

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

Method content_template has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function content_template() {
        ?>

        <div class="kirki-switch-control kirki-{{ data.checkboxType }}">
            <# if ( data.label || data.description ) { #>
Severity
Category
Status
Source
Language