picandocodigo/List-Category-Posts

View on GitHub

Showing 50 of 50 total issues

File lcp-catlist.php has 452 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
define( 'LCP_PATH', plugin_dir_path( __FILE__ ) );
require_once ( LCP_PATH . 'lcp-thumbnail.php' );
require_once ( LCP_PATH . 'lcp-parameters.php' );
require_once ( LCP_PATH . 'lcp-utils.php' );
Severity: Minor
Found in include/lcp-catlist.php - About 6 hrs to fix

    Method default_params has 138 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      public static function default_params(){
        if (self::$default_params === null) {
          self::$default_params = array(
            'id' => '0',
            'name' => '',
    Severity: Major
    Found in list-category-posts.php - About 5 hrs to fix

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

        public function current_category($mode, $ids='') {
          // Only single post pages with assigned category and
          // category archives have a 'current category',
          // in all other cases no posts should be returned. (#69)
          
      Severity: Minor
      Found in include/lcp-category.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

      Method list_category_posts_options has 126 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function list_category_posts_options() {
          if ( !current_user_can( 'manage_options' ) )  {
              wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
          }
      ?>
      Severity: Major
      Found in include/lcp-options.php - About 5 hrs to fix

        CatList has 37 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class CatList{
          private $params = array();
          private $lcp_category_id = 0;
          private $page = 1;
          private $posts_count = 0;
        Severity: Minor
        Found in include/lcp-catlist.php - About 4 hrs to fix

          Function get_query_params has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

            public function get_query_params($params){
              $this->params = $params;
              # Essential parameters:
              $args = array(
                'numberposts' => $params['numberposts'],
          Severity: Minor
          Found in include/lcp-parameters.php - About 4 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

          CatListDisplayer has 31 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class CatListDisplayer {
            public $catlist;
            private $wrapper;
            private $templater;
            private $params = array();
          Severity: Minor
          Found in include/lcp-catlistdisplayer.php - About 3 hrs to fix

            Function get_custom_fields has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

              public function get_custom_fields($custom_key, $post_id) {
                if ($this->utils->lcp_not_empty('customfield_display')) {
                  $lcp_customs = array();
            
                  //Doesn't work for many custom fields when having spaces:
            Severity: Minor
            Found in include/lcp-catlist.php - About 3 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 widget has 82 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function widget($args, $instance) {
                global $post;
                /* Since WP 4.9 global $post is nullified in text widgets
                 * when is_singular() is false. It should also be nullified in LCP
                 * widgets, otherwise the plugin will mark the last post of the loop
            Severity: Major
            Found in include/lcp-widget.php - About 3 hrs to fix

              Method get_query_params has 74 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                public function get_query_params($params){
                  $this->params = $params;
                  # Essential parameters:
                  $args = array(
                    'numberposts' => $params['numberposts'],
              Severity: Major
              Found in include/lcp-parameters.php - About 2 hrs to fix

                Function content_getter has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                Open

                  private function content_getter($type, $post, $tag = null, $css_class = null) {
                    // Shortcode parameters take precedence over function arguments
                    // for tags and classes. 'posts_morelink_tag' param doesn't exist
                    if ($type !== 'posts_morelink') $tag = $this->params[$type . '_tag'] ?: $tag;
                    $css_class = $this->params[$type . '_class'] ?: $css_class;
                Severity: Minor
                Found in include/lcp-catlistdisplayer.php - About 2 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_thumbnail has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                  public function get_thumbnail($single, $thumbnail, $thumbnail_size, $force_thumbnail, $lcp_thumb_class = null){
                    $lcp_thumbnail = null;
                
                    if( $thumbnail == 'yes' ){
                      $lcp_thumbnail = '';
                Severity: Minor
                Found in include/lcp-thumbnail.php - About 2 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 get_pagination has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  public function get_pagination($params){
                    if (LcpUtils::lcp_show_pagination($params['pagination'])){
                      $lcp_paginator = '';
                      $pages_count = ceil (
                        $params['posts_count'] /
                Severity: Major
                Found in include/lcp-paginator.php - About 2 hrs to fix

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

                    public function get_pagination($params){
                      if (LcpUtils::lcp_show_pagination($params['pagination'])){
                        $lcp_paginator = '';
                        $pages_count = ceil (
                          $params['posts_count'] /
                  Severity: Minor
                  Found in include/lcp-paginator.php - About 2 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 lcp-widget-form.php has 267 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                    /**
                     * List Category Posts sidebar widget form for Appearance > Widgets.
                     * @author fernando@picandocodigo.net
                     */
                  Severity: Minor
                  Found in include/lcp-widget-form.php - About 2 hrs to fix

                    Method content_getter has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      private function content_getter($type, $post, $tag = null, $css_class = null) {
                        // Shortcode parameters take precedence over function arguments
                        // for tags and classes. 'posts_morelink_tag' param doesn't exist
                        if ($type !== 'posts_morelink') $tag = $this->params[$type . '_tag'] ?: $tag;
                        $css_class = $this->params[$type . '_class'] ?: $css_class;
                    Severity: Major
                    Found in include/lcp-catlistdisplayer.php - About 2 hrs to fix

                      Function get_category_link has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                        public function get_category_link() {
                          if(($this->params['catlink'] == 'yes' ||
                              $this->params['catname'] == 'yes') &&
                             $this->lcp_category_id != 0){
                            // Check for one id or several:
                      Severity: Minor
                      Found in include/lcp-catlist.php - About 2 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_excerpt has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                        public function get_excerpt($single) {
                          if (!empty( $this->params['excerpt']) &&
                               ($this->params['excerpt']=='yes' || $this->params['excerpt']=='full')) {
                      
                            if($single->post_excerpt == "" ||
                      Severity: Minor
                      Found in include/lcp-catlist.php - About 2 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 get_thumbnail has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        public function get_thumbnail($single, $thumbnail, $thumbnail_size, $force_thumbnail, $lcp_thumb_class = null){
                          $lcp_thumbnail = null;
                      
                          if( $thumbnail == 'yes' ){
                            $lcp_thumbnail = '';
                      Severity: Minor
                      Found in include/lcp-thumbnail.php - About 1 hr to fix

                        Function create_date_query_args has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                          public function create_date_query_args($args, $params) {
                            $date_query = array();
                            // Booleans to track which subarrays should be created.
                            $after = false;
                            $before = false;
                        Severity: Minor
                        Found in include/lcp-date-query.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

                        Severity
                        Category
                        Status
                        Source
                        Language