Showing 44 of 52 total issues
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' ),
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' ) );
- 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
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_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,
- 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 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(
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 ) ) {
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;
}
- 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 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function upload( $file, $path, $dir_name = '', $mime_type = 'image/jpeg', $metadata = array(), $args = array() ) {
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' ) );
}
- 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_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 add_actions
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function add_actions() {
if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) {
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
Avoid too many return
statements within this method. Open
return $settings[ $name ];
Avoid too many return
statements within this method. Open
return $data;
Avoid too many return
statements within this method. Open
return (bool) $settings[ $name ];
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return '';
Avoid too many return
statements within this method. Open
return new WP_Error( 'object_not_inserted', sprintf( __( 'The object cannot be uploaded. Original error message: %s', 'wp-gcs-offload' ), $e->getMessage() ) );
Avoid too many return
statements within this method. Open
return $data;