Method embed_post
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
function embed_post( $content ) {
global $post;
if ( ! is_object( $post ) ) { return; }
$placements = array_intersect_assoc(
Function embed_post
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function embed_post( $content ) {
global $post;
if ( ! is_object( $post ) ) { return; }
$placements = array_intersect_assoc(
- 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 3 locations. Consider refactoring. Open
$post_types = array_keys(array_intersect(
parent::$options['where']['post_types'],
array(
'post' => 1,
'page' => 1,
- 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 46.
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
, ('print' == $type) ? sprintf( '<iframe style="display:none;" id="read_offline_print" name="read_offline_print" src="%s"></iframe>',parent::query_url( $post->ID,$post->post_name,$type ) ) : ''
- 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 40.
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
Array double arrow not aligned correctly; expected 3 space(s) between "'bottom'" and double arrow, but found 1. Open
'bottom' => 1,
- Exclude checks
Found precision alignment of 1 spaces. Open
'pdf' => __( 'Download PDF', 'read-offline' ),
- Exclude checks
Expected 1 space after comma in function call; 2 found Open
'pdf' => __( 'Download PDF', 'read-offline' ),
- Exclude checks
Array item not aligned correctly; expected 16 spaces but found 12 Open
'epub' => __( 'Download ePub', 'read-offline' ),
- Exclude checks
Array item not aligned correctly; expected 16 spaces but found 12 Open
'docx' => __( 'Download DocX', 'read-offline' ),
- Exclude checks
Found precision alignment of 1 spaces. Open
'top' => 1,
- Exclude checks
Array double arrow not aligned correctly; expected 1 space(s) between "'top'" and double arrow, but found 4. Open
'top' => 1,
- Exclude checks
Space found before comma in function call Open
, parent::$options['where']['placements']
- Exclude checks
Array item not aligned correctly; expected 16 spaces but found 12 Open
'bottom' => 1,
- Exclude checks
Array item not aligned correctly; expected 16 spaces but found 17 Open
'top' => 1,
- Exclude checks
Array double arrow not aligned correctly; expected 9 space(s) between "'docx'" and double arrow, but found 2. Open
'docx' => __( 'Download DocX', 'read-offline' ),
- Exclude checks
Array item not aligned correctly; expected 16 spaces but found 12 Open
'mobi' => __( 'Download mobi', 'read-offline' ),
- Exclude checks
Array double arrow not aligned correctly; expected 1 space(s) between "'pdf'" and double arrow, but found 3. Open
'pdf' => __( 'Download PDF', 'read-offline' ),
- Exclude checks
Concat operator must be surrounded by a single space Open
wp_enqueue_script( 'read-offline-ga', READOFFLINE_URL.'/js/read-offline-ga.js',array( 'jquery' ), READOFFLINE_VERSION );
- Exclude checks
Array double arrow not aligned correctly; expected 8 space(s) between "'print'" and double arrow, but found 1. Open
'print' => __( 'Print', 'read-offline' ),
- Exclude checks
Array double arrow not aligned correctly; expected 9 space(s) between "'mobi'" and double arrow, but found 2. Open
'mobi' => __( 'Download mobi', 'read-offline' ),
- Exclude checks
Array item not aligned correctly; expected 16 spaces but found 12 Open
'print' => __( 'Print', 'read-offline' ),
- Exclude checks
Expected 1 space after comma in function call; 3 found Open
wp_enqueue_style( 'read-offline-css', READOFFLINE_URL . '/css/read-offline.css',array(), READOFFLINE_VERSION );
- Exclude checks
Expected 1 space after comma in function call; 6 found Open
wp_enqueue_script( 'read-offline', READOFFLINE_URL . '/js/read-offline-wp.js',array( 'jquery' ), READOFFLINE_VERSION );
- Exclude checks
Array item not aligned correctly; expected 16 spaces but found 21 Open
'pdf' => __( 'Download PDF', 'read-offline' ),
- Exclude checks
Array double arrow not aligned correctly; expected 9 space(s) between "'epub'" and double arrow, but found 2. Open
'epub' => __( 'Download ePub', 'read-offline' ),
- Exclude checks
Expected 1 space after open parenthesis; 0 found Open
, ('print' == $type) ? '' : $type
- Exclude checks
Found precision alignment of 1 spaces. Open
'post' => 1,
- Exclude checks
Expected 1 space after open parenthesis; 0 found Open
, ('print' == $type) ? __( 'Print','read-offline' ) : __( 'Download','read-offline' )
- Exclude checks
Space found before comma in function call Open
, ('print' == $type) ? 'onclick="read_offline_print_me();return false;"': ''
- Exclude checks
Expected 1 space after open parenthesis; 0 found Open
, ('print' == $type) ? 'onclick="read_offline_print_me();return false;"': ''
- Exclude checks
Expected 1 space before close parenthesis; 0 found Open
, ('print' == $type) ? __( 'Print','read-offline' ) : __( 'Download','read-offline' )
- Exclude checks
Expected 1 space after open parenthesis; 0 found Open
, ('print' == $type) ? sprintf( '<iframe style="display:none;" id="read_offline_print" name="read_offline_print" src="%s"></iframe>',parent::query_url( $post->ID,$post->post_name,$type ) ) : ''
- Exclude checks
Expected 1 space after comma in function call; 9 found Open
'print' => __( 'Print', 'read-offline' ),
- Exclude checks
Space found before comma in function call Open
, parent::query_url( $post->ID,$post->post_name,$type )
- Exclude checks
Space found before comma in function call Open
, ('print' == $type) ? '' : $type
- Exclude checks
Expected 1 space before close parenthesis; 0 found Open
, ('print' == $type) ? 'onclick="read_offline_print_me();return false;"': ''
- Exclude checks
Array item not aligned correctly; expected 16 spaces but found 17 Open
'post' => 1,
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space Open
$text = parent::$options['how']['link_text'];
- Exclude checks
Expected 1 space before close parenthesis; 0 found Open
$str_info = (1 == parent::$options['how']['icons_only']) ? '' : sprintf( '%s',$document_type );
- Exclude checks
Space found before comma in function call Open
, ('print' == $type) ? __( 'Print','read-offline' ) : __( 'Download','read-offline' )
- Exclude checks
Space found before comma in function call Open
, $str_info
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space Open
$str_info = (1 == parent::$options['how']['icons_only']) ? '' : sprintf( '%s',$document_type );
- Exclude checks
Space found before comma in function call Open
, $post->post_name
- Exclude checks
Expected 1 space before close parenthesis; 0 found Open
, ('print' == $type) ? '' : $type
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space Open
$text = str_ireplace( '%title%', $post->post_title,$text );
- Exclude checks
Expected 1 space after open parenthesis; 0 found Open
$str_info = (1 == parent::$options['how']['icons_only']) ? '' : sprintf( '%s',$document_type );
- Exclude checks
Expected 1 space before ":"; 0 found Open
, ('print' == $type) ? 'onclick="read_offline_print_me();return false;"': ''
- Exclude checks
Space found before comma in function call Open
, array_filter( parent::$options['what']['formats'] )
- Exclude checks
Found precision alignment of 1 spaces. Open
'page' => 1,
- Exclude checks
Array closer not aligned correctly; expected 12 space(s) but found 16 Open
)
- Exclude checks
Expected 1 space before close parenthesis; 0 found Open
, ('print' == $type) ? sprintf( '<iframe style="display:none;" id="read_offline_print" name="read_offline_print" src="%s"></iframe>',parent::query_url( $post->ID,$post->post_name,$type ) ) : ''
- Exclude checks
Array item not aligned correctly; expected 16 spaces but found 17 Open
'page' => 1,
- Exclude checks
Space found before comma in function call Open
, ('print' == $type) ? sprintf( '<iframe style="display:none;" id="read_offline_print" name="read_offline_print" src="%s"></iframe>',parent::query_url( $post->ID,$post->post_name,$type ) ) : ''
- Exclude checks
No space found after comma in function call Open
wp_enqueue_script( 'read-offline-ga', READOFFLINE_URL.'/js/read-offline-ga.js',array( 'jquery' ), READOFFLINE_VERSION );
- Exclude checks
Newline required after opening brace Open
if ( ! is_object( $post ) ) { return; }
- Exclude checks
No space found after comma in function call Open
wp_enqueue_script( 'read-offline', READOFFLINE_URL . '/js/read-offline-wp.js',array( 'jquery' ), READOFFLINE_VERSION );
- Exclude checks
No space found after comma in function call Open
wp_enqueue_style( 'read-offline-embed', READOFFLINE_URL . '/css/read-offline-embed.css',array(), READOFFLINE_VERSION );
- Exclude checks
No space found after comma in function call Open
wp_enqueue_style( 'read-offline-css', READOFFLINE_URL . '/css/read-offline.css',array(), READOFFLINE_VERSION );
- Exclude checks
No space found after comma in function call Open
, ('print' == $type) ? __( 'Print','read-offline' ) : __( 'Download','read-offline' )
- Exclude checks
No space found after comma in function call Open
$text = str_ireplace( '%title%', $post->post_title,$text );
- Exclude checks
No space found after comma in function call Open
$readoffline .= sprintf( '<div class="readoffline-embed-text">%s</div>',stripslashes( $text ) );
- Exclude checks
No space found after comma in function call Open
$str_info = (1 == parent::$options['how']['icons_only']) ? '' : sprintf( '%s',$document_type );
- Exclude checks
No space found after comma in function call Open
, parent::query_url( $post->ID,$post->post_name,$type )
- Exclude checks
No space found after comma in function call Open
, ('print' == $type) ? __( 'Print','read-offline' ) : __( 'Download','read-offline' )
- Exclude checks
No space found after comma in function call Open
, ('print' == $type) ? sprintf( '<iframe style="display:none;" id="read_offline_print" name="read_offline_print" src="%s"></iframe>',parent::query_url( $post->ID,$post->post_name,$type ) ) : ''
- Exclude checks
No space found after comma in function call Open
, parent::query_url( $post->ID,$post->post_name,$type )
- Exclude checks
No space found after comma in function call Open
, ('print' == $type) ? sprintf( '<iframe style="display:none;" id="read_offline_print" name="read_offline_print" src="%s"></iframe>',parent::query_url( $post->ID,$post->post_name,$type ) ) : ''
- Exclude checks
No space found after comma in function call Open
, ('print' == $type) ? sprintf( '<iframe style="display:none;" id="read_offline_print" name="read_offline_print" src="%s"></iframe>',parent::query_url( $post->ID,$post->post_name,$type ) ) : ''
- Exclude checks