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.
- Read upRead up
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
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.
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'] ) ) {
- Read upRead up
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 ) {
- Read upRead up
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
- Read upRead up
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];
}
- Read upRead up
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];
}
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 ) {
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'] ) ) {
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 ) ) {
- Read upRead up
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'];
}
Avoid too many return
statements within this method. Open
return 'mention';
Avoid too many return
statements within this method. Open
return $entries[0];
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 ] );
}
- Read upRead up
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"