felixarntz/plugin-lib

View on GitHub

Showing 821 of 821 total issues

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

( function( exports, $, _, Backbone, wp, fieldsAPIData ) {
    'use strict';

    _.mixin({
        alias: function( alias, func ) {
Severity: Major
Found in assets/dist/js/fields.js and 1 other location - About 3 mos to fix
assets/src/js/fields.js on lines 1..1689

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

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

( function( exports, $, _, Backbone, wp, fieldsAPIData ) {
    'use strict';

    _.mixin({
        alias: function( alias, func ) {
Severity: Major
Found in assets/src/js/fields.js and 1 other location - About 3 mos to fix
assets/dist/js/fields.js on lines 6..1694

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

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

( function( $, pluginLibData ) {
    'use strict';

    $( '.submitdelete' ).on( 'click', function( e ) {
        if ( ! window.confirm( pluginLibData.i18n.confirm_deletion ) ) {
Severity: Major
Found in assets/dist/js/edit-model.js and 1 other location - About 1 wk to fix
assets/src/js/edit-model.js on lines 1..250

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

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

( function( $, pluginLibData ) {
    'use strict';

    $( '.submitdelete' ).on( 'click', function( e ) {
        if ( ! window.confirm( pluginLibData.i18n.confirm_deletion ) ) {
Severity: Major
Found in assets/src/js/edit-model.js and 1 other location - About 1 wk to fix
assets/dist/js/edit-model.js on lines 6..255

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

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

File fields.js has 1303 lines of code (exceeds 250 allowed). Consider refactoring.
Open

( function( exports, $, _, Backbone, wp, fieldsAPIData ) {
    'use strict';

    _.mixin({
        alias: function( alias, func ) {
Severity: Major
Found in assets/src/js/fields.js - About 3 days to fix

    File fields.js has 1303 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*!
     * plugin-lib (https://github.com/felixarntz/plugin-lib)
     * By Felix Arntz (https://leaves-and-love.net)
     * Licensed under GPL-2.0-or-later
     */
    Severity: Major
    Found in assets/dist/js/fields.js - About 3 days to fix

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

      <?php
      /**
       * Model status manager class for Core objects
       *
       * @package Leaves_And_Love\Plugin_Lib
      src/db-objects/model-type-managers/core-model-type-manager.php on lines 1..230

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

      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

      <?php
      /**
       * Model type manager class for Core objects
       *
       * @package Leaves_And_Love\Plugin_Lib
      Severity: Major
      Found in src/db-objects/model-type-managers/core-model-type-manager.php and 1 other location - About 3 days to fix
      src/db-objects/model-status-managers/core-model-status-manager.php on lines 1..230

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

      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

      <?php
      /**
       * Model status class for a Core object
       *
       * @package Leaves_And_Love\Plugin_Lib
      Severity: Major
      Found in src/db-objects/model-statuses/core-model-status.php and 1 other location - About 2 days to fix
      src/db-objects/model-types/core-model-type.php on lines 1..163

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

      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

      <?php
      /**
       * Model type class for a Core object
       *
       * @package Leaves_And_Love\Plugin_Lib
      Severity: Major
      Found in src/db-objects/model-types/core-model-type.php and 1 other location - About 2 days to fix
      src/db-objects/model-statuses/core-model-status.php on lines 1..163

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

      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 maybe_route_request has a Cognitive Complexity of 104 (exceeds 5 allowed). Consider refactoring.
      Open

              protected function maybe_route_request( $parse_request, $wp, $extra_query_vars ) {
                  if ( is_admin() || ! $parse_request ) {
                      return $parse_request;
                  }
      
      
      Severity: Minor
      Found in src/router.php - About 2 days 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

      File rest-models-controller.php has 760 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * REST models controller class
       *
       * @package Leaves_And_Love\Plugin_Lib
      Severity: Major
      Found in src/db-objects/rest-models-controller.php - About 1 day to fix

        File model-edit-page.php has 667 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * Edit page class
         *
         * @package Leaves_And_Love\Plugin_Lib
        Severity: Major
        Found in src/db-objects/model-edit-page.php - About 1 day to fix

          File field.php has 613 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          /**
           * Field base class
           *
           * @package Leaves_And_Love\Plugin_Lib
          Severity: Major
          Found in src/fields/field.php - About 1 day to fix

            File field-manager.php has 533 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            /**
             * Field_Manager class
             *
             * @package Leaves_And_Love\Plugin_Lib
            Severity: Major
            Found in src/fields/field-manager.php - About 1 day to fix

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

                      public function maybe_transition_type_property( $result, $model ) {
                          if ( is_wp_error( $result ) && in_array( $result->get_error_code(), array( 'db_insert_error', 'db_update_error' ), true ) ) {
                              return $result;
                          }
              
              
              Severity: Major
              Found in src/db-objects/traits/type-manager-trait.php and 1 other location - About 1 day to fix
              src/db-objects/traits/status-manager-trait.php on lines 141..174

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

              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

                      public function maybe_transition_status_property( $result, $model ) {
                          if ( is_wp_error( $result ) && in_array( $result->get_error_code(), array( 'db_insert_error', 'db_update_error' ), true ) ) {
                              return $result;
                          }
              
              
              Severity: Major
              Found in src/db-objects/traits/status-manager-trait.php and 1 other location - About 1 day to fix
              src/db-objects/traits/type-manager-trait.php on lines 141..174

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

              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 validate has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
              Open

                      public function validate( $value = null ) {
                          $this->maybe_resolve_dependencies();
              
                          if ( false === $this->display ) {
                              return $value;
              Severity: Minor
              Found in src/fields/field.php - About 1 day 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 get_items has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
              Open

                      public function get_items( $request ) {
                          $registered_args = $this->get_collection_params();
              
                          $args = array();
              
              
              Severity: Minor
              Found in src/db-objects/rest-models-controller.php - About 7 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

              File models-list-table.php has 495 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              /**
               * List table class
               *
               * @package Leaves_And_Love\Plugin_Lib
              Severity: Minor
              Found in src/db-objects/models-list-table.php - About 7 hrs to fix
                Severity
                Category
                Status
                Source
                Language