modxcms/revolution

View on GitHub
core/model/modx/rest/modrestcurlclient.class.php

Summary

Maintainability
C
1 day
Test Coverage

Function toArray has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public static function toArray( $xml ) {
        if ( is_string( $xml ) ) $xml = new SimpleXMLElement( $xml );
        $children = $xml->children();
        if ( !$children ) return (string) $xml;
        $arr = array();
Severity: Minor
Found in core/model/modx/rest/modrestcurlclient.class.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

Function toXML has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public static function toXML( $data, $rootNodeName = 'ResultSet', &$xml=null ) {

        // turn off compatibility mode as simple xml throws a wobbly if you don't.
        if ( ini_get('zend.ze1_compatibility_mode') == 1 ) ini_set ( 'zend.ze1_compatibility_mode', 0 );
        if ( is_null( $xml ) ) $xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><'.$rootNodeName.'></'.$rootNodeName.'>');
Severity: Minor
Found in core/model/modx/rest/modrestcurlclient.class.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 setUrl has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function setUrl($ch,$host,$path,$method = 'GET',array $params = array(),array $options = array()) {
        $q = http_build_query($params);
        switch ($method) {
            case 'GET':
                $path .= (strpos($host,'?') === false ? '?' : '&').$q;
Severity: Minor
Found in core/model/modx/rest/modrestcurlclient.class.php - About 1 hr to fix

    Function setUrl has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function setUrl($ch,$host,$path,$method = 'GET',array $params = array(),array $options = array()) {
            $q = http_build_query($params);
            switch ($method) {
                case 'GET':
                    $path .= (strpos($host,'?') === false ? '?' : '&').$q;
    Severity: Minor
    Found in core/model/modx/rest/modrestcurlclient.class.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

    Function setAuth has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function setAuth($ch,array $options = array()) {
            $auth = false;
            if (!empty($options[modRestClient::OPT_USERPWD])) {
                $options[modRestClient::OPT_AUTHTYPE] = $this->modx->getOption(modRestClient::OPT_AUTHTYPE,$options,'BASIC');
                switch ($options[modRestClient::OPT_AUTHTYPE]) {
    Severity: Minor
    Found in core/model/modx/rest/modrestcurlclient.class.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

    Function setProxy has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function setProxy($ch,array $options = array()) {
            $proxyEnabled = false;
            /* if proxy is set, attempt to use it */
            $proxyHost = $this->modx->getOption('proxy_host',null,'');
            if (!empty($proxyHost)) {
    Severity: Minor
    Found in core/model/modx/rest/modrestcurlclient.class.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 setUrl has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function setUrl($ch,$host,$path,$method = 'GET',array $params = array(),array $options = array()) {
    Severity: Minor
    Found in core/model/modx/rest/modrestcurlclient.class.php - About 45 mins to fix

      Function setOptions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function setOptions($ch,array $options = array()) {
              /* always return us the result */
              curl_setopt($ch, CURLOPT_RETURNTRANSFER, !empty($options['curlopt_returntransfer']) ? $options['curlopt_returntransfer'] : 1);
              /* we dont want header gruft */
              curl_setopt($ch, CURLOPT_HEADER, !empty($options['curlopt_header']) ? $options['curlopt_header'] : 0);
      Severity: Minor
      Found in core/model/modx/rest/modrestcurlclient.class.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 request has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function request($host,$path,$method = 'GET',array $params = array(),array $options = array()) {
      Severity: Minor
      Found in core/model/modx/rest/modrestcurlclient.class.php - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status