Showing 39 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.
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
$type_labels = array(
'reacji' => __( 'Reacjis', 'semantic-linkbacks' ),
'like' => __( 'Likes', 'semantic-linkbacks' ),
'favorite' => __( 'Favourites', 'semantic-linkbacks' ),
'bookmark' => __( 'Bookmarks', 'semantic-linkbacks' ),
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 248.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
$strings = array(
// translators: Name verb on domain
'mention' => __( '%1$s mentioned %2$s on <a href="%3$s">%4$s</a>.', 'semantic-linkbacks' ),
// translators: Name verb on domain
'reply' => __( '%1$s replied to %2$s on <a href="%3$s">%4$s</a>.', 'semantic-linkbacks' ),
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 248.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ( $type ) { // use type if set
if ( 'mention' === $type ) {
$args['type__not_in'] = 'comment';
$args['meta_query'] = array(
'relation' => 'OR',
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 181.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ( $type ) { // use type if set
if ( 'mention' === $type ) {
$args['type__not_in'] = 'comment';
$args['meta_query'] = array(
'relation' => 'OR',
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 181.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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 );
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
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
Linkbacks_Handler
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class Linkbacks_Handler {
/**
* Initialize the plugin, registering WordPress hooks.
*/
public static function init() {
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 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(
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(
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
- 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];
}
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;
- 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 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;
}
- 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"