picandocodigo/List-Category-Posts

View on GitHub
include/lcp-catlistdisplayer.php

Summary

Maintainability
D
1 day
Test Coverage

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

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

        public function get_post_title($single, $tag = null, $css_class = null,
          $link = true, $link_current = true) {
      
          // Don't do anything if no_post_titles is specified.
          if ('yes' === $this->params['no_post_titles']) {
      Severity: Minor
      Found in include/lcp-catlistdisplayer.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_post_title has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public function get_post_title($single, $tag = null, $css_class = null,
          $link = true, $link_current = true) {
      
          // Don't do anything if no_post_titles is specified.
          if ('yes' === $this->params['no_post_titles']) {
      Severity: Minor
      Found in include/lcp-catlistdisplayer.php - About 1 hr to fix

        Function lcp_title_limit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          private function lcp_title_limit( $lcp_post_title ){
            if ( !empty($this->params['title_limit']) && $this->params['title_limit'] !== "0" ){
              $title_limit = intval($this->params['title_limit']);
              if( function_exists('mb_strlen') && function_exists('mb_substr') && mb_strlen($lcp_post_title) > $title_limit ){
                $lcp_post_title = mb_substr($lcp_post_title, 0, $title_limit) . "…";
        Severity: Minor
        Found in include/lcp-catlistdisplayer.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

        Method get_post_title has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          public function get_post_title($single, $tag = null, $css_class = null,
            $link = true, $link_current = true) {
        Severity: Minor
        Found in include/lcp-catlistdisplayer.php - About 35 mins to fix

          There are no issues that match your filters.

          Category
          Status