picandocodigo/List-Category-Posts

View on GitHub
include/lcp-catlist.php

Summary

Maintainability
F
3 days
Test Coverage

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

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

      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

      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

      Method get_category_link has 32 lines of code (exceeds 25 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 1 hr to fix

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

          public function get_content($single) {
            if (isset($this->params['content']) &&
                ($this->params['content'] =='yes' || $this->params['content'] == 'full') &&
                $single->post_content){
              // get_extended - get content split by <!--more-->
        Severity: Minor
        Found in include/lcp-catlist.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

        Method get_content has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public function get_content($single) {
            if (isset($this->params['content']) &&
                ($this->params['content'] =='yes' || $this->params['content'] == 'full') &&
                $single->post_content){
              // get_extended - get content split by <!--more-->
        Severity: Minor
        Found in include/lcp-catlist.php - About 1 hr to fix

          Method set_lcp_parameters has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private function set_lcp_parameters(){
              $args = LcpCategory::get_instance()->get_lcp_category([
                'id'               => $this->params['id'],
                'name'             => $this->params['name'],
                'categorypage'     => $this->params['categorypage'],
          Severity: Minor
          Found in include/lcp-catlist.php - About 1 hr to fix

            Function get_inner_tag has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              public function get_inner_tag($single, $parent, $tag, $css_class='') {
                $class = $css_class;
                $props = [];
                if (is_object( $parent) && is_object($single) &&
                    $parent->ID === $single->ID) {
            Severity: Minor
            Found in include/lcp-catlist.php - About 55 mins 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 check_pagination has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              private function check_pagination($args) {
                if (LcpUtils::lcp_show_pagination($this->params['pagination'])) {
                  if(array_key_exists('QUERY_STRING', $_SERVER) && null !== $_SERVER['QUERY_STRING'] ) {
                    $query = $_SERVER['QUERY_STRING'];
                    if ($query !== '' && preg_match('/lcp_page' . preg_quote($this->instance) .
            Severity: Minor
            Found in include/lcp-catlist.php - About 45 mins 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_author_to_show has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              public function get_author_to_show($single) {
                if ($this->params['author'] == 'yes') {
                  $lcp_userdata = get_userdata($single->post_author);
                  $author_name =  $lcp_userdata->display_name;
                  if($this->utils->lcp_not_empty('author_posts_link') &&
            Severity: Minor
            Found in include/lcp-catlist.php - About 25 mins 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

            There are no issues that match your filters.

            Category
            Status