cosmocode/dokuwiki-plugin-issuelinks

View on GitHub
services/GitLab.service.php

Summary

Maintainability
D
2 days
Test Coverage

File GitLab.service.php has 392 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace dokuwiki\plugin\issuelinks\services;

use dokuwiki\Form\Form;
Severity: Minor
Found in services/GitLab.service.php - About 5 hrs to fix

    The class GitLab has an overall complexity of 68 which is very high. The configured complexity threshold is 50.
    Open

    class GitLab extends AbstractService
    {
    
        const SYNTAX = 'gl';
        const DISPLAY_NAME = 'GitLab';
    Severity: Minor
    Found in services/GitLab.service.php by phpmd

    GitLab has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class GitLab extends AbstractService
    {
    
        const SYNTAX = 'gl';
        const DISPLAY_NAME = 'GitLab';
    Severity: Minor
    Found in services/GitLab.service.php - About 3 hrs to fix

      Method retrieveAllIssues has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function retrieveAllIssues($projectKey, &$startat = 0)
          {
              $perPage = 100;
              $page = ceil(($startat + 1) / $perPage);
              $endpoint = '/projects/' . urlencode($projectKey) . "/issues?page=$page&per_page=$perPage";
      Severity: Minor
      Found in services/GitLab.service.php - About 1 hr to fix

        Avoid too many return statements within this method.
        Open

                    return false;
        Severity: Major
        Found in services/GitLab.service.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return true;
          Severity: Major
          Found in services/GitLab.service.php - About 30 mins to fix

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

                protected function getTypeFromLabels(array $labels)
            Severity: Major
            Found in services/GitLab.service.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;
            }
            

            Class "GitLab" has 26 methods, which is greater than 20 authorized. Split it into smaller classes.
            Open

            class GitLab extends AbstractService
            Severity: Major
            Found in services/GitLab.service.php by sonar-php

            A class that grows too much tends to aggregate too many responsibilities and inevitably becomes harder to understand and therefore to maintain. Above a specific threshold, it is strongly advised to refactor the class into smaller ones which focus on well defined topics.

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

                public function isConfigured()
            Severity: Major
            Found in services/GitLab.service.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;
            }
            

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

                protected function isOurIssueHook($hook)
            Severity: Major
            Found in services/GitLab.service.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;
            }
            

            Missing class import via use statement (line '27', column '37').
            Open

                    $this->dokuHTTPClient = new \DokuHTTPClient();
            Severity: Minor
            Found in services/GitLab.service.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\Issue' in method 'retrieveAllIssues'.
            Open

                            $issue = Issue::getInstance('gitlab', $projectKey, $issueData['iid'], false);
            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 using static access to class '\dokuwiki\plugin\issuelinks\classes\Issue' in method 'retrieveAllIssues'.
            Open

                            $issue = Issue::getInstance('gitlab', $projectKey, $mrData['iid'], true);
            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 using static access to class '\dokuwiki\plugin\issuelinks\classes\Issue' in method 'handleWebhook'.
            Open

                    $issue = Issue::getInstance(
                        'gitlab',
                        $data['project']['path_with_namespace'],
                        $data['object_attributes']['iid'],
                        $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 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

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

                    if (!in_array($data['event_type'], $allowedEventTypes)) {
            Severity: Critical
            Found in services/GitLab.service.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.

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

                        $repo->full_name = $project['path_with_namespace'];
            Severity: Critical
            Found in services/GitLab.service.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.

            Define a constant instead of duplicating this literal "gitlab_token" 4 times.
            Open

                    $authToken = $db->getKeyValue('gitlab_token');
            Severity: Critical
            Found in services/GitLab.service.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.

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

                    if (!empty($info['assignee'])) {
            Severity: Critical
            Found in services/GitLab.service.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.

            Rename "$token" which has the same name as the field declared at line 20.
            Open

                    $token = $INPUT->str('gitlab_token');
            Severity: Major
            Found in services/GitLab.service.php by sonar-php

            Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

            Noncompliant Code Example

            class Foo {
              public $myField;
            
              public function doSomething() {
                $myField = 0;
                ...
              }
            }
            

            See

            Define a constant instead of duplicating this literal "project" 4 times.
            Open

                            'project' => $currentProject,
            Severity: Critical
            Found in services/GitLab.service.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.

            Define a constant instead of duplicating this literal "issuelinks_db" 7 times.
            Open

                    $db = plugin_load('helper', 'issuelinks_db');
            Severity: Critical
            Found in services/GitLab.service.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.

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

                    if (!empty($info['milestone'])) {
            Severity: Critical
            Found in services/GitLab.service.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.

            Define a constant instead of duplicating this literal "gitlab" 9 times.
            Open

                const ID = 'gitlab';
            Severity: Critical
            Found in services/GitLab.service.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.

            Define a constant instead of duplicating this literal "/projects/" 4 times.
            Open

                    $endpoint = '/projects/' . $repoUrlEnc . '/' . $notable . '/' . $issue->getKey();
            Severity: Critical
            Found in services/GitLab.service.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.

            Rename "$user" which has the same name as the field declared at line 22.
            Open

                        $user = $this->makeSingleGitLabGetRequest('/user');
            Severity: Major
            Found in services/GitLab.service.php by sonar-php

            Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

            Noncompliant Code Example

            class Foo {
              public $myField;
            
              public function doSomething() {
                $myField = 0;
                ...
              }
            }
            

            See

            Define a constant instead of duplicating this literal "helper" 8 times.
            Open

                    $db = plugin_load('helper', 'issuelinks_db');
            Severity: Critical
            Found in services/GitLab.service.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.

            Define a constant instead of duplicating this literal "gitlab_url" 4 times.
            Open

                    $gitLabUrl = $db->getKeyValue('gitlab_url');
            Severity: Critical
            Found in services/GitLab.service.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.

            Reference to instance property resp_headers from undeclared class \DokuHTTPClient
            Open

                    $headers = $this->dokuHTTPClient->resp_headers;
            Severity: Minor
            Found in services/GitLab.service.php by phan

            Call to undeclared function \plugin_load()
            Open

                    $db = plugin_load('helper', 'issuelinks_db');
            Severity: Critical
            Found in services/GitLab.service.php by phan

            Call to undeclared function \hsc()
            Open

                        $this->configError = 'The GitLab authentication failed with message: ' . hsc($e->getMessage());
            Severity: Critical
            Found in services/GitLab.service.php by phan

            Call to undeclared function \plugin_load()
            Open

                            $db = plugin_load('helper', 'issuelinks_db');
            Severity: Critical
            Found in services/GitLab.service.php by phan

            Call to undeclared function \plugin_load()
            Open

                    $db = plugin_load('helper', 'issuelinks_db');
            Severity: Critical
            Found in services/GitLab.service.php by phan

            Call to undeclared function \plugin_load()
            Open

                        $db = plugin_load('helper', 'issuelinks_db');
            Severity: Critical
            Found in services/GitLab.service.php by phan

            Call to undeclared function \blank()
            Open

                    $valid = !blank($summary);
            Severity: Critical
            Found in services/GitLab.service.php by phan

            Call to undeclared function \dbglog()
            Open

                        dbglog($issueData);
            Severity: Critical
            Found in services/GitLab.service.php by phan

            Call to method __construct from undeclared class \DokuHTTPClient
            Open

                    $this->dokuHTTPClient = new \DokuHTTPClient();
            Severity: Critical
            Found in services/GitLab.service.php by phan

            Parameter $configForm has undeclared type \dokuwiki\Form\Form
            Open

                public function hydrateConfigForm(Form $configForm)
            Severity: Minor
            Found in services/GitLab.service.php by phan

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

                    $configForm->addTextInput('gitlab_url', 'GitLab Url')->val($this->gitlabUrl);
            Severity: Critical
            Found in services/GitLab.service.php by phan

            Reference to instance property status from undeclared class \DokuHTTPClient
            Open

                        $status = $this->dokuHTTPClient->status;
            Severity: Minor
            Found in services/GitLab.service.php by phan

            Call to undeclared function \dbglog()
            Open

                        dbglog($e->getMessage());
            Severity: Critical
            Found in services/GitLab.service.php by phan

            Call to undeclared function \dbglog()
            Open

                        dbglog($mrData);
            Severity: Critical
            Found in services/GitLab.service.php by phan

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

                    $configForm->addHTML($message);
            Severity: Critical
            Found in services/GitLab.service.php by phan

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

                    $configForm->addTextInput('gitlab_token', 'GitLab AccessToken')->useInput(false);
            Severity: Critical
            Found in services/GitLab.service.php by phan

            Call to undeclared function \plugin_load()
            Open

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

            Returning type int but isIssueValid() is declared to return bool
            Open

                    return $valid;
            Severity: Minor
            Found in services/GitLab.service.php by phan

            Call to undeclared function \plugin_load()
            Open

                    $db = plugin_load('helper', 'issuelinks_db');
            Severity: Critical
            Found in services/GitLab.service.php by phan

            Reference to instance property status from undeclared class \DokuHTTPClient
            Open

                        $status = $this->dokuHTTPClient->status;
            Severity: Minor
            Found in services/GitLab.service.php by phan

            Saw an @param annotation for errorsToBeReturned, but it was not found in the param list of function makeGitLabRequest(string $endpoint, array $data, string $method, array $headers = null) : array|int
            Open

                 *                   $errorsToBeReturned or an empty array if the error is not in @param $errorsToBeReturned
            Severity: Info
            Found in services/GitLab.service.php by phan

            Call to undeclared function \plugin_load()
            Open

                        $db = plugin_load('helper', 'issuelinks_db');
            Severity: Critical
            Found in services/GitLab.service.php by phan

            Saw unextractable annotation for comment '* @return'
            Open

                 * @return
            Severity: Info
            Found in services/GitLab.service.php by phan

            Call to undeclared function \dbglog()
            Open

                    dbglog($data, __FILE__ . ': ' . __LINE__);
            Severity: Critical
            Found in services/GitLab.service.php by phan

            Call to undeclared function \blank()
            Open

                    $valid &= !blank($status);
            Severity: Critical
            Found in services/GitLab.service.php by phan

            Call to undeclared function \plugin_load()
            Open

                    $db = plugin_load('helper', 'issuelinks_db');
            Severity: Critical
            Found in services/GitLab.service.php by phan

            Call to undeclared function \dbglog()
            Open

                        dbglog($e->getMessage());
            Severity: Critical
            Found in services/GitLab.service.php by phan

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                public function parseMergeRequestDescription($currentProject, $description)
                {
                    $issues = [];
            
                    $issueOwnRepoPattern = '/(?:\W|^)#([1-9]\d*)\b/';
            Severity: Major
            Found in services/GitLab.service.php and 1 other location - About 4 hrs to fix
            services/GitHub.service.php on lines 487..515

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 171.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                protected function getTypeFromLabels(array $labels)
                {
                    $bugTypeLabels = ['bug'];
                    $improvementTypeLabels = ['enhancement'];
                    $storyTypeLabels = ['feature'];
            Severity: Major
            Found in services/GitLab.service.php and 1 other location - About 1 hr to fix
            services/GitHub.service.php on lines 414..433

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 119.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                protected function estimateTotal($perPage, $default)
                {
                    $headers = $this->dokuHTTPClient->resp_headers;
            
                    if (empty($headers['link'])) {
            Severity: Major
            Found in services/GitLab.service.php and 1 other location - About 1 hr to fix
            services/GitHub.service.php on lines 571..587

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 118.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Avoid excessively long variable names like $improvementTypeLabels. Keep variable name length under 20.
            Open

                    $improvementTypeLabels = ['enhancement'];
            Severity: Minor
            Found in services/GitLab.service.php by phpmd

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

            Avoid excessively long variable names like $projectIssueSeperator. Keep variable name length under 20.
            Open

                    $projectIssueSeperator = '#';
            Severity: Minor
            Found in services/GitLab.service.php by phpmd

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

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

                            $db = plugin_load('helper', 'issuelinks_db');
            Severity: Minor
            Found in services/GitLab.service.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

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

                    $db = plugin_load('helper', 'issuelinks_db');
            Severity: Minor
            Found in services/GitLab.service.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

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

                    $db = plugin_load('helper', 'issuelinks_db');
            Severity: Minor
            Found in services/GitLab.service.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

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

                        $db = plugin_load('helper', 'issuelinks_db');
            Severity: Minor
            Found in services/GitLab.service.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

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

                    $db = plugin_load('helper', 'issuelinks_db');
            Severity: Minor
            Found in services/GitLab.service.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

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

                        $db = plugin_load('helper', 'issuelinks_db');
            Severity: Minor
            Found in services/GitLab.service.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

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

                    $db = plugin_load('helper', 'issuelinks_db');
            Severity: Minor
            Found in services/GitLab.service.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 variable $INPUT is not named in camelCase.
            Open

                public static function isOurWebhook()
                {
                    global $INPUT;
                    if ($INPUT->server->has('HTTP_X_GITLAB_TOKEN')) {
                        return true;
            Severity: Minor
            Found in services/GitLab.service.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 validateWebhook($webhookBody)
                {
                    global $INPUT;
                    $requestToken = $INPUT->server->str('HTTP_X_GITLAB_TOKEN');
            
            
            Severity: Minor
            Found in services/GitLab.service.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 validateWebhook($webhookBody)
                {
                    global $INPUT;
                    $requestToken = $INPUT->server->str('HTTP_X_GITLAB_TOKEN');
            
            
            Severity: Minor
            Found in services/GitLab.service.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 handleAuthorization()
                {
                    global $INPUT;
            
                    $token = $INPUT->str('gitlab_token');
            Severity: Minor
            Found in services/GitLab.service.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 static function isOurWebhook()
                {
                    global $INPUT;
                    if ($INPUT->server->has('HTTP_X_GITLAB_TOKEN')) {
                        return true;
            Severity: Minor
            Found in services/GitLab.service.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 handleAuthorization()
                {
                    global $INPUT;
            
                    $token = $INPUT->str('gitlab_token');
            Severity: Minor
            Found in services/GitLab.service.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 handleAuthorization()
                {
                    global $INPUT;
            
                    $token = $INPUT->str('gitlab_token');
            Severity: Minor
            Found in services/GitLab.service.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