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
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' ) );
}
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 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
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 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 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' ) );
}
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;
}
- 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
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;
- 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_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 ) );
}
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 ) {
Function get_cloud_storage_url
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function get_cloud_storage_url() {
$bucket_name = get_post_meta( $this->id, '_wpgcso_bucket_name', true );
if ( ! $bucket_name ) {
return false;
}
- 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"