soderlind/read-offline

View on GitHub

Showing 35 of 1,262 total issues

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

      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

      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

        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

        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

          Avoid too many return statements within this method.
          Open

                          return add_action( 'admin_notices', function() use ( $error ) {
                                  $msg[] = '<div class="error"><p>';
                                  $msg[] = '<strong>Read Offline</strong>: ';
                                  $msg[] = sprintf( __( 'wp_upload_bits failed,  error: "<strong>%s</strong>','read-offline' ), $error );
                                  $msg[] = '</p></div>';
          Severity: Major
          Found in inc/class-read-offline.php - About 30 mins to fix

            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

              Severity
              Category
              Status
              Source
              Language