soderlind/read-offline

View on GitHub

Showing 1,262 of 1,262 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            $this->author_lastfirst = sprintf( '%s, %s', get_the_author_meta( 'user_firstname', $post->post_author ), get_the_author_meta( 'user_lastname', $post->post_author ) );
Severity: Minor
Found in inc/class-read-offline-create.php and 1 other location - About 45 mins to fix
inc/class-read-offline-create.php on lines 41..41

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 3 locations. Consider refactoring.
Open

        $post_types = array_keys(array_intersect(
            self::$options['where']['post_types'],
            array(
                 'post' => 1,
                 'page' => 1,
Severity: Major
Found in inc/class-read-offline.php and 2 other locations - About 45 mins to fix
inc/class-read-offline-shortcode.php on lines 79..85
inc/class-read-offline-ux.php on lines 93..99

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

Function __construct has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private function __construct() {

        self::$options = get_option( 'Read_Offline_Admin_Settings' );

        // Only generate files for formats selected in plugin settings
Severity: Minor
Found in inc/class-read-offline.php - About 45 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

Avoid deeply nested control flow statements.
Open

                            if ( filesize( $attached_file ) > 0 ) {
                                parent::read_offline_download( $attached_file,$mime_type,wp_create_nonce( 'read-offline-download' ) );
                                exit();
                            }
Severity: Major
Found in inc/class-read-offline-parser.php - About 45 mins to fix

    Function _header_footer has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        private function _header_footer( $post, $type ) {
            $val = '';
            switch ( $type ) {
                case 'document_title':
                    $val = $post->post_title;
    Severity: Minor
    Found in inc/class-read-offline-create.php - About 45 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                case 'css':
                    $print_css = ( '' != parent::$options['print']['css'] ) ? parent::$options['print']['css'] : '';
                    break;
    Severity: Minor
    Found in inc/class-read-offline-create.php and 1 other location - About 40 mins to fix
    inc/class-read-offline-create.php on lines 124..126

    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 44.

    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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                case 'css':
                    $print_css = ( '' != parent::$options['epub']['css'] ) ? parent::$options['epub']['css'] : '';
                    break;
    Severity: Minor
    Found in inc/class-read-offline-create.php and 1 other location - About 40 mins to fix
    inc/class-read-offline-create.php on lines 76..78

    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 44.

    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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                        if ( '' != $image_url ) {
                            $pdf->AddPageByArray(
                                array(
                                    'suppress' => 'on', // supress header
                                )
    Severity: Minor
    Found in inc/class-read-offline-create.php and 1 other location - About 40 mins to fix
    inc/class-read-offline-create.php on lines 665..678

    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 43.

    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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                        if ( '' != $image_url ) {
                            $pdf->AddPageByArray(
                                array(
                                    'suppress' => 'on', // supress header
                                )
    Severity: Minor
    Found in inc/class-read-offline-create.php and 1 other location - About 40 mins to fix
    inc/class-read-offline-create.php on lines 641..656

    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 43.

    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

    Found precision alignment of 1 spaces.
    Open

     elseif ( version_compare( PHP_VERSION, '5.6.0' ) < 0 ) {
    Severity: Minor
    Found in read-offline.php by phpcodesniffer

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

    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

    Function read_offline_update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function read_offline_update() {
    
            $options = get_option( 'Read_Offline' );
            $version = (isset( $options['version'] )) ? $options['version'] : '0';
    
    
    Severity: Minor
    Found in inc/class-read-offline.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

    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,
    Severity
    Category
    Status
    Source
    Language