pfefferle/wordpress-semantic-linkbacks

View on GitHub
includes/class-linkbacks-mf2-handler.php

Summary

Maintainability
F
6 days
Test Coverage

Function generate_commentdata has a Cognitive Complexity of 84 (exceeds 5 allowed). Consider refactoring.
Open

    public static function generate_commentdata( $commentdata ) {
        // Use new webmention source meta key.
        if ( array_key_exists( 'webmention_source_url', $commentdata['comment_meta'] ) ) {
            $source = $commentdata['comment_meta']['webmention_source_url'];
        } else { // Fallback to comment author url.
Severity: Minor
Found in includes/class-linkbacks-mf2-handler.php - About 1 day 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 class-linkbacks-mf2-handler.php has 440 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
use Mf2\Parser;

/**
 * provides a microformats handler for the semantic linkbacks
Severity: Minor
Found in includes/class-linkbacks-mf2-handler.php - About 6 hrs to fix

    Method generate_commentdata has 161 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function generate_commentdata( $commentdata ) {
            // Use new webmention source meta key.
            if ( array_key_exists( 'webmention_source_url', $commentdata['comment_meta'] ) ) {
                $source = $commentdata['comment_meta']['webmention_source_url'];
            } else { // Fallback to comment author url.
    Severity: Major
    Found in includes/class-linkbacks-mf2-handler.php - About 6 hrs to fix

      Function get_representative_entry has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function get_representative_entry( $entries, $target ) {
              // iterate array
              foreach ( $entries as $entry ) {
                  // check properties
                  if ( isset( $entry['properties'] ) ) {
      Severity: Minor
      Found in includes/class-linkbacks-mf2-handler.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_entry_type has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function get_entry_type( $target, $entry, $mf_array = array() ) {
              $classes = self::get_class_mapper();
      
              // check properties for target-url
              foreach ( $entry['properties'] as $key => $values ) {
      Severity: Minor
      Found in includes/class-linkbacks-mf2-handler.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_representative_author has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function get_representative_author( $mf_array, $source ) {
              foreach ( $mf_array['items'] as $mf ) {
                  if ( isset( $mf['type'] ) ) {
                      if ( in_array( 'h-card', $mf['type'], true ) ) {
                          // check domain
      Severity: Minor
      Found in includes/class-linkbacks-mf2-handler.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

      Function flatten_microformats has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function flatten_microformats( $item ) {
              $flat = array();
              if ( 1 === count( $item ) ) {
                  $item = $item[0];
              }
      Severity: Minor
      Found in includes/class-linkbacks-mf2-handler.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 flatten_microformats has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function flatten_microformats( $item ) {
              $flat = array();
              if ( 1 === count( $item ) ) {
                  $item = $item[0];
              }
      Severity: Minor
      Found in includes/class-linkbacks-mf2-handler.php - About 1 hr to fix

        Method get_entry_type has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function get_entry_type( $target, $entry, $mf_array = array() ) {
                $classes = self::get_class_mapper();
        
                // check properties for target-url
                foreach ( $entry['properties'] as $key => $values ) {
        Severity: Minor
        Found in includes/class-linkbacks-mf2-handler.php - About 1 hr to fix

          Method get_representative_entry has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function get_representative_entry( $entries, $target ) {
                  // iterate array
                  foreach ( $entries as $entry ) {
                      // check properties
                      if ( isset( $entry['properties'] ) ) {
          Severity: Minor
          Found in includes/class-linkbacks-mf2-handler.php - About 1 hr to fix

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

                public static function get_entries( $mf_array ) {
                    $entries = array();
            
                    // some basic checks
                    if ( ! is_array( $mf_array ) ) {
            Severity: Minor
            Found in includes/class-linkbacks-mf2-handler.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

            Avoid deeply nested control flow statements.
            Open

                                            if ( isset( $mf_array['rels']['me'] ) ) {
                                                $mf['properties']['me'] = $mf_array['rels']['me'];
                                            }
            Severity: Major
            Found in includes/class-linkbacks-mf2-handler.php - About 45 mins to fix

              Avoid too many return statements within this method.
              Open

                      return 'mention';
              Severity: Major
              Found in includes/class-linkbacks-mf2-handler.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return $entries[0];
                Severity: Major
                Found in includes/class-linkbacks-mf2-handler.php - About 30 mins to fix

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

                      public static function get_property( $key, $properties ) {
                          if ( isset( $properties[ $key ] ) && isset( $properties[ $key ][0] ) ) {
                              if ( is_array( $properties[ $key ] ) ) {
                                  $properties[ $key ] = array_unique( $properties[ $key ] );
                              }
                  Severity: Minor
                  Found in includes/class-linkbacks-mf2-handler.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