kai-jacobsen/kontentblocks

View on GitHub
core/Fields/Definitions/Plupload.php

Summary

Maintainability
A
2 hrs
Test Coverage

handleUpload accesses the super-global variable $_REQUEST.
Open

    public static function handleUpload()
    {
        header( 'Content-Type: text/html; charset=UTF-8' );

        if (!defined( 'DOING_AJAX' )) {
Severity: Minor
Found in core/Fields/Definitions/Plupload.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

handleUpload accesses the super-global variable $_REQUEST.
Open

    public static function handleUpload()
    {
        header( 'Content-Type: text/html; charset=UTF-8' );

        if (!defined( 'DOING_AJAX' )) {
Severity: Minor
Found in core/Fields/Definitions/Plupload.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

handleUpload accesses the super-global variable $_FILES.
Open

    public static function handleUpload()
    {
        header( 'Content-Type: text/html; charset=UTF-8' );

        if (!defined( 'DOING_AJAX' )) {
Severity: Minor
Found in core/Fields/Definitions/Plupload.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Method handleUpload has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function handleUpload()
    {
        header( 'Content-Type: text/html; charset=UTF-8' );

        if (!defined( 'DOING_AJAX' )) {
Severity: Minor
Found in core/Fields/Definitions/Plupload.php - About 1 hr to fix

    Method enqueueScripts has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function enqueueScripts()
        {
            global $post;
            $post_id = ( !empty( $post->ID ) ) ? $post->ID : null;
    
    Severity: Minor
    Found in core/Fields/Definitions/Plupload.php - About 1 hr to fix

      The method handleUpload uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  return new AjaxErrorResponse(
                      'Attachment not generated due to error', array(
                          'error' => $attachmentId
                      )
      Severity: Minor
      Found in core/Fields/Definitions/Plupload.php by phpmd

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

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

      The variable $file_attr is not named in camelCase.
      Open

          public static function handleUpload()
          {
              header( 'Content-Type: text/html; charset=UTF-8' );
      
              if (!defined( 'DOING_AJAX' )) {
      Severity: Minor
      Found in core/Fields/Definitions/Plupload.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $post_id is not named in camelCase.
      Open

          public static function handleUpload()
          {
              header( 'Content-Type: text/html; charset=UTF-8' );
      
              if (!defined( 'DOING_AJAX' )) {
      Severity: Minor
      Found in core/Fields/Definitions/Plupload.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $post_id is not named in camelCase.
      Open

          public static function enqueueScripts()
          {
              global $post;
              $post_id = ( !empty( $post->ID ) ) ? $post->ID : null;
      
      Severity: Minor
      Found in core/Fields/Definitions/Plupload.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $post_id is not named in camelCase.
      Open

          public static function handleUpload()
          {
              header( 'Content-Type: text/html; charset=UTF-8' );
      
              if (!defined( 'DOING_AJAX' )) {
      Severity: Minor
      Found in core/Fields/Definitions/Plupload.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $file_attr is not named in camelCase.
      Open

          public static function handleUpload()
          {
              header( 'Content-Type: text/html; charset=UTF-8' );
      
              if (!defined( 'DOING_AJAX' )) {
      Severity: Minor
      Found in core/Fields/Definitions/Plupload.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $file_attr is not named in camelCase.
      Open

          public static function handleUpload()
          {
              header( 'Content-Type: text/html; charset=UTF-8' );
      
              if (!defined( 'DOING_AJAX' )) {
      Severity: Minor
      Found in core/Fields/Definitions/Plupload.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $post_id is not named in camelCase.
      Open

          public static function enqueueScripts()
          {
              global $post;
              $post_id = ( !empty( $post->ID ) ) ? $post->ID : null;
      
      Severity: Minor
      Found in core/Fields/Definitions/Plupload.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $file_attr is not named in camelCase.
      Open

          public static function handleUpload()
          {
              header( 'Content-Type: text/html; charset=UTF-8' );
      
              if (!defined( 'DOING_AJAX' )) {
      Severity: Minor
      Found in core/Fields/Definitions/Plupload.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $post_id is not named in camelCase.
      Open

          public static function handleUpload()
          {
              header( 'Content-Type: text/html; charset=UTF-8' );
      
              if (!defined( 'DOING_AJAX' )) {
      Severity: Minor
      Found in core/Fields/Definitions/Plupload.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      There are no issues that match your filters.

      Category
      Status