cosmocode/dokuwiki-plugin-issuelinks

View on GitHub
admin/repoadmin.php

Summary

Maintainability
A
2 hrs
Test Coverage

Method appendServicePage has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function appendServicePage($html, $serviceID)
    {
        $serviceProvider = ServiceProvider::getInstance();
        $services = $serviceProvider->getServices();
        $service = $services[$serviceID]::getInstance();
Severity: Minor
Found in admin/repoadmin.php - About 1 hr to fix

    Function handle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function handle()
        {
            global $INPUT;
    
            $serviceProvider = ServiceProvider::getInstance();
    Severity: Minor
    Found in admin/repoadmin.php - About 25 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

    Missing class import via use statement (line '151', column '25').
    Open

                $form = new \dokuwiki\Form\Form(['data-service' => $serviceID]);
    Severity: Minor
    Found in admin/repoadmin.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

    Missing class import via use statement (line '136', column '31').
    Open

                $configForm = new \dokuwiki\Form\Form();
    Severity: Minor
    Found in admin/repoadmin.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

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

            $serviceProvider = ServiceProvider::getInstance();
    Severity: Minor
    Found in admin/repoadmin.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\ServiceProvider' in method 'appendServicePage'.
    Open

            $serviceProvider = ServiceProvider::getInstance();
    Severity: Minor
    Found in admin/repoadmin.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\ServiceProvider' in method 'appendServiceTab'.
    Open

            $serviceProvider = ServiceProvider::getInstance();
    Severity: Minor
    Found in admin/repoadmin.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 appendServicePage uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                global $INPUT;
                $reconfigureURL = $INPUT->server->str('REQUEST_URI') . '&reconfigureService=' . $serviceID;
                $reconfigureLink = "<a href=\"$reconfigureURL\">{$this->getLang('label: reconfigure service')}</a>";
                $authorizedUserLabel = sprintf($this->getLang('label: authorized with user'), $service->getUserString());
    Severity: Minor
    Found in admin/repoadmin.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

    Define a constant instead of duplicating this literal "authorize" 3 times.
    Open

            if ($INPUT->has('authorize')) {
    Severity: Critical
    Found in admin/repoadmin.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Avoid unused parameters such as '$language'.
    Open

        public function getMenuText($language)
    Severity: Minor
    Found in admin/repoadmin.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

    Call to undeclared method \admin_plugin_issuelinks_repoadmin::getLang
    Open

            return $this->getLang('menu:repo-admin');
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Call to undeclared method \admin_plugin_issuelinks_repoadmin::getLang
    Open

                $reconfigureLink = "<a href=\"$reconfigureURL\">{$this->getLang('label: reconfigure service')}</a>";
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Class extends undeclared class \DokuWiki_Admin_Plugin
    Open

    class admin_plugin_issuelinks_repoadmin extends DokuWiki_Admin_Plugin
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Reference to undeclared constant \dokuwiki\plugin\issuelinks\services\ServiceInterface::DISPLAY_NAME
    Open

            $serviceName = $service::DISPLAY_NAME;
    Severity: Minor
    Found in admin/repoadmin.php by phan

    Call to method __construct from undeclared class \dokuwiki\Form\Form
    Open

                $configForm = new \dokuwiki\Form\Form();
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Possibly zero references to use statement for classlike/namespace ServiceInterface (\dokuwiki\plugin\issuelinks\services\ServiceInterface)
    Open

    use dokuwiki\plugin\issuelinks\services\ServiceInterface;
    Severity: Minor
    Found in admin/repoadmin.php by phan

    Call to method addFieldsetOpen from undeclared class \dokuwiki\Form\Form
    Open

                $form->addFieldsetOpen($this->getLang('legend:user'));
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Call to method addFieldsetClose from undeclared class \dokuwiki\Form\Form
    Open

                $configForm->addFieldsetClose();
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Call to method addFieldsetClose from undeclared class \dokuwiki\Form\Form
    Open

                $form->addFieldsetClose();
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Call to method addHTML from undeclared class \dokuwiki\Form\Form
    Open

                $form->addHTML($authorizedUserLabel . ' ' . $reconfigureLink);
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Call to undeclared method \admin_plugin_issuelinks_repoadmin::getLang
    Open

                $configForm->addButton('', $this->getLang('btn:Submit'))->attr('type', 'submit');
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Call to method addFieldsetOpen from undeclared class \dokuwiki\Form\Form
    Open

                $form->addFieldsetOpen($this->getLang("legend:group $serviceID"));
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Call to undeclared method \admin_plugin_issuelinks_repoadmin::getLang
    Open

                $form->addFieldsetOpen($this->getLang('legend:user'));
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Call to undeclared method \admin_plugin_issuelinks_repoadmin::getLang
    Open

                    $this->getLang("label $serviceID:choose organisation")
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Reference to undeclared constant \dokuwiki\plugin\issuelinks\services\ServiceInterface::DISPLAY_NAME
    Open

            $serviceName = $service::DISPLAY_NAME;
    Severity: Minor
    Found in admin/repoadmin.php by phan

    Call to method addButton from undeclared class \dokuwiki\Form\Form
    Open

                $configForm->addButton('', $this->getLang('btn:Submit'))->attr('type', 'submit');
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Call to method toHTML from undeclared class \dokuwiki\Form\Form
    Open

                $html .= $form->toHTML();
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Call to method addFieldsetOpen from undeclared class \dokuwiki\Form\Form
    Open

                $configForm->addFieldsetOpen();
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Call to undeclared method \admin_plugin_issuelinks_repoadmin::getLang
    Open

                $authorizedUserLabel = sprintf($this->getLang('label: authorized with user'), $service->getUserString());
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Call to method addTagClose from undeclared class \dokuwiki\Form\Form
    Open

                $form->addTagClose('p');
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Call to undeclared method \admin_plugin_issuelinks_repoadmin::getLang
    Open

                $form->addFieldsetOpen($this->getLang("legend:group $serviceID"));
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Call to undeclared method \admin_plugin_issuelinks_repoadmin::getPluginName
    Open

            $plugin = $this->getPluginName();
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Reference to undeclared constant \DOKU_PLUGIN
    Open

            return DOKU_PLUGIN . $plugin . '/images/issue-opened.svg';
    Severity: Minor
    Found in admin/repoadmin.php by phan

    Call to method toHTML from undeclared class \dokuwiki\Form\Form
    Open

                $html .= $configForm->toHTML();
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Call to method addDropdown from undeclared class \dokuwiki\Form\Form
    Open

                $form->addDropdown(
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Call to method addFieldsetClose from undeclared class \dokuwiki\Form\Form
    Open

                $form->addFieldsetClose();
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Call to method addClass from undeclared class \dokuwiki\Form\Form
    Open

                $configForm->addClass('plugin__repoadmin_serviceConfig');
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Call to method __construct from undeclared class \dokuwiki\Form\Form
    Open

                $form = new \dokuwiki\Form\Form(['data-service' => $serviceID]);
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Call to method setHiddenField from undeclared class \dokuwiki\Form\Form
    Open

                $configForm->setHiddenField('authorize', $serviceID);
    Severity: Critical
    Found in admin/repoadmin.php by phan

    Call to method addTagOpen from undeclared class \dokuwiki\Form\Form
    Open

                $form->addTagOpen('p');
    Severity: Critical
    Found in admin/repoadmin.php by phan

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

    class admin_plugin_issuelinks_repoadmin extends DokuWiki_Admin_Plugin
    Severity: Minor
    Found in admin/repoadmin.php by phpcodesniffer

    The class admin_plugin_issuelinks_repoadmin is not named in CamelCase.
    Open

    class admin_plugin_issuelinks_repoadmin extends DokuWiki_Admin_Plugin
    {
    
        private $orgs = [];
        private $configNeeded = [];
    Severity: Minor
    Found in admin/repoadmin.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 "admin_plugin_issuelinks_repoadmin" is not in camel caps format
    Open

    class admin_plugin_issuelinks_repoadmin extends DokuWiki_Admin_Plugin
    Severity: Minor
    Found in admin/repoadmin.php by phpcodesniffer

    The variable $INPUT is not named in camelCase.
    Open

        public function handle()
        {
            global $INPUT;
    
            $serviceProvider = ServiceProvider::getInstance();
    Severity: Minor
    Found in admin/repoadmin.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 handle()
        {
            global $INPUT;
    
            $serviceProvider = ServiceProvider::getInstance();
    Severity: Minor
    Found in admin/repoadmin.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

        protected function appendServicePage($html, $serviceID)
        {
            $serviceProvider = ServiceProvider::getInstance();
            $services = $serviceProvider->getServices();
            $service = $services[$serviceID]::getInstance();
    Severity: Minor
    Found in admin/repoadmin.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 handle()
        {
            global $INPUT;
    
            $serviceProvider = ServiceProvider::getInstance();
    Severity: Minor
    Found in admin/repoadmin.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 handle()
        {
            global $INPUT;
    
            $serviceProvider = ServiceProvider::getInstance();
    Severity: Minor
    Found in admin/repoadmin.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

        protected function appendServicePage($html, $serviceID)
        {
            $serviceProvider = ServiceProvider::getInstance();
            $services = $serviceProvider->getServices();
            $service = $services[$serviceID]::getInstance();
    Severity: Minor
    Found in admin/repoadmin.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