cosmocode/dokuwiki-plugin-issuelinks

View on GitHub

Showing 899 of 899 total issues

Avoid unused parameters such as '$isMergeRequest'.
Open

    public function getIssueURL($projectId, $issueId, $isMergeRequest)
Severity: Minor
Found in services/Jira.service.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

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

Avoid using static access to class '\dokuwiki\plugin\issuelinks\classes\Issue' in method 'parseIssueSyntax'.
Open

        $issue = Issue::getInstance('gitlab', $projectKey, $issueId, $isMergeRequest);
Severity: Minor
Found in services/GitLab.service.php by phpmd

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 unused local variables such as '$issueId'.
Open

        list($projectKey, $issueId) = explode('-', $data['issue']['key']);
Severity: Minor
Found in services/Jira.service.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

Avoid unused parameters such as '$isMergeRequest'.
Open

    public static function getProjectIssueSeparator($isMergeRequest)
Severity: Minor
Found in services/GitHub.service.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

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

Avoid unused parameters such as '$isMergeRequest'.
Open

    public function getIssueURL($projectId, $issueId, $isMergeRequest)
Severity: Minor
Found in services/GitHub.service.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

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

Avoid using static access to class '\dokuwiki\plugin\issuelinks\classes\Issue' in method 'retrieveAllIssues'.
Open

                $issue = Issue::getInstance(
                    'github',
                    $projectKey,
                    $issueData['number'],
                    !empty($issueData['pull_request'])
Severity: Minor
Found in services/GitHub.service.php by phpmd

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 '\dokuwiki\plugin\issuelinks\classes\Issue' in method 'getMergeRequestsForIssue'.
Open

            $issue = Issue::getInstance(
                $issueData['service'],
                $issueData['project_id'],
                $issueData['issue_id'],
                $issueData['is_mergerequest']
Severity: Minor
Found in helper/data.php by phpmd

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

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

            } else {
                $activeLinks[] = $linkingPage;
            }
Severity: Minor
Found in helper/db.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 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

handleAjax accesses the super-global variable $_SERVER.
Open

    public function handleAjax(Doku_Event $event, $param)
    {
        if ($event->data !== 'plugin_issuelinks') {
            return;
        }
Severity: Minor
Found in action/ajax.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

repoAdminToggle accesses the super-global variable $_SERVER.
Open

    public function repoAdminToggle(Doku_Event $event, $param)
    {
        if ($event->data !== 'issuelinks_repo_admin_toggle') {
            return;
        }
Severity: Minor
Found in action/ajax.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

repoAdminOrg accesses the super-global variable $_SERVER.
Open

    public function repoAdminOrg(Doku_Event $event, $param)
    {
        if ($event->data !== 'issuelinks_repo_admin_getorg') {
            return;
        }
Severity: Minor
Found in action/ajax.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

The method helper_plugin_issuelinks_db::saveEntity() calls the typical debug function print_r() which is mostly only used during development.
Open

            msg(print_r($entity, true), -1);
Severity: Minor
Found in helper/db.php by phpmd

DevelopmentCodeFragment

Since: 2.3.0

Functions like vardump(), printr() etc. are normally only used during development and therefore such calls in production code are a good indicator that they were just forgotten.

Example

class SuspectCode {

    public function doSomething(array $items)
    {
        foreach ($items as $i => $item) {
            // …

            if ('qafoo' == $item) var_dump($i);

            // …
        }
    }
}

Source https://phpmd.org/rules/design.html#developmentcodefragment

The method buildTooltipHTML() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
Open

    public function buildTooltipHTML()
    {
        $html = '<aside class="issueTooltip">';
        $html .= "<h1 class=\"issueTitle\">{$this->getSummary()}</h1>";
        $html .= "<div class='assigneeAvatar waiting'></div>";
Severity: Minor
Found in classes/Issue.php by phpmd

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

Avoid using dokuwiki\plugin\issuelinks\services\count() function in do loops.
Open

        do {
            usleep($waittime);
            try {
                $data = $this->makeGitHubRequest($endpoint, [], 'GET', []);
            } catch (ExternalServerException $e) {
Severity: Minor
Found in services/GitHub.service.php by phpmd

CountInLoopExpression

Since: 2.7.0

Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.

Example

class Foo {

  public function bar()
  {
    $array = array();

    for ($i = 0; count($array); $i++) {
      // ...
    }
  }
}

Source https://phpmd.org/rules/design.html#countinloopexpression

importAllIssues accesses the super-global variable $_SERVER.
Open

    public function importAllIssues($serviceName, $projectKey)
    {
        $lockfileKey = $this->getImportLockID($serviceName, $projectKey);
        if ($this->isImportLocked($lockfileKey)) {
            throw new RuntimeException('Import of Issues is already locked!');
Severity: Minor
Found in helper/data.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

importAllIssues accesses the super-global variable $_SERVER.
Open

    public function importAllIssues($serviceName, $projectKey)
    {
        $lockfileKey = $this->getImportLockID($serviceName, $projectKey);
        if ($this->isImportLocked($lockfileKey)) {
            throw new RuntimeException('Import of Issues is already locked!');
Severity: Minor
Found in helper/data.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

Only one argument is allowed per line in a multi-line function call
Open

                $this->assertArrayHasKey($key, $conf,
Severity: Minor
Found in _test/general.test.php by phpcodesniffer

Only one argument is allowed per line in a multi-line function call
Open

        $this->assertEquals(gettype($conf), gettype($meta),
Severity: Minor
Found in _test/general.test.php by phpcodesniffer
Severity
Category
Status
Source
Language