filestack/filestack-php

View on GitHub

Showing 91 of 92 total issues

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

    protected function sendGetTags($handle, $security)
    {
        $url = sprintf('%s/tags/security=policy:%s,signature:%s/%s',
            $this->getCustomUrl(FilestackConfig::CDN_URL),
            $security->policy,
Severity: Major
Found in filestack/mixins/CommonMixin.php and 1 other location - About 2 hrs to fix
filestack/mixins/CommonMixin.php on lines 244..262

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

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

    protected function sendGetSafeForWork($handle, $security)
    {
        $url = sprintf('%s/sfw/security=policy:%s,signature:%s/%s',
            $this->getCustomUrl(FilestackConfig::CDN_URL),
            $security->policy,
Severity: Major
Found in filestack/mixins/CommonMixin.php and 1 other location - About 2 hrs to fix
filestack/mixins/CommonMixin.php on lines 275..293

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

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

    protected function createParts($api_key, $metadata, $upload_data)
    {
        $parts = [];
        $max_part_size = FilestackConfig::UPLOAD_PART_SIZE;
        $max_chunk_size = FilestackConfig::UPLOAD_CHUNK_SIZE;
Severity: Major
Found in filestack/UploadProcessor.php - About 2 hrs to fix

    Function createParts has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function createParts($api_key, $metadata, $upload_data)
        {
            $parts = [];
            $max_part_size = FilestackConfig::UPLOAD_PART_SIZE;
            $max_chunk_size = FilestackConfig::UPLOAD_CHUNK_SIZE;
    Severity: Minor
    Found in filestack/UploadProcessor.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 processChunks has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function processChunks($part, $chunks)
        {
            $upload_url = $this->getCustomUrl(FilestackConfig::UPLOAD_URL) . '/multipart/upload';
            $max_retries = FilestackConfig::MAX_RETRIES;
    
    
    Severity: Minor
    Found in filestack/UploadProcessor.php - About 1 hr to fix

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

          public function testBlurSuccess()
          {
              $filelink = new Filelink($this->test_file_handle,
                              $this->test_api_key,
                              $this->test_security);
      Severity: Major
      Found in tests/FilestackTransformTest.php and 6 other locations - About 1 hr to fix
      tests/FilestackTransformTest.php on lines 302..321
      tests/FilestackTransformTest.php on lines 617..636
      tests/FilestackTransformTest.php on lines 701..720
      tests/FilestackTransformTest.php on lines 752..771
      tests/FilestackTransformTest.php on lines 881..900
      tests/FilestackTransformTest.php on lines 905..924

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

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

          public function testQualitySuccess()
          {
              $filelink = new Filelink($this->test_file_handle,
                              $this->test_api_key,
                              $this->test_security);
      Severity: Major
      Found in tests/FilestackTransformTest.php and 6 other locations - About 1 hr to fix
      tests/FilestackTransformTest.php on lines 302..321
      tests/FilestackTransformTest.php on lines 326..345
      tests/FilestackTransformTest.php on lines 617..636
      tests/FilestackTransformTest.php on lines 701..720
      tests/FilestackTransformTest.php on lines 881..900
      tests/FilestackTransformTest.php on lines 905..924

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

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

          public function testSepiaSuccess()
          {
              $filelink = new Filelink($this->test_file_handle,
                              $this->test_api_key,
                              $this->test_security);
      Severity: Major
      Found in tests/FilestackTransformTest.php and 6 other locations - About 1 hr to fix
      tests/FilestackTransformTest.php on lines 302..321
      tests/FilestackTransformTest.php on lines 326..345
      tests/FilestackTransformTest.php on lines 617..636
      tests/FilestackTransformTest.php on lines 701..720
      tests/FilestackTransformTest.php on lines 752..771
      tests/FilestackTransformTest.php on lines 905..924

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

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

          public function testSharpenSuccess()
          {
              $filelink = new Filelink($this->test_file_handle,
                              $this->test_api_key,
                              $this->test_security);
      Severity: Major
      Found in tests/FilestackTransformTest.php and 6 other locations - About 1 hr to fix
      tests/FilestackTransformTest.php on lines 302..321
      tests/FilestackTransformTest.php on lines 326..345
      tests/FilestackTransformTest.php on lines 617..636
      tests/FilestackTransformTest.php on lines 701..720
      tests/FilestackTransformTest.php on lines 752..771
      tests/FilestackTransformTest.php on lines 881..900

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

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

          public function testOilPaintSuccess()
          {
              $filelink = new Filelink($this->test_file_handle,
                              $this->test_api_key,
                              $this->test_security);
      Severity: Major
      Found in tests/FilestackTransformTest.php and 6 other locations - About 1 hr to fix
      tests/FilestackTransformTest.php on lines 302..321
      tests/FilestackTransformTest.php on lines 326..345
      tests/FilestackTransformTest.php on lines 701..720
      tests/FilestackTransformTest.php on lines 752..771
      tests/FilestackTransformTest.php on lines 881..900
      tests/FilestackTransformTest.php on lines 905..924

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

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

          public function testBlackwhiteSuccess()
          {
              $filelink = new Filelink($this->test_file_handle,
                              $this->test_api_key,
                              $this->test_security);
      Severity: Major
      Found in tests/FilestackTransformTest.php and 6 other locations - About 1 hr to fix
      tests/FilestackTransformTest.php on lines 326..345
      tests/FilestackTransformTest.php on lines 617..636
      tests/FilestackTransformTest.php on lines 701..720
      tests/FilestackTransformTest.php on lines 752..771
      tests/FilestackTransformTest.php on lines 881..900
      tests/FilestackTransformTest.php on lines 905..924

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

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

          public function testPixelateSuccess()
          {
              $filelink = new Filelink($this->test_file_handle,
                              $this->test_api_key,
                              $this->test_security);
      Severity: Major
      Found in tests/FilestackTransformTest.php and 6 other locations - About 1 hr to fix
      tests/FilestackTransformTest.php on lines 302..321
      tests/FilestackTransformTest.php on lines 326..345
      tests/FilestackTransformTest.php on lines 617..636
      tests/FilestackTransformTest.php on lines 752..771
      tests/FilestackTransformTest.php on lines 881..900
      tests/FilestackTransformTest.php on lines 905..924

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

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

          public function upload($filepath, $options = [])
          {
              if (!file_exists($filepath)) {
                  throw new FilestackException("File not found", 400);
              }
      Severity: Minor
      Found in filestack/FilestackClient.php - About 1 hr to fix

        Method testProcessChunks has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function testProcessChunks()
            {
                $mock_response1 = new MockHttpResponse(408,  '{"error": "timed out"}');
                $mock_response2 = new MockHttpResponse(504,  '{"error": "Gateway timed out"}');
                $mock_response3 = new MockHttpResponse(200,
        Severity: Minor
        Found in tests/UploadProcessorTest.php - About 1 hr to fix

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

              public function testFilelinkSaveException()
              {
                  $mock_response = new MockHttpResponse(400,
                      'Invalid parameters');
          
          
          Severity: Major
          Found in tests/FilelinkTest.php and 1 other location - About 1 hr to fix
          tests/FilelinkTest.php on lines 361..379

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

          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 testFilelinkGetMetadataException()
              {
                  $mock_response = new MockHttpResponse(
                      400,
                      'Bad Request'
          Severity: Major
          Found in tests/FilelinkTest.php and 1 other location - About 1 hr to fix
          tests/FilelinkTest.php on lines 473..491

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

          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 testGetMetadataException()
              {
                  $mock_response = new MockHttpResponse(
                      400,
                      'Bad Request'
          Severity: Major
          Found in tests/FilestackClientTest.php and 1 other location - About 1 hr to fix
          tests/FilestackClientTest.php on lines 117..136

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

          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 testGetContentNotFound()
              {
                  $mock_response = new MockHttpResponse(
                      404,
                      'File not found'
          Severity: Major
          Found in tests/FilestackClientTest.php and 1 other location - About 1 hr to fix
          tests/FilestackClientTest.php on lines 255..275

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

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

              public function testCollageSuccess()
              {
                  $mock_response = new MockHttpResponse(
                      200,
                      '{"url": "http://cdn.filestackcontent.com/somehandle",'.
          Severity: Minor
          Found in tests/FilestackClientTest.php - About 1 hr to fix

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

                public function testFilelinkGetSfwException()
                {
                    $mock_response = new MockHttpResponse(404);
            
                    $stub_http_client = $this->createMock(\GuzzleHttp\Client::class);
            Severity: Major
            Found in tests/FilelinkTest.php and 1 other location - About 1 hr to fix
            tests/FilelinkTest.php on lines 341..356

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

            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

            Severity
            Category
            Status
            Source
            Language