YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/Mail/actions/DownloadAttachment.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Avoid using static access to class '\App\Fields\File' in method 'process'.
Open

            header('content-disposition: attachment; filename="' . \App\Fields\File::sanitizeUploadFileName($fileInfo['name']) . '"');

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class 'Settings_Mail_Module_Model' in method 'process'.
Open

        $fileInfo = Settings_Mail_Module_Model::getAttachmentInfo($id, $selectedFile);

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

When fetching an array index from a value of type string, found an array index of type 'name', but expected the index to be of type int
Open

            header('content-disposition: attachment; filename="' . \App\Fields\File::sanitizeUploadFileName($fileInfo['name']) . '"');

When fetching an array index from a value of type string, found an array index of type 'path', but expected the index to be of type int
Open

            readfile($fileInfo['path']);

When fetching an array index from a value of type string, found an array index of type 'path', but expected the index to be of type int
Open

            header('content-length: ' . filesize($fileInfo['path']));

When fetching an array index from a value of type string, found an array index of type 'path', but expected the index to be of type int
Open

        if ($fileInfo['path'] ?? null && file_exists($fileInfo['path'])) {

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class Settings_Mail_DownloadAttachment_Action extends Vtiger_Mass_Action

Avoid variables with short names like $id. Configured minimum length is 3.
Open

        $id = $request->getInteger('record');

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

The class Settings_Mail_DownloadAttachment_Action is not named in CamelCase.
Open

class Settings_Mail_DownloadAttachment_Action extends Vtiger_Mass_Action
{
    use \App\Controller\Traits\SettingsPermission;

    /**

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param \App\Request $request

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

        $selectedFile = $request->getInteger('selectedFile');

Spaces must be used to indent lines; tabs are not allowed
Open

            header('content-disposition: attachment; filename="' . \App\Fields\File::sanitizeUploadFileName($fileInfo['name']) . '"');

Spaces must be used to indent lines; tabs are not allowed
Open

        $fileInfo = Settings_Mail_Module_Model::getAttachmentInfo($id, $selectedFile);

Spaces must be used to indent lines; tabs are not allowed
Open

            header('content-type: application/octet-stream');

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

            header('expires: 0');

Spaces must be used to indent lines; tabs are not allowed
Open

            header('pragma: public');

Spaces must be used to indent lines; tabs are not allowed
Open

            readfile($fileInfo['path']);

Line exceeds 120 characters; contains 134 characters
Open

            header('content-disposition: attachment; filename="' . \App\Fields\File::sanitizeUploadFileName($fileInfo['name']) . '"');

Spaces must be used to indent lines; tabs are not allowed
Open

    use \App\Controller\Traits\SettingsPermission;

Spaces must be used to indent lines; tabs are not allowed
Open

        $id = $request->getInteger('record');

Spaces must be used to indent lines; tabs are not allowed
Open

     * Process.

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

    public function process(App\Request $request)

Spaces must be used to indent lines; tabs are not allowed
Open

            header('content-length: ' . filesize($fileInfo['path']));

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($fileInfo['path'] ?? null && file_exists($fileInfo['path'])) {

Spaces must be used to indent lines; tabs are not allowed
Open

            header('content-description: File Transfer');

Spaces must be used to indent lines; tabs are not allowed
Open

            header('cache-control: must-revalidate');

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Class name "Settings_Mail_DownloadAttachment_Action" is not in camel caps format
Open

class Settings_Mail_DownloadAttachment_Action extends Vtiger_Mass_Action

There are no issues that match your filters.

Category
Status