soderlind/read-offline

View on GitHub
inc/class-read-offline-ux.php

Summary

Maintainability
A
3 hrs
Test Coverage

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(
Severity: Major
Found in inc/class-read-offline-ux.php - About 2 hrs to fix

    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(
    Severity: Minor
    Found in inc/class-read-offline-ux.php - About 35 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

    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,
    Severity: Major
    Found in inc/class-read-offline-ux.php and 2 other locations - About 45 mins to fix
    inc/class-read-offline-shortcode.php on lines 79..85
    inc/class-read-offline.php on lines 55..61

    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

    Further Reading

    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 ) ) : ''
    Severity: Minor
    Found in inc/class-read-offline-ux.php and 1 other location - About 30 mins to fix
    inc/class-read-offline-shortcode.php on lines 97..97

    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

    Further Reading

    Array double arrow not aligned correctly; expected 3 space(s) between "'bottom'" and double arrow, but found 1.
    Open

                'bottom' => 1,

    Found precision alignment of 1 spaces.
    Open

                         'pdf'   => __( 'Download PDF',  'read-offline' ),

    Expected 1 space after comma in function call; 2 found
    Open

                         'pdf'   => __( 'Download PDF',  'read-offline' ),

    Array item not aligned correctly; expected 16 spaces but found 12
    Open

                'epub'  => __( 'Download ePub', 'read-offline' ),

    Array item not aligned correctly; expected 16 spaces but found 12
    Open

                'docx'  => __( 'Download DocX', 'read-offline' ),

    Found precision alignment of 1 spaces.
    Open

                     'top'    => 1,

    Array double arrow not aligned correctly; expected 1 space(s) between "'top'" and double arrow, but found 4.
    Open

                     'top'    => 1,

    Space found before comma in function call
    Open

                , parent::$options['where']['placements']

    Array item not aligned correctly; expected 16 spaces but found 12
    Open

                'bottom' => 1,

    Array item not aligned correctly; expected 16 spaces but found 17
    Open

                     'top'    => 1,

    Array double arrow not aligned correctly; expected 9 space(s) between "'docx'" and double arrow, but found 2.
    Open

                'docx'  => __( 'Download DocX', 'read-offline' ),

    Array item not aligned correctly; expected 16 spaces but found 12
    Open

                'mobi'  => __( 'Download mobi', 'read-offline' ),

    Array double arrow not aligned correctly; expected 1 space(s) between "'pdf'" and double arrow, but found 3.
    Open

                         'pdf'   => __( 'Download PDF',  'read-offline' ),

    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 );

    Array double arrow not aligned correctly; expected 8 space(s) between "'print'" and double arrow, but found 1.
    Open

                'print' => __( 'Print',         'read-offline' ),

    Array double arrow not aligned correctly; expected 9 space(s) between "'mobi'" and double arrow, but found 2.
    Open

                'mobi'  => __( 'Download mobi', 'read-offline' ),

    Array item not aligned correctly; expected 16 spaces but found 12
    Open

                'print' => __( 'Print',         'read-offline' ),

    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 );

    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 );

    Array item not aligned correctly; expected 16 spaces but found 21
    Open

                         'pdf'   => __( 'Download PDF',  'read-offline' ),

    Array double arrow not aligned correctly; expected 9 space(s) between "'epub'" and double arrow, but found 2.
    Open

                'epub'  => __( 'Download ePub', 'read-offline' ),

    Expected 1 space after open parenthesis; 0 found
    Open

                    , ('print' == $type) ? '' : $type

    Found precision alignment of 1 spaces.
    Open

                     'post' => 1,

    Expected 1 space after open parenthesis; 0 found
    Open

                    , ('print' == $type) ? __( 'Print','read-offline' ) : __( 'Download','read-offline' )

    Space found before comma in function call
    Open

                    , ('print' == $type) ? 'onclick="read_offline_print_me();return false;"': ''

    Expected 1 space after open parenthesis; 0 found
    Open

                    , ('print' == $type) ? 'onclick="read_offline_print_me();return false;"': ''

    Expected 1 space before close parenthesis; 0 found
    Open

                    , ('print' == $type) ? __( 'Print','read-offline' ) : __( 'Download','read-offline' )

    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 ) ) : ''

    Expected 1 space after comma in function call; 9 found
    Open

                'print' => __( 'Print',         'read-offline' ),

    Space found before comma in function call
    Open

                    , parent::query_url( $post->ID,$post->post_name,$type )

    Space found before comma in function call
    Open

                    , ('print' == $type) ? '' : $type

    Expected 1 space before close parenthesis; 0 found
    Open

                    , ('print' == $type) ? 'onclick="read_offline_print_me();return false;"': ''

    Array item not aligned correctly; expected 16 spaces but found 17
    Open

                     'post' => 1,

    Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space
    Open

                $text = parent::$options['how']['link_text'];

    Expected 1 space before close parenthesis; 0 found
    Open

                $str_info = (1 == parent::$options['how']['icons_only']) ? '' : sprintf( '%s',$document_type );

    Space found before comma in function call
    Open

                    , ('print' == $type) ? __( 'Print','read-offline' ) : __( 'Download','read-offline' )

    Space found before comma in function call
    Open

                    , $str_info

    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 );

    Space found before comma in function call
    Open

                    , $post->post_name

    Expected 1 space before close parenthesis; 0 found
    Open

                    , ('print' == $type) ? '' : $type

    Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space
    Open

                $text = str_ireplace( '%title%', $post->post_title,$text );

    Expected 1 space after open parenthesis; 0 found
    Open

                $str_info = (1 == parent::$options['how']['icons_only']) ? '' : sprintf( '%s',$document_type );

    Expected 1 space before ":"; 0 found
    Open

                    , ('print' == $type) ? 'onclick="read_offline_print_me();return false;"': ''

    Space found before comma in function call
    Open

                    , array_filter( parent::$options['what']['formats'] )

    Found precision alignment of 1 spaces.
    Open

                     'page' => 1,

    Array closer not aligned correctly; expected 12 space(s) but found 16
    Open

                    )

    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 ) ) : ''

    Array item not aligned correctly; expected 16 spaces but found 17
    Open

                     'page' => 1,

    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 ) ) : ''

    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 );

    Newline required after opening brace
    Open

            if ( ! is_object( $post ) ) { return; }

    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 );

    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 );

    No space found after comma in function call
    Open

            wp_enqueue_style( 'read-offline-css',   READOFFLINE_URL . '/css/read-offline.css',array(), READOFFLINE_VERSION );

    No space found after comma in function call
    Open

                    , ('print' == $type) ? __( 'Print','read-offline' ) : __( 'Download','read-offline' )

    No space found after comma in function call
    Open

                $text = str_ireplace( '%title%', $post->post_title,$text );

    No space found after comma in function call
    Open

                $readoffline .= sprintf( '<div class="readoffline-embed-text">%s</div>',stripslashes( $text ) );

    No space found after comma in function call
    Open

                $str_info = (1 == parent::$options['how']['icons_only']) ? '' : sprintf( '%s',$document_type );

    No space found after comma in function call
    Open

                    , parent::query_url( $post->ID,$post->post_name,$type )

    No space found after comma in function call
    Open

                    , ('print' == $type) ? __( 'Print','read-offline' ) : __( 'Download','read-offline' )

    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 ) ) : ''

    No space found after comma in function call
    Open

                    , parent::query_url( $post->ID,$post->post_name,$type )

    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 ) ) : ''

    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 ) ) : ''

    There are no issues that match your filters.

    Category
    Status