keboola/gooddata-php-client

View on GitHub

Showing 60 of 60 total issues

File Client.php has 435 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @package gooddata-php-client
 * @copyright Keboola
 * @author Jakub Matejka <jakub@keboola.com>
Severity: Minor
Found in src/Client.php - About 6 hrs to fix

    Function diff has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

        public function diff($pid, $model)
        {
            $uri = "/gdc/projects/$pid/model/diff?includeDeprecated=true&includeGrain=true";
            $result = $this->client->post($uri, ['diffRequest' => ['targetModel' => $model]]);
    
    
    Severity: Minor
    Found in src/ProjectModel.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

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

        public function normalizeModel($model)
        {
            foreach ($model['projectModel']['datasets'] as &$d) {
                if (isset($d['dataset']['anchor']['attribute']['labels'])) {
                    foreach ($d['dataset']['anchor']['attribute']['labels'] as &$l) {
    Severity: Minor
    Found in src/ProjectModel.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

    Method unaccent has 122 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function unaccent($string)
        {
            if (!preg_match('/[\x80-\xff]/', $string)) {
                return $string;
            }
    Severity: Major
    Found in src/Utility.php - About 4 hrs to fix

      Method getDataLoadManifest has 119 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function getDataLoadManifest(
              $identifier,
              array $columns,
              $incrementalLoad = false
          ) {
      Severity: Major
      Found in src/Datasets.php - About 4 hrs to fix

        Client has 35 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Client
        {
            /**
             * Number of retries for one API call
             */
        Severity: Minor
        Found in src/Client.php - About 4 hrs to fix

          Function getDataLoadManifest has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function getDataLoadManifest(
                  $identifier,
                  array $columns,
                  $incrementalLoad = false
              ) {
          Severity: Minor
          Found in src/Datasets.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

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

                  $handlerStack->push(Middleware::retry(
                      function ($retries, RequestInterface $request, ResponseInterface $response = null, $error = null) {
                          if ($retries >= self::RETRIES_COUNT) {
                              return false;
                          } elseif ($response && $response->getStatusCode() > 499) {
          Severity: Major
          Found in src/WebDav.php and 1 other location - About 3 hrs to fix
          src/Client.php on lines 100..115

          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 144.

          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

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

                  $handlerStack->push(Middleware::retry(
                      function ($retries, RequestInterface $request, ResponseInterface $response = null, $error = null) {
                          if ($retries >= self::RETRIES_COUNT) {
                              return false;
                          } elseif ($response && $response->getStatusCode() > 499) {
          Severity: Major
          Found in src/Client.php and 1 other location - About 3 hrs to fix
          src/WebDav.php on lines 54..69

          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 144.

          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

          File Projects.php has 285 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          /**
           * @package gooddata-php-client
           * @copyright Keboola
           * @author Jakub Matejka <jakub@keboola.com>
          Severity: Minor
          Found in src/Projects.php - About 2 hrs to fix

            Function pollEtlTask has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

                private function pollEtlTask($uri)
                {
                    $try = 1;
                    do {
                        sleep(min(pow(2, $try), rand(15, 20)));
            Severity: Minor
            Found in src/Datasets.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 request has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

                public function request($method, $uri, $params = [], $retries = 5)
                {
                    $startTime = time();
            
                    $options = $this->guzzleOptions;
            Severity: Minor
            Found in src/Client.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 diff has 65 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function diff($pid, $model)
                {
                    $uri = "/gdc/projects/$pid/model/diff?includeDeprecated=true&includeGrain=true";
                    $result = $this->client->post($uri, ['diffRequest' => ['targetModel' => $model]]);
            
            
            Severity: Major
            Found in src/ProjectModel.php - About 2 hrs to fix

              Function getToFile has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getToFile($uri, $filename, $retries = 20)
                  {
                      $this->refreshToken();
                      $startTime = time();
              
              
              Severity: Minor
              Found in src/Client.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 update has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function update($pid, $model, $dryRun = false, $multivalueAttributes = [])
                  {
                      $model = $this->normalizeModel($model);
              
                      $update = $this->diff($pid, $model);
              Severity: Minor
              Found in src/ProjectModel.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 seemsUtf8 has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function seemsUtf8($string)
                  {
                      for ($i = 0; $i < strlen($string); $i++) {
                          if (ord($string[$i]) < 0x80) {
                              continue;   # 0bbbbbbb
              Severity: Minor
              Found in src/Utility.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 saveLogs has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function saveLogs($folderName, $logFile)
                  {
                      $errors = [];
              
                      $uploadFile = "$folderName/upload_status.json";
              Severity: Minor
              Found in src/WebDav.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

              File Datasets.php has 252 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              /**
               * @package gooddata-php-client
               * @copyright Keboola
               * @author Jakub Matejka <jakub@keboola.com>
              Severity: Minor
              Found in src/Datasets.php - About 2 hrs to fix

                Method getToFile has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getToFile($uri, $filename, $retries = 20)
                    {
                        $this->refreshToken();
                        $startTime = time();
                
                
                Severity: Minor
                Found in src/Client.php - About 1 hr to fix

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

                      public function __construct($username, $password, $url = '')
                      {
                          $this->username = $username;
                          $this->password = $password;
                  
                  
                  Severity: Minor
                  Found in src/WebDav.php - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language