felixarntz/wp-gcs-offload

View on GitHub
inc/WPGCSOffload/Core/Client.php

Summary

Maintainability
C
1 day
Test Coverage

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' ) );
            }

Severity: Minor
Found in inc/WPGCSOffload/Core/Client.php - About 2 hrs 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 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' ) );
            }

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

    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 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 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

      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() ) );
      Severity: Major
      Found in inc/WPGCSOffload/Core/Client.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return $data;
        Severity: Major
        Found in inc/WPGCSOffload/Core/Client.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return $data;
          Severity: Major
          Found in inc/WPGCSOffload/Core/Client.php - About 30 mins to fix

            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

            There are no issues that match your filters.

            Category
            Status