felixarntz/plugin-lib

View on GitHub

Showing 821 of 821 total issues

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

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

            public function get_item_permissions_check( $request ) {
                $capabilities = $this->manager->capabilities();
    
                if ( 'edit' === $request['context'] && ( ! $capabilities || ! $capabilities->user_can_edit() ) ) {
                    return new WP_Error( 'rest_cannot_edit_status', $this->manager->get_message( 'rest_cannot_edit_status' ), array( 'status' => rest_authorization_required_code() ) );
    Severity: Major
    Found in src/db-objects/rest-model-statuses-controller.php and 1 other location - About 7 hrs to fix
    src/db-objects/rest-model-types-controller.php on lines 147..165

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

    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 get_item_permissions_check( $request ) {
                $capabilities = $this->manager->capabilities();
    
                if ( 'edit' === $request['context'] && ( ! $capabilities || ! $capabilities->user_can_edit() ) ) {
                    return new WP_Error( 'rest_cannot_edit_type', $this->manager->get_message( 'rest_cannot_edit_type' ), array( 'status' => rest_authorization_required_code() ) );
    Severity: Major
    Found in src/db-objects/rest-model-types-controller.php and 1 other location - About 7 hrs to fix
    src/db-objects/rest-model-statuses-controller.php on lines 147..165

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

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

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

              public function register_routes() {
                  register_rest_route(
                      $this->namespace,
                      '/' . $this->rest_base,
                      array(
      Severity: Major
      Found in src/db-objects/rest-model-statuses-controller.php and 1 other location - About 6 hrs to fix
      src/db-objects/rest-model-types-controller.php on lines 57..93

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

      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 register_routes() {
                  register_rest_route(
                      $this->namespace,
                      '/' . $this->rest_base,
                      array(
      Severity: Major
      Found in src/db-objects/rest-model-types-controller.php and 1 other location - About 6 hrs to fix
      src/db-objects/rest-model-statuses-controller.php on lines 57..93

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

      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

      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

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

                      if ( method_exists( $this, 'maybe_set_transition_type_property_data' ) && method_exists( $this, 'maybe_transition_type_property' ) ) {
                          $this->filters[] = array(
                              'name'     => "{$prefix}pre_add_{$singular_slug}",
                              'callback' => array( $this, 'maybe_set_transition_type_property_data' ),
                              'priority' => 100,
          Severity: Major
          Found in src/db-objects/manager.php and 1 other location - About 5 hrs to fix
          src/db-objects/manager.php on lines 793..818

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

          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

                      if ( method_exists( $this, 'maybe_set_transition_status_property_data' ) && method_exists( $this, 'maybe_transition_status_property' ) ) {
                          $this->filters[] = array(
                              'name'     => "{$prefix}pre_add_{$singular_slug}",
                              'callback' => array( $this, 'maybe_set_transition_status_property_data' ),
                              'priority' => 100,
          Severity: Major
          Found in src/db-objects/manager.php and 1 other location - About 5 hrs to fix
          src/db-objects/manager.php on lines 766..791

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

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

                  protected function validate_custom_data( $form_data, $error ) {
                      if ( method_exists( $this->model_manager, 'get_type_property' ) ) {
                          $type_property = $this->model_manager->get_type_property();
          
                          if ( isset( $form_data[ $type_property ] ) && $form_data[ $type_property ] !== $this->model->$type_property ) {
          Severity: Minor
          Found in src/db-objects/model-edit-page.php - About 5 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_items_permissions_check has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
          Open

                  public function get_items_permissions_check( $request ) {
                      $capabilities = $this->manager->capabilities();
          
                      if ( 'edit' === $request['context'] ) {
                          if ( ! $capabilities || ! $capabilities->user_can_edit() ) {
          Severity: Minor
          Found in src/db-objects/rest-models-controller.php - About 5 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 manager.php has 405 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

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

            Function build_row_actions has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
            Open

                    protected function build_row_actions( $model, $model_id, $view_url = '', $edit_url = '', $list_url = '' ) {
                        $actions = array();
            
                        $title = null;
                        if ( method_exists( $this->manager, 'get_title_property' ) ) {
            Severity: Minor
            Found in src/db-objects/models-list-table.php - About 5 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

            Severity
            Category
            Status
            Source
            Language