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").
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))
{
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))
{
- 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 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))
{
- 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
CFRuntime
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
class CFRuntime
{
/*%******************************************************************************************%*/
// CONSTANTS
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))
{
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();
- 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 __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();
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
)
{
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();
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();
- 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 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.
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
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
- 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 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.
- 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 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))
{
Method authenticate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function authenticate($action, $opt = null, $domain = null, $signature_version = 2, $redirects = 0)
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))
{
- 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 $data;
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));
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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;
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76