modxcms/revolution

View on GitHub
core/model/aws/sdk.class.php

Summary

Maintainability
F
1 wk
Test Coverage

File sdk.class.php has 792 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/*
 * Copyright 2010-2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
Severity: Major
Found in core/model/aws/sdk.class.php - About 1 day to fix

    Method authenticate has 225 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function authenticate($action, $opt = null, $domain = null, $signature_version = 2, $redirects = 0)
        {
            // Handle nulls
            if (is_null($signature_version))
            {
    Severity: Major
    Found in core/model/aws/sdk.class.php - About 1 day to fix

      Function authenticate has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
      Open

          public function authenticate($action, $opt = null, $domain = null, $signature_version = 2, $redirects = 0)
          {
              // Handle nulls
              if (is_null($signature_version))
              {
      Severity: Minor
      Found in core/model/aws/sdk.class.php - About 7 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

      Function parse_callback has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
      Open

          public function parse_callback($response, $headers = null)
          {
              // Shorten this so we have a (mostly) single code path
              if (isset($response->body))
              {
      Severity: Minor
      Found in core/model/aws/sdk.class.php - About 6 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

      CFRuntime has 30 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class CFRuntime
      {
          /*%******************************************************************************************%*/
          // CONSTANTS
      
      
      Severity: Minor
      Found in core/model/aws/sdk.class.php - About 3 hrs to fix

        Method parse_callback has 89 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function parse_callback($response, $headers = null)
            {
                // Shorten this so we have a (mostly) single code path
                if (isset($response->body))
                {
        Severity: Major
        Found in core/model/aws/sdk.class.php - About 3 hrs to fix

          Function __aws_sdk_ua_callback has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

          function __aws_sdk_ua_callback()
          {
              $ua_append = '';
              $extensions = get_loaded_extensions();
              $sorted_extensions = array();
          Severity: Minor
          Found in core/model/aws/sdk.class.php - About 3 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 __aws_sdk_ua_callback has 60 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function __aws_sdk_ua_callback()
          {
              $ua_append = '';
              $extensions = get_loaded_extensions();
              $sorted_extensions = array();
          Severity: Major
          Found in core/model/aws/sdk.class.php - About 2 hrs to fix

            Consider simplifying this complex logical expression.
            Open

                    if (
                        (isset($headers['content-type']) && ($headers['content-type'] === 'text/xml' || $headers['content-type'] === 'application/xml')) || // We know it's XML
                        (!isset($headers['content-type']) && (stripos($body, '<?xml') === 0 || strpos($body, '<Error>') === 0) || preg_match('/^<(\w*) xmlns="http(s?):\/\/(\w*).amazon(aws)?.com/im', $body)) // Sniff for XML
                    )
                    {
            Severity: Critical
            Found in core/model/aws/sdk.class.php - About 2 hrs to fix

              Method session_based_auth has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function session_based_auth($key = null, $secret_key = null, $token = null)
                  {
                      // Instantiate the utilities class.
                      $this->util = new $this->utilities_class();
              
              
              Severity: Minor
              Found in core/model/aws/sdk.class.php - About 1 hr to fix

                Function session_based_auth has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function session_based_auth($key = null, $secret_key = null, $token = null)
                    {
                        // Instantiate the utilities class.
                        $this->util = new $this->utilities_class();
                
                
                Severity: Minor
                Found in core/model/aws/sdk.class.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

                Method send has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function send($clear_after_send = true)
                    {
                        if ($this->use_batch_flow)
                        {
                            // When we send the request, disable batch flow.
                Severity: Minor
                Found in core/model/aws/sdk.class.php - About 1 hr to fix

                  Method autoloader has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function autoloader($class)
                      {
                          $path = dirname(__FILE__) . DIRECTORY_SEPARATOR;
                  
                          // Amazon SDK classes
                  Severity: Minor
                  Found in core/model/aws/sdk.class.php - About 1 hr to fix

                    Function autoloader has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static function autoloader($class)
                        {
                            $path = dirname(__FILE__) . DIRECTORY_SEPARATOR;
                    
                            // Amazon SDK classes
                    Severity: Minor
                    Found in core/model/aws/sdk.class.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 send has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function send($clear_after_send = true)
                        {
                            if ($this->use_batch_flow)
                            {
                                // When we send the request, disable batch flow.
                    Severity: Minor
                    Found in core/model/aws/sdk.class.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

                    Method set_cache_config has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function set_cache_config($location, $gzip = true)
                        {
                            // If we have an array, we're probably passing in Memcached servers and ports.
                            if (is_array($location))
                            {
                    Severity: Minor
                    Found in core/model/aws/sdk.class.php - About 1 hr to fix

                      Method authenticate has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          public function authenticate($action, $opt = null, $domain = null, $signature_version = 2, $redirects = 0)
                      Severity: Minor
                      Found in core/model/aws/sdk.class.php - About 35 mins to fix

                        Function set_cache_config has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function set_cache_config($location, $gzip = true)
                            {
                                // If we have an array, we're probably passing in Memcached servers and ports.
                                if (is_array($location))
                                {
                        Severity: Minor
                        Found in core/model/aws/sdk.class.php - About 35 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

                        Avoid too many return statements within this method.
                        Open

                                return $data;
                        Severity: Major
                        Found in core/model/aws/sdk.class.php - About 30 mins to fix

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                  if ($this->use_cache_flow)
                                  {
                                      // Generate an identifier specific to this particular set of arguments.
                                      $cache_id = $this->key . '_' . get_class($this) . '_' . $action . '_' . sha1(serialize($method_arguments));
                          
                          
                          Severity: Major
                          Found in core/model/aws/sdk.class.php and 1 other location - About 4 hrs to fix
                          core/model/aws/services/s3.class.php on lines 358..381

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 173.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                              public function cache_callback($action, $opt = null, $domain = null, $signature_version = 2)
                              {
                                  // Disable the cache flow since it's already been handled.
                                  $this->use_cache_flow = false;
                          
                          
                          Severity: Major
                          Found in core/model/aws/sdk.class.php and 1 other location - About 1 hr to fix
                          core/model/aws/services/s3.class.php on lines 827..841

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 103.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          There are no issues that match your filters.

                          Category
                          Status