zendesk/zendesk_api_client_php

View on GitHub

Showing 41 of 41 total issues

Method updateMany has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function updateMany(array $params, $key = 'ids')
    {
        try {
            $route = $this->getRoute(__FUNCTION__);
        } catch (RouteException $e) {
Severity: Minor
Found in src/Zendesk/API/Traits/Resource/UpdateMany.php - About 1 hr to fix

    Function pageSize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function pageSize()
        {
            if (isset($this->pageSize)) {
                return $this->pageSize;
            } else if (isset($this->params['page[size]'])) {
    Severity: Minor
    Found in src/Zendesk/API/Traits/Utility/Pagination/AbstractStrategy.php - About 55 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 __construct has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function __construct($strategy, array $options)
        {
            if (! in_array($strategy, self::getValidAuthStrategies())) {
                throw new AuthException('Invalid auth strategy set, please use `'
                                        . implode('` or `', self::getValidAuthStrategies())
    Severity: Minor
    Found in src/Zendesk/API/Utilities/Auth.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 __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            $subdomain,
            $username = '',
            $scheme = "https",
            $hostname = "zendesk.com",
            $port = 443,
    Severity: Minor
    Found in src/Zendesk/API/HttpClient.php - About 45 mins to fix

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

          public function getMatches(array $tokens, array $info = [])
          {
              $input = $this->getInput($tokens);
      
              array_shift($tokens);
      Severity: Minor
      Found in src/Zendesk/Console/Matchers/SubResourceMatcher.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 upload has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function upload(array $params)
          {
              if (! $this->hasKeys($params, ['file'])) {
                  throw new MissingParametersException(__METHOD__, ['file']);
              }
      Severity: Minor
      Found in src/Zendesk/API/Resources/Core/Attachments.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 upload has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function upload(array $params, $routeKey = __FUNCTION__)
          {
              if (! array_key_exists('file', $params)) {
                  throw new MissingParametersException(__METHOD__, ['file']);
              }
      Severity: Minor
      Found in src/Zendesk/API/Traits/Resource/MultipartUpload.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

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

              try {
                  $route = $this->getRoute($routeKey, ['id' => $id]);
              } catch (RouteException $e) {
                  if (! isset($this->resourceName)) {
                      $this->resourceName = $this->getResourceNameFromClass();
      Severity: Major
      Found in src/Zendesk/API/Traits/Resource/Delete.php and 2 other locations - About 40 mins to fix
      src/Zendesk/API/Traits/Resource/Find.php on lines 30..39
      src/Zendesk/API/Traits/Resource/Update.php on lines 26..35

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

      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 3 locations. Consider refactoring.
      Open

              try {
                  $route = $this->getRoute($routeKey, ['id' => $id]);
              } catch (RouteException $e) {
                  if (! isset($this->resourceName)) {
                      $this->resourceName = $this->getResourceNameFromClass();
      Severity: Major
      Found in src/Zendesk/API/Traits/Resource/Find.php and 2 other locations - About 40 mins to fix
      src/Zendesk/API/Traits/Resource/Delete.php on lines 31..40
      src/Zendesk/API/Traits/Resource/Update.php on lines 26..35

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

      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 3 locations. Consider refactoring.
      Open

              try {
                  $route = $this->getRoute($routeKey, ['id' => $id]);
              } catch (RouteException $e) {
                  if (! isset($this->resourceName)) {
                      $this->resourceName = $this->getResourceNameFromClass();
      Severity: Major
      Found in src/Zendesk/API/Traits/Resource/Update.php and 2 other locations - About 40 mins to fix
      src/Zendesk/API/Traits/Resource/Delete.php on lines 31..40
      src/Zendesk/API/Traits/Resource/Find.php on lines 30..39

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

      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

      Method setDebug has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              $lastRequestHeaders,
              $lastRequestBody,
              $lastResponseCode,
              $lastResponseHeaders,
              $lastResponseError
      Severity: Minor
      Found in src/Zendesk/API/HttpClient.php - About 35 mins to fix

        Function getRoute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getRoute($name, array $params = [])
            {
                $lastChained = $this->getLatestChainedParameter();
        
                if (empty($lastChained) || $name !== 'findAll') {
        Severity: Minor
        Found in src/Zendesk/API/Resources/Core/OrganizationSubscriptions.php - About 35 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 delete has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function delete($id = null, $routeKey = __FUNCTION__)
            {
                if (empty($id)) {
                    $chainedParameters = $this->getChainedParameters();
                    if (array_key_exists(get_class($this), $chainedParameters)) {
        Severity: Minor
        Found in src/Zendesk/API/Traits/Resource/Delete.php - About 35 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

        Avoid too many return statements within this method.
        Open

                        return "{$chainedResourceName}/{$chainedResourceId}/memberships.json";
        Severity: Major
        Found in src/Zendesk/API/Resources/Core/GroupMemberships.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return [];
          Severity: Major
          Found in src/Zendesk/Console/Matchers/SubResourceMatcher.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return "{$chainedResourceName}/{$chainedResourceId}/group_memberships.json";
            Severity: Major
            Found in src/Zendesk/API/Resources/Core/GroupMemberships.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return "{$chainedResourceName}/{$chainedResourceId}/{$this->resourceName}.json";
              Severity: Major
              Found in src/Zendesk/API/Resources/Core/OrganizationMemberships.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return "{$this->resourceName}.json";
                Severity: Major
                Found in src/Zendesk/API/Resources/Core/OrganizationMemberships.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return "{$this->resourceName}/{$params['id']}.json";
                  Severity: Major
                  Found in src/Zendesk/API/Resources/Core/OrganizationMemberships.php - About 30 mins to fix

                    Function getRoute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function getRoute($name, array $params = [])
                        {
                            $lastChained = $this->getLatestChainedParameter();
                    
                            $chainedResourceNames = array_keys($lastChained);
                    Severity: Minor
                    Found in src/Zendesk/API/Resources/Core/Groups.php - About 25 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