steadlane/silverstripe-cloudflare

View on GitHub
src/Admin/CloudFlareAdmin.php

Summary

Maintainability
A
2 hrs
Test Coverage

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

    public function purge_single()
    {
        if (!Permission::check('CF_PURGE_SINGLE')) {
            Security::permissionFailure();
        }
Severity: Minor
Found in src/Admin/CloudFlareAdmin.php - About 1 hr to fix

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

    public function providePermissions()
    {
        return array(
            "CF_PURGE_ALL" => array(
                'name' => "Cloudflare: Purge All Cache",
Severity: Minor
Found in src/Admin/CloudFlareAdmin.php - About 1 hr to fix

Remove error control operator '@' on line 80.
Open

    public function init()
    {
        parent::init();

        //Requirements::css('cloudflare/css/cloudflare.min.css');
Severity: Minor
Found in src/Admin/CloudFlareAdmin.php by phpmd

ErrorControlOperator

Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

Example

function foo($filePath) {
    $file = @fopen($filPath); // hides exceptions
    $key = @$array[$notExistingKey]; // assigns null to $key
}

Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

Avoid assigning values to variables in if clauses and the like (line '160', column '15').
Open

    public function purge_single()
    {
        if (!Permission::check('CF_PURGE_SINGLE')) {
            Security::permissionFailure();
        }
Severity: Minor
Found in src/Admin/CloudFlareAdmin.php by phpmd

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

Avoid unused local variables such as '$context'.
Open

        foreach ($this->providePermissions() as $permission => $context) {
Severity: Minor
Found in src/Admin/CloudFlareAdmin.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

The method purge_javascript is not named in camelCase.
Open

    public function purge_javascript()
    {
        if (!Permission::check('CF_PURGE_JAVASCRIPT')) {
            Security::permissionFailure();
        }
Severity: Minor
Found in src/Admin/CloudFlareAdmin.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method ZoneID is not named in camelCase.
Open

    public function ZoneID()
    {
        return (CloudFlare::singleton()->fetchZoneID() ?: _t("CloudFlare.UnableToDetect", "UNABLE TO DETECT"));
    }
Severity: Minor
Found in src/Admin/CloudFlareAdmin.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method DestroyCFAlert is not named in camelCase.
Open

    public function DestroyCFAlert()
    {
        $jar = CloudFlare::singleton()->getSessionJar();

        $jar['CFType']    = false;
Severity: Minor
Found in src/Admin/CloudFlareAdmin.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method purge_all is not named in camelCase.
Open

    public function purge_all()
    {
        if (!Permission::check('CF_PURGE_ALL')) {
            Security::permissionFailure();
        }
Severity: Minor
Found in src/Admin/CloudFlareAdmin.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method purge_single is not named in camelCase.
Open

    public function purge_single()
    {
        if (!Permission::check('CF_PURGE_SINGLE')) {
            Security::permissionFailure();
        }
Severity: Minor
Found in src/Admin/CloudFlareAdmin.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method FormSingleUrlForm is not named in camelCase.
Open

    public function FormSingleUrlForm()
    {
        return CloudFlareSingleUrlForm::create($this, 'purge-single');
    }
Severity: Minor
Found in src/Admin/CloudFlareAdmin.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method purge_stylesheets is not named in camelCase.
Open

    public function purge_stylesheets()
    {
        if (!Permission::check('CF_PURGE_STYLESHEETS')) {
            Security::permissionFailure();
        }
Severity: Minor
Found in src/Admin/CloudFlareAdmin.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method purge_images is not named in camelCase.
Open

    public function purge_images()
    {
        if (!Permission::check('CF_PURGE_IMAGES')) {
            Security::permissionFailure();
        }
Severity: Minor
Found in src/Admin/CloudFlareAdmin.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method CFAlert is not named in camelCase.
Open

    public function CFAlert()
    {
        $jar = CloudFlare::singleton()->getSessionJar();

        $array = array(
Severity: Minor
Found in src/Admin/CloudFlareAdmin.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method HasPermission is not named in camelCase.
Open

    public function HasPermission($code)
    {
        return Permission::check($code);
    }
Severity: Minor
Found in src/Admin/CloudFlareAdmin.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method HasAnyAccess is not named in camelCase.
Open

    public function HasAnyAccess()
    {
        foreach ($this->providePermissions() as $permission => $context) {
            if (!Permission::check($permission)) {
                return false;
Severity: Minor
Found in src/Admin/CloudFlareAdmin.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

There are no issues that match your filters.

Category
Status