felixarntz/wp-gcs-offload

View on GitHub

Showing 44 of 52 total issues

Function render_status_message has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        public static function render_status_message( $status, $context = 'site' ) {
            ?>
            <p>
                <?php if ( 'activated' === $status ) : ?>
                    <?php printf( __( 'You have just activated %s.', 'wp-gcs-offload' ), '<strong>' . self::get_info( 'name' ) . '</strong>' ); ?>
Severity: Minor
Found in inc/WPGCSOffload/App.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_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;
            }
Severity: Minor
Found in inc/WPGCSOffload/Core/Attachment.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 delete has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        public function delete( $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 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 attachment_url_to_postid has a Cognitive Complexity of 6 (exceeds 5 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 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