Function getResponse
has a Cognitive Complexity of 201 (exceeds 5 allowed). Consider refactoring. Open
function getResponse(){
$this->incoming_payload = '';
if ($this->io_method() == 'socket') {
// loop until headers have been retrieved
- 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 connect
has a Cognitive Complexity of 153 (exceeds 5 allowed). Consider refactoring. Open
function connect($connection_timeout=0,$response_timeout=30){
// For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like
// "regular" socket.
// TODO: disabled for now because OpenSSL must be *compiled* in (not just
// loaded), and until PHP5 stream_get_wrappers is not available.
- 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
File class.soap_transport_http.php
has 874 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
Method getResponse
has 298 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getResponse(){
$this->incoming_payload = '';
if ($this->io_method() == 'socket') {
// loop until headers have been retrieved
Method connect
has 172 lines of code (exceeds 25 allowed). Consider refactoring. Open
function connect($connection_timeout=0,$response_timeout=30){
// For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like
// "regular" socket.
// TODO: disabled for now because OpenSSL must be *compiled* in (not just
// loaded), and until PHP5 stream_get_wrappers is not available.
Function getCookiesForRequest
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
function getCookiesForRequest($cookies, $secure=false) {
$cookie_str = '';
if ((! is_null($cookies)) && (is_array($cookies))) {
foreach ($cookies as $cookie) {
if (! is_array($cookie)) {
- 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 sendRequest
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
function sendRequest($data, $cookies = NULL) {
// build cookie string
$cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https')));
// build payload
- 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
soap_transport_http
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class soap_transport_http extends nusoap_base {
var $url = '';
var $uri = '';
var $digest_uri = '';
Method parseCookie
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parseCookie($cookie_str) {
$cookie_str = str_replace('; ', ';', $cookie_str) . ';';
$data = preg_split('/;/', $cookie_str);
$value_str = $data[0];
Function setCredentials
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function setCredentials($username, $password, $authtype = 'basic', $digestRequest = array(), $certRequest = array()) {
$this->debug("setCredentials username=$username authtype=$authtype digestRequest=");
$this->appendDebug($this->varDump($digestRequest));
$this->debug("certRequest=");
$this->appendDebug($this->varDump($certRequest));
- 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 setCredentials
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setCredentials($username, $password, $authtype = 'basic', $digestRequest = array(), $certRequest = array()) {
$this->debug("setCredentials username=$username authtype=$authtype digestRequest=");
$this->appendDebug($this->varDump($digestRequest));
$this->debug("certRequest=");
$this->appendDebug($this->varDump($certRequest));
Method getCookiesForRequest
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getCookiesForRequest($cookies, $secure=false) {
$cookie_str = '';
if ((! is_null($cookies)) && (is_array($cookies))) {
foreach ($cookies as $cookie) {
if (! is_array($cookie)) {
Method sendRequest
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function sendRequest($data, $cookies = NULL) {
// build cookie string
$cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https')));
// build payload
Method decodeChunked
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function decodeChunked($buffer, $lb){
// length := 0
$length = 0;
$new = '';
Function setURL
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function setURL($url) {
$this->url = $url;
$u = parse_url($url);
foreach($u as $k => $v){
- 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
function send($data, $timeout=0, $response_timeout=30, $cookies=NULL) {
$this->debug('entered send() with data of length: '.strlen($data));
$this->tryagain = 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 setURL
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setURL($url) {
$this->url = $url;
$u = parse_url($url);
foreach($u as $k => $v){
Consider simplifying this complex logical expression. Open
if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm'))
return 'curl';
Function parseCookie
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function parseCookie($cookie_str) {
$cookie_str = str_replace('; ', ';', $cookie_str) . ';';
$data = preg_split('/;/', $cookie_str);
$value_str = $data[0];
- 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 io_method
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function io_method() {
if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm'))
return 'curl';
if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm'))
return 'socket';
- 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 decodeChunked
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function decodeChunked($buffer, $lb){
// length := 0
$length = 0;
$new = '';
- 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
Consider simplifying this complex logical expression. Open
if (
($http_status >= 300 && $http_status <= 307) ||
($http_status >= 400 && $http_status <= 417) ||
($http_status >= 501 && $http_status <= 505)
) {
Method setCredentials
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function setCredentials($username, $password, $authtype = 'basic', $digestRequest = array(), $certRequest = array()) {
Method setProxy
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 'basic') {
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $data;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Similar blocks of code found in 2 locations. Consider refactoring. Open
class soap_transport_http extends nusoap_base {
var $url = '';
var $uri = '';
var $digest_uri = '';
- 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 9371.
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