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

                    ( '0' == parent::$options['pdffooter']['default_footer'][0] &&
                     '0' == parent::$options['pdffooter']['default_footer'][1] &&
                     '0' == parent::$options['pdffooter']['default_footer'][2] ) ) {
Severity: Major
Found in inc/class-read-offline-create.php and 1 other location - About 1 hr to fix
inc/class-read-offline-create.php on lines 498..500

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

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

Method widget has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function widget($args, $instance) {
        global $post;

        if (!is_single() && !is_page()) return;

Severity: Minor
Found in inc/class-read-offline-widget.php - About 1 hr to fix

    Method _split_content has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function _split_content( $html, $header ) {
    
            $all_tags   = ( 'all' === $header );
            $content    = array();
            $title      = '';
    Severity: Minor
    Found in inc/class-read-offline-create.php - About 1 hr to fix

      Function _create_tmp_directories has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          private function _create_tmp_directories() {
              global $wp_filesystem;
              if ( ! $wp_filesystem || ! is_object( $wp_filesystem ) ) {
                  WP_Filesystem(); }
              if ( ! is_object( $wp_filesystem ) ) {
      Severity: Minor
      Found in inc/class-read-offline.php - About 1 hr 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

              printf('<p><label for="%s">%s <textarea class="widefat" id="%s" name="%s" >%s</textarea></label></p>',$this->get_field_id('text'),__('Text:',$this->localizationDomain),$this->get_field_id('text'),$this->get_field_name('text'),esc_attr($text));
      Severity: Major
      Found in inc/class-read-offline-widget.php and 1 other location - About 1 hr to fix
      inc/class-read-offline-widget.php on lines 113..113

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

      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

              printf('<p><label for="%s">%s <input class="widefat" id="%s" name="%s" type="text" value="%s" /></label></p>',$this->get_field_id('title'),__('Title:',$this->localizationDomain),$this->get_field_id('title'),$this->get_field_name('title'),esc_attr($title));
      Severity: Major
      Found in inc/class-read-offline-widget.php and 1 other location - About 1 hr to fix
      inc/class-read-offline-widget.php on lines 114..114

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

      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

      Method __construct has 35 lines of code (exceeds 25 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 1 hr to fix

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

                    array(
                        'field_id'         => 'watermark_image',
                        'section_id'       => 'pdf_watermark',
                        'title'            => __( 'Image', 'read-offline' ),
                        'type'             => 'image',
        Severity: Major
        Found in inc/class-read-offline-admin-settings.php and 1 other location - About 1 hr to fix
        inc/class-read-offline-admin-settings.php on lines 918..925

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

        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

                    array(
                        'field_id'         => 'watermark_text',
                        'section_id'       => 'pdf_watermark',
                        'title'            => __( 'Text', 'read-offline' ),
                        'type'             => 'text',
        Severity: Major
        Found in inc/class-read-offline-admin-settings.php and 1 other location - About 1 hr to fix
        inc/class-read-offline-admin-settings.php on lines 926..933

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

        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

        Method replyToAddStyle has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function replyToAddStyle( $css ) {
                      return $css
                          . '
        
                  .page_title {
        Severity: Minor
        Found in inc/class-read-offline-admin-settings.php - About 1 hr to fix

          Method _pdf_add_annotations has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function _pdf_add_annotations( $content ) {
          
                  $anchors = array();
                  $doc     = new DOMDocument();
                  // START LibXML error management.
          Severity: Minor
          Found in inc/class-read-offline-create.php - About 1 hr to fix

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

                                  __( 'ISO Press', 'read-offline' ) => array(
                                      'RA0' => 'RA0 (860x1220 mm ; 33.86x48.03 in)',
                                      'RA1' => 'RA1 (610x860 mm ; 24.02x33.86 in)',
                                      'RA2' => 'RA2 (430x610 mm ; 16.93x24.02 in)',
                                      'RA3' => 'RA3 (305x430 mm ; 12.01x16.93 in)',
            Severity: Major
            Found in inc/class-read-offline-admin-settings.php and 1 other location - About 1 hr to fix
            inc/class-read-offline-admin-settings.php on lines 939..950

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

            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

                            'label'            => array(
                                '0.1' => '0.1',
                                '0.2' => '0.2',
                                '0.3' => '0.3',
                                '0.4' => '0.4',
            Severity: Major
            Found in inc/class-read-offline-admin-settings.php and 1 other location - About 1 hr to fix
            inc/class-read-offline-admin-settings.php on lines 386..397

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

            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 _remove_tmp_directories has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                private function _remove_tmp_directories() {
                    global $wp_filesystem;
                    if ( ! $wp_filesystem || ! is_object( $wp_filesystem ) ) {
                        WP_Filesystem(); }
                    if ( ! is_object( $wp_filesystem ) ) {
            Severity: Minor
            Found in inc/class-read-offline.php - About 55 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 _pdf_add_annotations has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                private function _pdf_add_annotations( $content ) {
            
                    $anchors = array();
                    $doc     = new DOMDocument();
                    // START LibXML error management.
            Severity: Minor
            Found in inc/class-read-offline-create.php - About 55 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 widget has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                function widget($args, $instance) {
                    global $post;
            
                    if (!is_single() && !is_page()) return;
            
            
            Severity: Minor
            Found in inc/class-read-offline-widget.php - About 55 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

                        $toc_stop  = ( '0' == parent::$options['pdf_layout']['toc'][1] ) ? 2 : parent::$options['pdf_layout']['toc'][1];
            Severity: Minor
            Found in inc/class-read-offline-create.php and 1 other location - About 50 mins to fix
            inc/class-read-offline-create.php on lines 708..708

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

            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

                        $toc_start = ( '0' == parent::$options['pdf_layout']['toc'][0] ) ? 1 : parent::$options['pdf_layout']['toc'][0];
            Severity: Minor
            Found in inc/class-read-offline-create.php and 1 other location - About 50 mins to fix
            inc/class-read-offline-create.php on lines 709..709

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

            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-shortcode.php and 2 other locations - About 45 mins to fix
            inc/class-read-offline-ux.php on lines 93..99
            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

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

                        $this->author_firstlast = 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 42..42

            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

            Severity
            Category
            Status
            Source
            Language