mgribov/apiscrape

View on GitHub

Showing 8 of 8 total issues

Function request has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    public function request($path, $params = array(), $method = 'GET', $headers = array()) {
        $path_get = $path;
        $etag = null;
        $current = false;
                
Severity: Minor
Found in src/Scrape/Client/HttpClient.php - About 4 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 request has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function request($path, $params = array(), $method = 'GET', $headers = array()) {
        $path_get = $path;
        $etag = null;
        $current = false;
                
Severity: Major
Found in src/Scrape/Client/HttpClient.php - About 2 hrs to fix

    Method save has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function save($path, $response, $header) {
            if (!(is_array($response) && count($response) > 0)) {
                $this->__debug("no valid response for $path, will not save, invalidating any saved copy");            
                $this->backend->delete($path);
                return false;
    Severity: Minor
    Found in src/Scrape/Storage/HttpStorage.php - About 1 hr to fix

      Method __curl has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function __curl($path, $method = 'GET', array $params = array(), array $headers = array()) {
              $this->ret = [];
              
              // only JSON for now
              $headers[] = 'Content-Type: application/json';
      Severity: Minor
      Found in src/Scrape/Client/HttpClient.php - About 1 hr to fix

        Function __construct has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            public function __construct(array $config = array(), $debug = false) {
                // storage is required for mirroring
                if (!array_key_exists('storage', $config)) {
                    throw new Exception("Missing mandatory storage config");
                }
        Severity: Minor
        Found in src/Scrape/Client/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 save has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public function save($path, $response, $header) {
                if (!(is_array($response) && count($response) > 0)) {
                    $this->__debug("no valid response for $path, will not save, invalidating any saved copy");            
                    $this->backend->delete($path);
                    return false;
        Severity: Minor
        Found in src/Scrape/Storage/HttpStorage.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 __construct has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function __construct(array $config = array(), $debug = false) {
                // storage is required for mirroring
                if (!array_key_exists('storage', $config)) {
                    throw new Exception("Missing mandatory storage config");
                }
        Severity: Minor
        Found in src/Scrape/Client/Client.php - About 1 hr to fix

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

              protected function __curl($path, $method = 'GET', array $params = array(), array $headers = array()) {
                  $this->ret = [];
                  
                  // only JSON for now
                  $headers[] = 'Content-Type: application/json';
          Severity: Minor
          Found in src/Scrape/Client/HttpClient.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

          Severity
          Category
          Status
          Source
          Language