filestack/filestack-php

View on GitHub

Showing 91 of 92 total issues

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

    public function testGetTagsException()
    {
        $mock_response = new MockHttpResponse(404);

        $stub_http_client = $this->createMock(\GuzzleHttp\Client::class);
Severity: Major
Found in tests/FilestackClientTest.php and 1 other location - About 1 hr to fix
tests/FilestackClientTest.php on lines 187..204

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

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

    public function testGetSfwException()
    {
        $mock_response = new MockHttpResponse(404);

        $stub_http_client = $this->createMock(\GuzzleHttp\Client::class);
Severity: Major
Found in tests/FilestackClientTest.php and 1 other location - About 1 hr to fix
tests/FilestackClientTest.php on lines 233..250

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

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

    public function testFilelinkGetTagsException()
    {
        $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 300..315

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

Method testUploadIntelligentSuccess has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testUploadIntelligentSuccess()
    {
        $mock_response_202 = new MockHttpResponse(202,  '{accepted: true}');
        $mock_response = new MockHttpResponse(200,
            json_encode([
Severity: Minor
Found in tests/FilestackClientTest.php - About 1 hr to fix

    Avoid using undefined variables such as '$data' which will lead to PHP notices.
    Open

            $response = $this->sendRequest('POST', $url, $data);
    Severity: Minor
    Found in filestack/mixins/CommonMixin.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$data' which will lead to PHP notices.
    Open

                $data['form_params'] = ['url' => $resource];
    Severity: Minor
    Found in filestack/mixins/CommonMixin.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$data' which will lead to PHP notices.
    Open

                $data['body'] = fopen($resource, 'r');
    Severity: Minor
    Found in filestack/mixins/CommonMixin.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Method processParts has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function processParts($parts)
        {
            $num_parts = count($parts);
            $parts_etags = [];
            $parts_completed = 0;
    Severity: Minor
    Found in filestack/UploadProcessor.php - About 1 hr to fix

      Method testconvertVideoSuccess has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function testconvertVideoSuccess()
          {
              $mock_response = new MockHttpResponse(
                  200,
                  '{"uuid" : "some_uuid", "conversion_url": "http://someurl.com/handle"}'
      Severity: Minor
      Found in tests/FilestackClientTest.php - About 1 hr to fix

        Method testCollageSuccess has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function testCollageSuccess()
            {
                $filelink = new Filelink($this->test_file_handle,
                                $this->test_api_key,
                                $this->test_security);
        Severity: Minor
        Found in tests/FilestackTransformTest.php - About 1 hr to fix

          Method testUploadSuccessWithOptions has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function testUploadSuccessWithOptions()
              {
                  $test_headers = ['ETag' =>['some-etag']];
                  $mock_response = new MockHttpResponse(200,
                      json_encode([
          Severity: Minor
          Found in tests/FilestackClientTest.php - About 1 hr to fix

            Method testCreatePartsIntelligentSuccess has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function testCreatePartsIntelligentSuccess()
                {
                    $mock_response = new MockHttpResponse(200,
                        json_encode([
                            'filename'  => 'somefilename.jpg',
            Severity: Minor
            Found in tests/UploadProcessorTest.php - About 1 hr to fix

              Method testProcessPartsIntelligentSuccess has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function testProcessPartsIntelligentSuccess()
                  {
                      $test_headers = ['ETag' =>['some-etag']];
                      $mock_response = new MockHttpResponse(200,
                          json_encode([
              Severity: Minor
              Found in tests/UploadProcessorTest.php - About 1 hr to fix

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

                    public function testProcessPartsSuccess()
                    {
                        $test_headers = ['ETag' =>['some-etag']];
                        $mock_response = new MockHttpResponse(200,
                            json_encode([
                Severity: Minor
                Found in tests/UploadProcessorTest.php - About 1 hr to fix

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

                      public function testCommitPartException()
                      {
                          $this->expectException(FilestackException::class);
                          $this->expectExceptionCode(400);
                  
                  
                  Severity: Minor
                  Found in tests/UploadProcessorTest.php - About 1 hr to fix

                    Method registerComplete has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function registerComplete($api_key, $parts_etags, $upload_data,
                                                              $metadata)
                        {
                            $data = [];
                            $this->appendData($data, 'apikey',          $api_key);
                    Severity: Minor
                    Found in filestack/UploadProcessor.php - About 1 hr to fix

                      Method collage has 8 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          public function collage($sources, $width, $height, $store_options = [],
                              $color = 'white', $fit = 'auto', $margin = 10, $auto_rotate = false)
                      Severity: Major
                      Found in filestack/FilestackClient.php - About 1 hr to fix

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

                            public function testGetSfwSuccess()
                            {
                                $mock_response = new MockHttpResponse(
                                    200,
                                    '{"sfw": true}'
                        Severity: Minor
                        Found in tests/FilestackClientTest.php and 1 other location - About 1 hr to fix
                        tests/FilestackClientTest.php on lines 209..228

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

                        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 testFilelinkGetTagsSuccess()
                            {
                                $mock_response = new MockHttpResponse(
                                    200,
                                    '{"tags": "some-tags"}'
                        Severity: Minor
                        Found in tests/FilelinkTest.php and 1 other location - About 1 hr to fix
                        tests/FilelinkTest.php on lines 279..295

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

                        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 testFilelinkGetSfwSuccess()
                            {
                                $mock_response = new MockHttpResponse(
                                    200,
                                    '{"sfw": true}'
                        Severity: Minor
                        Found in tests/FilelinkTest.php and 1 other location - About 1 hr to fix
                        tests/FilelinkTest.php on lines 320..336

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

                        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