picandocodigo/List-Category-Posts

View on GitHub
include/lcp-category.php

Summary

Maintainability
C
1 day
Test Coverage

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 current_category has 30 lines of code (exceeds 25 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 1 hr to fix

    Function lcp_categories has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      private function lcp_categories($categories, $child_categories, $exclude) {
        $args = array();
    
        if (is_array($categories)) {
          // Handle excluded categories for the 'and' relationship.
    Severity: Minor
    Found in include/lcp-category.php - About 35 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_post_primary_category has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      private function get_post_primary_category( $post_id ) {
        $return = null;
    
        if ( class_exists( 'WPSEO_Primary_Term' ) ) {
          // Show Primary category by Yoast if it is enabled & set
    Severity: Minor
    Found in include/lcp-category.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

    Function get_lcp_category has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      public function get_lcp_category($params, &$lcp_category_id=0) {
        // Only used when excluded categories are combined with 'and' relationship.
        $exclude = [];
        // This will be the value of lcp_category_id which is passed by reference.
        $categories = $lcp_category_id;
    Severity: Minor
    Found in include/lcp-category.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