Showing 44 of 52 total issues
Function upload_to_cloud_storage
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
public function upload_to_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' ) );
}
- Read upRead up
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
File Attachment.php
has 340 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WPGCSOffload\Core\Attachment class
*
* @package WPGCSOffload
Function attachment_submitbox_misc_actions
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function attachment_submitbox_misc_actions( $id = null ) {
$attachment = Attachment::get( $id );
if ( ! $attachment ) {
return;
}
- Read upRead up
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 upload
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function upload( $file, $path, $dir_name = '', $mime_type = 'image/jpeg', $metadata = array(), $args = array() ) {
if ( ! $this->is_configured() ) {
return new WP_Error( 'client_not_configured', __( 'The Google Cloud Storage client is not configured properly.', 'wp-gcs-offload' ) );
}
- Read upRead up
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_to_cloud_storage
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function upload_to_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' ) );
}
Method attachment_submitbox_misc_actions
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function attachment_submitbox_misc_actions( $id = null ) {
$attachment = Attachment::get( $id );
if ( ! $attachment ) {
return;
}
Function delete_local_file
has a Cognitive Complexity of 16 (exceeds 5 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 ) );
}
- Read upRead up
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_setting
has a Cognitive Complexity of 15 (exceeds 5 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 ) ) {
- Read upRead up
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_from_cloud_storage
has a Cognitive Complexity of 15 (exceeds 5 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' ) );
}
- Read upRead up
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_from_cloud_storage
has a Cognitive Complexity of 15 (exceeds 5 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' ) );
}
- Read upRead up
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 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function upload( $file, $path, $dir_name = '', $mime_type = 'image/jpeg', $metadata = array(), $args = array() ) {
if ( ! $this->is_configured() ) {
return new WP_Error( 'client_not_configured', __( 'The Google Cloud Storage client is not configured properly.', 'wp-gcs-offload' ) );
}
Method get_attachment_ids
has 39 lines of code (exceeds 25 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,
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();
- Read upRead up
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' ) );
}
- Read upRead up
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();
- Read upRead up
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();
- Read upRead up
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 ) ) {
- Read upRead up
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' ) );
}
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' ) );
}
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] );