felixarntz/wp-gcs-offload

View on GitHub

Showing 52 of 52 total issues

Function upload_sizes_to_cloud_storage has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        private function upload_sizes_to_cloud_storage( $meta_sizes, &$image_sizes, $main_file, $dir_name, $mime_type, $args ) {
            $uploads = wp_get_upload_dir();

            $errors = new WP_Error();

Severity: Minor
Found in inc/WPGCSOffload/Core/Attachment.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

Function download has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        public function download( $file, $path, $dir_name = '' ) {
            if ( ! $this->is_configured() ) {
                return new WP_Error( 'client_not_configured', __( 'The Google Cloud Storage client is not configured properly.', 'wp-gcs-offload' ) );
            }

Severity: Minor
Found in inc/WPGCSOffload/Core/Client.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

Function delete_local_sizes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        private function delete_local_sizes( $meta_sizes, $image_sizes, $main_file, $dir_name ) {
            $uploads = wp_get_upload_dir();

            $errors = new WP_Error();

Severity: Minor
Found in inc/WPGCSOffload/Core/Attachment.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

Function download_sizes_from_google_cloud_storage has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        private function download_sizes_from_google_cloud_storage( $meta_sizes, $image_sizes, $main_file, $dir_name ) {
            $uploads = wp_get_upload_dir();

            $errors = new WP_Error();

Severity: Minor
Found in inc/WPGCSOffload/Core/Attachment.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

Function delete_sizes_from_google_cloud_storage has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        private function delete_sizes_from_google_cloud_storage( $meta_sizes, $image_sizes, $main_file, $dir_name ) {
            $errors = new WP_Error();

            foreach ( $meta_sizes as $size => $data ) {
                if ( ! in_array( $size, $image_sizes, true ) ) {
Severity: Minor
Found in inc/WPGCSOffload/Core/Attachment.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

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

        public function delete_from_cloud_storage( $metadata = false, $suppress_hooks = false ) {
            if ( ! Client::instance()->is_configured() ) {
                return new WP_Error( 'client_not_configured', __( 'The Google Cloud Storage client is not configured properly.', 'wp-gcs-offload' ) );
            }

Severity: Minor
Found in inc/WPGCSOffload/Core/Attachment.php - About 1 hr to fix

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

            public function download_from_cloud_storage( $metadata = false, $suppress_hooks = false ) {
                if ( ! Client::instance()->is_configured() ) {
                    return new WP_Error( 'client_not_configured', __( 'The Google Cloud Storage client is not configured properly.', 'wp-gcs-offload' ) );
                }
    
    
    Severity: Minor
    Found in inc/WPGCSOffload/Core/Attachment.php - About 1 hr to fix

      Method attachment_url_to_postid has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              public function attachment_url_to_postid( $id, $url ) {
                  if ( ! $id && preg_match( '#^https:' . str_replace( '.', '\.', Client::BASE_URL ) . '([A-Za-z0-9\.\-_]+)/([A-Za-z0-9\.\-_]+)/(\S+)$#', $url, $matches ) ) {
                      $bucket_name = $matches[1];
                      $dir_name = $matches[2];
                      $file_name = preg_replace( '#\-(\d+)x(\d+)\.#', '.', $matches[3] );
      Severity: Minor
      Found in inc/WPGCSOffload/Core/URLFixer.php - About 1 hr to fix

        Method get_site_configuration_fields has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                public function get_site_configuration_fields() {
                    return array(
                        'gcs_mode'                    => array(
                            'title'                        => __( 'Plugin Mode', 'wp-gcs-offload' ),
                            'description'                => __( 'Specify whether your site should prefer local or remote attachment files.', 'wp-gcs-offload' ),
        Severity: Minor
        Found in inc/WPGCSOffload/Admin/Settings.php - About 1 hr to fix

          Function request has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                  public function request() {
                      $name = str_replace( 'wpgcso_', '', $_REQUEST['action'] );
          
                      if ( ! isset( $this->actions[ $name ] ) ) {
                          wp_send_json_error( __( 'Invalid action.', 'wp-gcs-offload' ) );
          Severity: Minor
          Found in inc/WPGCSOffload/Core/AjaxHandler.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

          Function get has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                  public static function get( $id = null ) {
                      if ( ! $id ) {
                          $post = get_post();
                          if ( ! $post ) {
                              return null;
          Severity: Minor
          Found in inc/WPGCSOffload/Core/Attachment.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

          Function get_cloud_storage_image_downsize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                  public function get_cloud_storage_image_downsize( $size = 'thumbnail' ) {
                      $gcs_url = $this->get_cloud_storage_url();
                      if ( ! $gcs_url ) {
                          return false;
                      }
          Severity: Minor
          Found in inc/WPGCSOffload/Core/Attachment.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

          Function get_attachment_ids has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                  public function get_attachment_ids( $mode = 'all', $number = -1, $offset = 0 ) {
                      $args = array(
                          'posts_per_page'            => $number,
                          'offset'                    => $offset,
                          'no_found_rows'                => true,
          Severity: Minor
          Found in inc/WPGCSOffload/Core/BackgroundSync.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

          Method delete_local_file has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  public function delete_local_file( $metadata = false, $suppress_hooks = false ) {
                      if ( ! $this->is_cloud_storage_file() ) {
                          return new WP_Error( 'not_in_cloud_storage', sprintf( __( 'The files for attachment %d cannot be deleted since they are not available on Google Cloud Storage.', 'wp-gcs-offload' ), $this->id ) );
                      }
          
          
          Severity: Minor
          Found in inc/WPGCSOffload/Core/Attachment.php - About 1 hr to fix

            Method add_components has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    public function add_components( $wpod ) {
                        $wpod->add_components( array(
                            Admin::MENU_SLUG            => array(
                                'screens'                    => array(
                                    Admin::SCREEN_SLUG            => array(
            Severity: Minor
            Found in inc/WPGCSOffload/Admin/Menu.php - About 1 hr to fix

              Method get_setting has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      public function get_setting( $name ) {
                          if ( Admin::is_network_active() && ( 'authentication_key' === $name || 'bucket_name' === $name ) ) {
                              $constant_name = $this->get_setting_constant_name( $name );
              
                              if ( defined( $constant_name ) ) {
              Severity: Minor
              Found in inc/WPGCSOffload/Admin/Settings.php - About 1 hr to fix

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

                        public function setup_sync_assistant() {
                            if ( ! Client::instance()->is_configured() ) {
                                return;
                            }
                
                
                Severity: Minor
                Found in inc/WPGCSOffload/Core/Core.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

                Method upload has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        public function upload( $file, $path, $dir_name = '', $mime_type = 'image/jpeg', $metadata = array(), $args = array() ) {
                Severity: Minor
                Found in inc/WPGCSOffload/Core/Client.php - About 45 mins to fix

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

                          public function get_info( $file, $dir_name = '' ) {
                              if ( ! $this->is_configured() ) {
                                  return new WP_Error( 'client_not_configured', __( 'The Google Cloud Storage client is not configured properly.', 'wp-gcs-offload' ) );
                              }
                  
                  
                  Severity: Minor
                  Found in inc/WPGCSOffload/Core/Client.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

                  Method upload_sizes_to_cloud_storage has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          private function upload_sizes_to_cloud_storage( $meta_sizes, &$image_sizes, $main_file, $dir_name, $mime_type, $args ) {
                  Severity: Minor
                  Found in inc/WPGCSOffload/Core/Attachment.php - About 45 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language