pfefferle/wordpress-semantic-linkbacks

View on GitHub

Showing 35 of 42 total issues

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

      File class-linkbacks-handler.php has 369 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      // Mentions with content less than this length will be rendered inline.
      define( 'MAX_INLINE_MENTION_LENGTH', 300 );
      
      
      Severity: Minor
      Found in includes/class-linkbacks-handler.php - About 4 hrs to fix

        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

        Method list_linkbacks has 97 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function list_linkbacks( $args, $comments ) {
            $defaults = array(
                'avatar_size' => 64,
                'style'       => 'ul', // What HTML type to wrap it in. Accepts 'ul', 'ol'.
                'style-class' => 'mention-list', // What class to assign to the wrapper
        Severity: Major
        Found in includes/functions.php - About 3 hrs to fix

          Linkbacks_Handler has 27 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Linkbacks_Handler {
              /**
               * Initialize the plugin, registering WordPress hooks.
               */
              public static function init() {
          Severity: Minor
          Found in includes/class-linkbacks-handler.php - About 3 hrs to fix

            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 get_linkbacks_number has 56 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function get_linkbacks_number( $type = null, $post_id = null ) {
                if ( null === $post_id ) {
                    $post_id = get_the_ID();
                }
                $args = array(
            Severity: Major
            Found in includes/functions.php - About 2 hrs to fix

              Method get_linkbacks has 51 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function get_linkbacks( $type = null, $post_id = null, $order = 'DESC' ) {
                  if ( null === $post_id ) {
                      $post_id = get_the_ID();
                  }
                  $args = array(
              Severity: Major
              Found in includes/functions.php - About 2 hrs to fix

                Function list_linkbacks has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                function list_linkbacks( $args, $comments ) {
                    $defaults = array(
                        'avatar_size' => 64,
                        'style'       => 'ul', // What HTML type to wrap it in. Accepts 'ul', 'ol'.
                        'style-class' => 'mention-list', // What class to assign to the wrapper
                Severity: Minor
                Found in includes/functions.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 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

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

                      public static function pre_get_avatar_data( $args, $id_or_email ) {
                          if ( ! $id_or_email instanceof WP_Comment ||
                          ! isset( $id_or_email->comment_type ) ||
                          $id_or_email->user_id ) {
                              return $args;
                  Severity: Minor
                  Found in includes/class-linkbacks-avatar-handler.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

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

                      public static function anonymous_avatar_data( $args, $id_or_email ) {
                          $local = apply_filters( 'semantic_linkbacks_local_avatars', array( 'mm', 'mystery', 'mysteryman' ) );
                          if ( ! in_array( $args['default'], $local, true ) ) {
                              return $args;
                          }
                  Severity: Minor
                  Found in includes/class-linkbacks-avatar-handler.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 pre_get_avatar_data has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function pre_get_avatar_data( $args, $id_or_email ) {
                          if ( ! $id_or_email instanceof WP_Comment ||
                          ! isset( $id_or_email->comment_type ) ||
                          $id_or_email->user_id ) {
                              return $args;
                  Severity: Minor
                  Found in includes/class-linkbacks-avatar-handler.php - About 1 hr to fix

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

                        public static function register_meta() {
                            $args = array(
                                'sanitize_callback' => 'esc_url_raw',
                                'type'              => 'string',
                                'description'       => 'Author URL',
                    Severity: Minor
                    Found in includes/class-linkbacks-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
                          Severity
                          Category
                          Status
                          Source
                          Language