zendesk/zendesk_api_client_php

View on GitHub

Showing 41 of 41 total issues

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

    public function getRoute($name, array $params = [])
    {
        $lastChained = $this->getLatestChainedParameter();
        $params = $this->addChainedParametersToParams($params, [
            'category_id' => Categories::class
Severity: Major
Found in src/Zendesk/API/Resources/HelpCenter/Sections.php and 1 other location - About 4 hrs to fix
src/Zendesk/API/Resources/HelpCenter/Articles.php on lines 54..76

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

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

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

    public function getRoute($name, array $params = [])
    {
        $lastChained = $this->getLatestChainedParameter();
        $params = $this->addChainedParametersToParams($params, [
            'section_id' => Sections::class
Severity: Major
Found in src/Zendesk/API/Resources/HelpCenter/Articles.php and 1 other location - About 4 hrs to fix
src/Zendesk/API/Resources/HelpCenter/Sections.php on lines 62..85

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

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 HttpClient.php has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Zendesk\API;

/*
Severity: Minor
Found in src/Zendesk/API/HttpClient.php - About 2 hrs to fix

    Method send has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function send(
            HttpClient $client,
            $endPoint,
            $options = []
        ) {
    Severity: Major
    Found in src/Zendesk/API/Http.php - About 2 hrs to fix

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

          public function getRoute($name, array $params = [])
          {
              $lastChained = $this->getLatestChainedParameter();
      
              $chainedResourceNames = array_keys($lastChained);
      Severity: Major
      Found in src/Zendesk/API/Resources/Core/Organizations.php and 1 other location - About 2 hrs to fix
      src/Zendesk/API/Resources/Core/Groups.php on lines 53..71

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

      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

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

          public function getRoute($name, array $params = [])
          {
              $lastChained = $this->getLatestChainedParameter();
      
              $chainedResourceNames = array_keys($lastChained);
      Severity: Major
      Found in src/Zendesk/API/Resources/Core/Groups.php and 1 other location - About 2 hrs to fix
      src/Zendesk/API/Resources/Core/Organizations.php on lines 75..93

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

      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

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

      <?php
      
      include("../../vendor/autoload.php");
      
      use Zendesk\API\HttpClient as ZendeskAPI;
      Severity: Major
      Found in samples/tickets/getTicketMetrics.php and 1 other location - About 2 hrs to fix
      samples/tickets/getTicketComments.php on lines 1..29

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

      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

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

      <?php
      
      include("../../vendor/autoload.php");
      
      use Zendesk\API\HttpClient as ZendeskAPI;
      Severity: Major
      Found in samples/tickets/getTicketComments.php and 1 other location - About 2 hrs to fix
      samples/tickets/getTicketMetrics.php on lines 1..28

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

      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 getValidSubResources has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function getValidSubResources()
          {
              return [
                  'apps'                      => Apps::class,
                  'activities'                => Activities::class,
      Severity: Minor
      Found in src/Zendesk/API/HttpClient.php - About 1 hr to fix

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

        <?php
        
        include("../../vendor/autoload.php");
        
        use Zendesk\API\HttpClient as ZendeskAPI;
        Severity: Major
        Found in samples/helpcenter/findCategories.php and 1 other location - About 1 hr to fix
        samples/helpcenter/findArticles.php on lines 1..27

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

        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

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

        <?php
        
        include("../../vendor/autoload.php");
        
        use Zendesk\API\HttpClient as ZendeskAPI;
        Severity: Major
        Found in samples/helpcenter/findArticles.php and 1 other location - About 1 hr to fix
        samples/helpcenter/findCategories.php on lines 1..27

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

        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

        Function send has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function send(
                HttpClient $client,
                $endPoint,
                $options = []
            ) {
        Severity: Minor
        Found in src/Zendesk/API/Http.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 upload has 38 lines of code (exceeds 25 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 1 hr to fix

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

              public function makeDefault($params = [])
              {
                  $params = $this->addChainedParametersToParams($params, ['id' => self::class, 'userId' => Users::class]);
          
                  if (! $this->hasKeys($params, ['id', 'userId'])) {
          Severity: Major
          Found in src/Zendesk/API/Resources/Core/OrganizationMemberships.php and 1 other location - About 1 hr to fix
          src/Zendesk/API/Resources/Core/GroupMemberships.php on lines 114..123

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

          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

              public function makeDefault($params = [])
              {
                  $params = $this->addChainedParametersToParams($params, ['id' => self::class, 'userId' => Users::class]);
          
                  if (! $this->hasKeys($params, ['id', 'userId'])) {
          Severity: Major
          Found in src/Zendesk/API/Resources/Core/GroupMemberships.php and 1 other location - About 1 hr to fix
          src/Zendesk/API/Resources/Core/OrganizationMemberships.php on lines 89..98

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

          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

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

              public function getRoute($name, array $params = [])
              {
                  $lastChained = $this->getLatestChainedParameter([self::class]);
          
                  if ((empty($lastChained)) || ! (in_array($name, ['findAll', 'find', 'create', 'delete']))) {
          Severity: Minor
          Found in src/Zendesk/API/Resources/Core/OrganizationMemberships.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 upload has 29 lines of code (exceeds 25 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 1 hr to fix

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

                public function getRoute($name, array $params = [])
                {
                    $lastChained = $this->getLatestChainedParameter([self::class]);
            
                    $chainableRoutes = ['findAll', 'find', 'create', 'delete', 'assignable'];
            Severity: Minor
            Found in src/Zendesk/API/Resources/Core/GroupMemberships.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 getRoute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getRoute($name, array $params = [])
                {
                    $lastChained = $this->getLatestChainedParameter();
                    $params = $this->addChainedParametersToParams($params, [
                        'section_id' => Sections::class
            Severity: Minor
            Found in src/Zendesk/API/Resources/HelpCenter/Articles.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 getRoute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getRoute($name, array $params = [])
                {
                    $lastChained = $this->getLatestChainedParameter();
                    $params = $this->addChainedParametersToParams($params, [
                        'category_id' => Categories::class
            Severity: Minor
            Found in src/Zendesk/API/Resources/HelpCenter/Sections.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

            Severity
            Category
            Status
            Source
            Language