cosmocode/dokuwiki-plugin-issuelinks

View on GitHub
helper/util.php

Summary

Maintainability
A
0 mins
Test Coverage

Missing class import via use statement (line '51', column '30').
Open

            $changelog = new PageChangelog($page_id);
Severity: Minor
Found in helper/util.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

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

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

        } else {
            $changelog = new PageChangelog($page_id);
            $previousRevision = $changelog->getRelativeRevision($revision, -1);
            $url = wl(
                $page_id,
Severity: Minor
Found in helper/util.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 method sendResponse uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            http_status($code);
        }
Severity: Minor
Found in helper/util.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

Class extends undeclared class \DokuWiki_Plugin
Open

class helper_plugin_issuelinks_util extends DokuWiki_Plugin
Severity: Critical
Found in helper/util.php by phan

Call to method __construct from undeclared class \PageChangelog
Open

            $changelog = new PageChangelog($page_id);
Severity: Critical
Found in helper/util.php by phan

Call to undeclared function \msg()
Open

            msg('<pre>' . hsc($e->getTraceAsString()) . '</pre>', -1);
Severity: Critical
Found in helper/util.php by phan

Call to undeclared function \http_status()
Open

            http_status(200);
Severity: Critical
Found in helper/util.php by phan

Call to undeclared function \msg()
Open

        msg(hsc($e->getMessage()), -1, $e->getLine(), $e->getFile());
Severity: Critical
Found in helper/util.php by phan

Call to undeclared function \wl() (Did you mean \dl())
Open

            $url = wl(
Severity: Critical
Found in helper/util.php by phan

Call to undeclared function \wikiFN()
Open

            $currentRevision = filemtime(wikiFN($page_id));
Severity: Critical
Found in helper/util.php by phan

Call to undeclared function \wl() (Did you mean \dl())
Open

            $url = wl(
Severity: Critical
Found in helper/util.php by phan

Call to undeclared function \hsc()
Open

        msg(hsc($e->getMessage()), -1, $e->getLine(), $e->getFile());
Severity: Critical
Found in helper/util.php by phan

Call to undeclared function \hsc()
Open

            msg('<pre>' . hsc($e->getTraceAsString()) . '</pre>', -1);
Severity: Critical
Found in helper/util.php by phan

Call to undeclared function \http_status()
Open

            http_status($code);
Severity: Critical
Found in helper/util.php by phan

Call to method getRelativeRevision from undeclared class \PageChangelog
Open

            $previousRevision = $changelog->getRelativeRevision($revision, -1);
Severity: Critical
Found in helper/util.php by phan

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

class helper_plugin_issuelinks_util extends DokuWiki_Plugin
Severity: Minor
Found in helper/util.php by phpcodesniffer

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

    public function reportException(Exception $e)
Severity: Minor
Found in helper/util.php by phpmd

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 parameter $page_id is not named in camelCase.
Open

    public function getDiffUrl($page_id, $revision = 0)
    {
        if (empty($revision)) {
            $currentRevision = filemtime(wikiFN($page_id));
            $url = wl(
Severity: Minor
Found in helper/util.php by phpmd

CamelCaseParameterName

Since: 0.2

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

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

The class helper_plugin_issuelinks_util is not named in CamelCase.
Open

class helper_plugin_issuelinks_util extends DokuWiki_Plugin
{

    /**
     * Parse the link header received by DokuHTTPClient
Severity: Minor
Found in helper/util.php by phpmd

CamelCaseClassName

Since: 0.2

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

Example

class class_name {
}

Source

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

class helper_plugin_issuelinks_util extends DokuWiki_Plugin
Severity: Minor
Found in helper/util.php by phpcodesniffer

The variable $page_id is not named in camelCase.
Open

    public function getDiffUrl($page_id, $revision = 0)
    {
        if (empty($revision)) {
            $currentRevision = filemtime(wikiFN($page_id));
            $url = wl(
Severity: Minor
Found in helper/util.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 $page_id is not named in camelCase.
Open

    public function getDiffUrl($page_id, $revision = 0)
    {
        if (empty($revision)) {
            $currentRevision = filemtime(wikiFN($page_id));
            $url = wl(
Severity: Minor
Found in helper/util.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 $page_id is not named in camelCase.
Open

    public function getDiffUrl($page_id, $revision = 0)
    {
        if (empty($revision)) {
            $currentRevision = filemtime(wikiFN($page_id));
            $url = wl(
Severity: Minor
Found in helper/util.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 $page_id is not named in camelCase.
Open

    public function getDiffUrl($page_id, $revision = 0)
    {
        if (empty($revision)) {
            $currentRevision = filemtime(wikiFN($page_id));
            $url = wl(
Severity: Minor
Found in helper/util.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 $MSG is not named in camelCase.
Open

    public function sendResponse($code, $msg)
    {
        header('Content-Type: application/json');
        if ((int)$code === 204) {
            http_status(200);
Severity: Minor
Found in helper/util.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 $MSG is not named in camelCase.
Open

    public function sendResponse($code, $msg)
    {
        header('Content-Type: application/json');
        if ((int)$code === 204) {
            http_status(200);
Severity: Minor
Found in helper/util.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