cosmocode/dokuwiki-plugin-issuelinks

View on GitHub
Webhook.php

Summary

Maintainability
A
2 hrs
Test Coverage

Method run has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function run()
    {
        /** @var \helper_plugin_issuelinks_util $util */
        $util = plugin_load('helper', 'issuelinks_util');
        if (!$util) {
Severity: Minor
Found in Webhook.php - About 1 hr to fix

    Function run has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function run()
        {
            /** @var \helper_plugin_issuelinks_util $util */
            $util = plugin_load('helper', 'issuelinks_util');
            if (!$util) {
    Severity: Minor
    Found in Webhook.php - About 55 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Reduce the number of returns of this function 4, down to the maximum allowed 3.
    Open

        public function run()
    Severity: Major
    Found in Webhook.php by sonar-php

    Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

    Noncompliant Code Example

    With the default threshold of 3:

    function myFunction(){ // Noncompliant as there are 4 return statements
      if (condition1) {
        return true;
      } else {
        if (condition2) {
          return false;
        } else {
          return true;
        }
      }
      return false;
    }
    

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

            $serviceProvider = classes\ServiceProvider::getInstance();
    Severity: Minor
    Found in Webhook.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

    Class extends undeclared class \DokuWiki_Plugin
    Open

    class Webhook extends \DokuWiki_Plugin
    Severity: Critical
    Found in Webhook.php by phan

    Call to undeclared function \http_status()
    Open

                http_status(424);
    Severity: Critical
    Found in Webhook.php by phan

    Call to undeclared function \dbglog()
    Open

            dbglog($userAgent);
    Severity: Critical
    Found in Webhook.php by phan

    Call to undeclared function \dbglog()
    Open

            dbglog($INPUT->server);
    Severity: Critical
    Found in Webhook.php by phan

    Call to undeclared function \plugin_load()
    Open

            $util = plugin_load('helper', 'issuelinks_util');
    Severity: Critical
    Found in Webhook.php by phan

    Call to undeclared function \dbglog()
    Open

                dbglog(json_decode($body, true));
    Severity: Critical
    Found in Webhook.php by phan

    Call to undeclared function \dbglog()
    Open

                dbglog('user agent: ' . $userAgent);
    Severity: Critical
    Found in Webhook.php by phan

    Call to undeclared function \dbglog()
    Open

                dbglog('webhook could not be indentified', __FILE__ . ': ' . __LINE__);
    Severity: Critical
    Found in Webhook.php by phan

    The variable $INPUT is not named in camelCase.
    Open

        public function run()
        {
            /** @var \helper_plugin_issuelinks_util $util */
            $util = plugin_load('helper', 'issuelinks_util');
            if (!$util) {
    Severity: Minor
    Found in Webhook.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 $INPUT is not named in camelCase.
    Open

        public function run()
        {
            /** @var \helper_plugin_issuelinks_util $util */
            $util = plugin_load('helper', 'issuelinks_util');
            if (!$util) {
    Severity: Minor
    Found in Webhook.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 $INPUT is not named in camelCase.
    Open

        public function run()
        {
            /** @var \helper_plugin_issuelinks_util $util */
            $util = plugin_load('helper', 'issuelinks_util');
            if (!$util) {
    Severity: Minor
    Found in Webhook.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