soderlind/read-offline

View on GitHub

Showing 1,262 of 1,262 total issues

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

                    $attachments = new WP_Query( array(
                        'post_type'      => 'attachment',
                        'post_status'    => 'any',
                        'posts_per_page' => 500,
                        'post_parent'    => $post_id,
Severity: Minor
Found in inc/class-read-offline-parser.php and 1 other location - About 30 mins to fix
inc/class-read-offline.php on lines 157..163

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

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

        if ( get_option( 'permalink_structure' ) ) {
            return sprintf('%s/read-offline/%s/%s.%s%s',
                site_url(),$post_id,$name,$format,
                ( $refresh ) ? '?read-offline-code=' . $code  : ''
            );
Severity: Minor
Found in inc/class-read-offline.php and 1 other location - About 30 mins to fix
inc/class-read-offline.php on lines 77..82

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

Avoid too many return statements within this method.
Open

                return $post_id; }
Severity: Major
Found in inc/class-read-offline.php - About 30 mins to fix

    Function image_create_frome_image has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function image_create_frome_image( $filepath ) {
            $type = exif_imagetype( $filepath ); // [] if you don't have exif you could use getImageSize()
            $allowed_types = array(
                1,  // [] gif
                2,  // [] jpg
    Severity: Minor
    Found in inc/class-read-offline.php - About 25 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 _get_taxonomies_terms has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        private function _get_taxonomies_terms( $post ) {
            // get post type by post
            $post_type = $post->post_type;
    
            // get post type taxonomies
    Severity: Minor
    Found in inc/class-read-offline-create.php - About 25 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

    Inline control structures are not allowed
    Open

    if ( ! defined( 'ABSPATH' ) ) exit;
    Severity: Minor
    Found in read-offline.php by phpcodesniffer

    Unknown property 'margin-header'.
    Open

        margin-header: 5mm; /*any of the usual CSS values for margins*/
    Severity: Minor
    Found in templates/pdf/default-print.css by csslint

    Unknown property 'margin-header'.
    Open

        margin-header: 5mm; /*any of the usual CSS values for margins*/
    Severity: Minor
    Found in templates/pdf/custom-print.css by csslint

    Rule is empty.
    Open

    .mpdf_toc_t_level_2 {    /* Title level 2 */
    Severity: Minor
    Found in templates/pdf/custom-print.css by csslint

    Rule doesn't have all its properties in alphabetical order.
    Open

    @page {
    Severity: Minor
    Found in templates/pdf/default-print.css by csslint

    Unknown property 'header'.
    Open

        header: pdfheader;
    Severity: Minor
    Found in templates/pdf/default-print.css by csslint

    Attribute selectors with ^= are slow!
    Open

    a[href^="http://"]::after,
    Severity: Minor
    Found in templates/print/custom-print.css by csslint

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

    Rule is empty.
    Open

    .mpdf_toc_p_level_0 {    /* Page no. level 0 - may be inside <a> */
    Severity: Minor
    Found in templates/pdf/custom-print.css by csslint

    Rule is empty.
    Open

    .mpdf_toc_p_level_1 {    /* Page no. level 1 - may be inside <a> */
    Severity: Minor
    Found in templates/pdf/custom-print.css by csslint

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

    Unknown property 'footer'.
    Open

        footer: pdffooter;
    Severity: Minor
    Found in templates/pdf/default-print.css by csslint

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

    Rule is empty.
    Open

    .mpdf_toc_p_level_2 {    /* Page no. level 2 - may be inside <a> */
    Severity: Minor
    Found in templates/pdf/custom-print.css by csslint
    Severity
    Category
    Status
    Source
    Language