felixarntz/plugin-lib

View on GitHub

Showing 458 of 821 total issues

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

      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

              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

                File query.php has 481 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                /**
                 * Query class
                 *
                 * @package Leaves_And_Love\Plugin_Lib
                Severity: Minor
                Found in src/db-objects/query.php - About 7 hrs to fix

                  Function prepare_item_for_database has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
                  Open

                          protected function prepare_item_for_database( $request ) {
                              $primary_property = $this->manager->get_primary_property();
                  
                              if ( isset( $request[ $primary_property ] ) ) {
                                  $model = $this->manager->get( $request[ $primary_property ] );
                  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

                  Function build_views has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
                  Open

                          protected function build_views( &$current, $list_url = '' ) {
                              $capabilities = $this->manager->capabilities();
                  
                              $current = 'all';
                              $total   = 0;
                  Severity: Minor
                  Found in src/db-objects/models-list-table.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

                  Function map_capabilities has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
                  Open

                          public function map_capabilities( $mode ) {
                              $this->capability_mappings = array();
                  
                              if ( $mode ) {
                                  $this->capability_mappings[ $this->meta_capabilities['read_item'] ]   = array( $this, 'map_read_item' );
                  Severity: Minor
                  Found in src/db-objects/capabilities.php - About 6 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 build_query_params has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
                  Open

                          protected function build_query_params( $number, $offset ) {
                              $query_params = array(
                                  'number' => $number,
                                  'offset' => $offset,
                              );
                  Severity: Minor
                  Found in src/db-objects/models-list-table.php - About 6 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 get_model_permalink has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
                  Open

                          public function get_model_permalink( $model ) {
                              if ( method_exists( $this->manager, 'get_status_property' ) ) {
                                  $status_property = $this->manager->get_status_property();
                                  if ( ! in_array( $model->$status_property, $this->manager->statuses()->get_public(), true ) ) {
                                      return '';
                  Severity: Minor
                  Found in src/db-objects/view-routing.php - About 6 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 view-routing.php has 446 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  /**
                   * View_Routing manager class
                   *
                   * @package Leaves_And_Love\Plugin_Lib
                  Severity: Minor
                  Found in src/db-objects/view-routing.php - About 6 hrs to fix

                    Field has 45 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                        abstract class Field {
                            /**
                             * Field manager instance.
                             *
                             * @since 1.0.0
                    Severity: Minor
                    Found in src/fields/field.php - About 6 hrs to fix

                      Function action_edit has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
                      Open

                              protected function action_edit( $id ) {
                                  if ( ! $id ) {
                                      $id = null;
                                  }
                      
                      
                      Severity: Minor
                      Found in src/db-objects/model-edit-page.php - About 6 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

                      Method init has 149 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              protected function init() {
                                  $this->translations = array(
                                      /* --- Model --- */
                      
                                      'db_insert_error'                                       => $this->__translate( 'Could not insert model into the database.', 'textdomain' ),
                      Severity: Major
                      Found in src/translations/translations-manager.php - About 5 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language