File GitHub.service.php
has 440 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace dokuwiki\plugin\issuelinks\services;
use dokuwiki\Form\Form;
GitHub
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class GitHub extends AbstractService
{
const SYNTAX = 'gh';
The class GitHub has an overall complexity of 76 which is very high. The configured complexity threshold is 50. Open
class GitHub extends AbstractService
{
const SYNTAX = 'gh';
- Exclude checks
Method makeGitHubGETRequest
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function makeGitHubGETRequest($endpoint, $max = null)
{
$results = [];
$waittime = 0;
/** @var \helper_plugin_issuelinks_util $utils */
Function makeGitHubGETRequest
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function makeGitHubGETRequest($endpoint, $max = null)
{
$results = [];
$waittime = 0;
/** @var \helper_plugin_issuelinks_util $utils */
- Read upRead up
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
Method retrieveAllIssues
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function retrieveAllIssues($projectKey, &$startat = 0)
{
$perPage = 30;
$page = ceil(($startat + 1) / $perPage);
// FIXME: implent `since` parameter?
Method getListOfAllReposAndHooks
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getListOfAllReposAndHooks($organisation)
{
$endpoint = "/orgs/$organisation/repos";
try {
$repos = $this->makeGitHubGETRequest($endpoint);
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Function isOurIssueHook
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function isOurIssueHook($hook)
{
if ($hook['config']['url'] !== self::WEBHOOK_URL) {
return false;
}
- Read upRead up
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
Function getListOfAllReposAndHooks
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getListOfAllReposAndHooks($organisation)
{
$endpoint = "/orgs/$organisation/repos";
try {
$repos = $this->makeGitHubGETRequest($endpoint);
- Read upRead up
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
Function retrieveAllIssues
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function retrieveAllIssues($projectKey, &$startat = 0)
{
$perPage = 30;
$page = ceil(($startat + 1) / $perPage);
// FIXME: implent `since` parameter?
- Read upRead up
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
Class "GitHub" has 28 methods, which is greater than 20 authorized. Split it into smaller classes. Open
class GitHub extends AbstractService
- Read upRead up
- Exclude checks
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()
- Read upRead up
- Exclude checks
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 4, down to the maximum allowed 3. Open
protected function getTypeFromLabels(array $labels)
- Read upRead up
- Exclude checks
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)
- Read upRead up
- Exclude checks
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 '31', column '37'). Open
$this->dokuHTTPClient = new \DokuHTTPClient();
- Read upRead up
- Exclude checks
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 'parseIssueSyntax'. Open
$issue = Issue::getInstance('github', $projectKey, $issueId, false);
- Read upRead up
- Exclude checks
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('github', $projectKey, $issueId, true);
- Read upRead up
- Exclude checks
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 'saveIssue'. Open
$issue = Issue::getInstance(
'github',
$data['repository']['full_name'],
$data['issue']['number'],
false,
- Read upRead up
- Exclude checks
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(
'github',
$projectKey,
$issueData['number'],
!empty($issueData['pull_request'])
- Read upRead up
- Exclude checks
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 "merged" 4 times. Open
$issue->setStatus(isset($info['merged']) ? 'merged' : $info['state']);
- Read upRead up
- Exclude checks
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 "events" 3 times. Open
'events' => ['issues', 'issue_comment', 'pull_request'],
- Read upRead up
- Exclude checks
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.
Take the required action to fix the issue indicated by this "FIXME" comment. Open
// fixme: add 'user repos'!
- Read upRead up
- Exclude checks
FIXME
tags are commonly used to mark places where a bug is suspected, but which the developer wants to deal with later.
Sometimes the developer will not have the time or will simply forget to get back to that tag.
This rule is meant to track those tags and to ensure that they do not go unnoticed.
Noncompliant Code Example
function divide($numerator, $denominator) { return $numerator / $denominator; // FIXME denominator value might be 0 }
See
- MITRE, CWE-546 - Suspicious Comment
Define a constant instead of duplicating this literal "assignee" 3 times. Open
if ($info['assignee']) {
- Read upRead up
- Exclude checks
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 "pull_request" 4 times. Open
'events' => ['issues', 'issue_comment', 'pull_request'],
- Read upRead up
- Exclude checks
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 "config" 4 times. Open
"config" => $config,
- Read upRead up
- Exclude checks
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.
Take the required action to fix the issue indicated by this "FIXME" comment. Open
// FIXME: implent `since` parameter?
- Read upRead up
- Exclude checks
FIXME
tags are commonly used to mark places where a bug is suspected, but which the developer wants to deal with later.
Sometimes the developer will not have the time or will simply forget to get back to that tag.
This rule is meant to track those tags and to ensure that they do not go unnoticed.
Noncompliant Code Example
function divide($numerator, $denominator) { return $numerator / $denominator; // FIXME denominator value might be 0 }
See
- MITRE, CWE-546 - Suspicious Comment
Define a constant instead of duplicating this literal "full_name" 3 times. Open
$repo->full_name = $repoData['full_name'];
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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.
Take the required action to fix the issue indicated by this "FIXME" comment. Open
// FIXME: this should be done by JIRA service class
- Read upRead up
- Exclude checks
FIXME
tags are commonly used to mark places where a bug is suspected, but which the developer wants to deal with later.
Sometimes the developer will not have the time or will simply forget to get back to that tag.
This rule is meant to track those tags and to ensure that they do not go unnoticed.
Noncompliant Code Example
function divide($numerator, $denominator) { return $numerator / $denominator; // FIXME denominator value might be 0 }
See
- MITRE, CWE-546 - Suspicious Comment
Rename "$user" which has the same name as the field declared at line 21. Open
$user = $this->makeGitHubGETRequest('/user');
- Read upRead up
- Exclude checks
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
- CERT, DCL51-J. - Do not shadow or obscure identifiers in subscopes
Define a constant instead of duplicating this literal "github" 9 times. Open
const ID = 'github';
- Read upRead up
- Exclude checks
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.
Take the required action to fix the issue indicated by this "FIXME" comment. Open
* // FIXME: set Header application/vnd.github.symmetra-preview+json ?
- Read upRead up
- Exclude checks
FIXME
tags are commonly used to mark places where a bug is suspected, but which the developer wants to deal with later.
Sometimes the developer will not have the time or will simply forget to get back to that tag.
This rule is meant to track those tags and to ensure that they do not go unnoticed.
Noncompliant Code Example
function divide($numerator, $denominator) { return $numerator / $denominator; // FIXME denominator value might be 0 }
See
- MITRE, CWE-546 - Suspicious Comment
Define a constant instead of duplicating this literal "login" 3 times. Open
$issue->setAssignee($info['assignee']['login'], $info['assignee']['avatar_url']);
- Read upRead up
- Exclude checks
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 "helper" 9 times. Open
$db = plugin_load('helper', 'issuelinks_db');
- Read upRead up
- Exclude checks
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.
Remove this commented out code. Open
// $status = $this->connector->getLastStatus();
- Read upRead up
- Exclude checks
Programmers should not comment out code as it bloats programs and reduces readability.
Unused code should be deleted and can be retrieved from source control history if required.
See
- MISRA C:2004, 2.4 - Sections of code should not be "commented out".
- MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
- MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
- MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"
Define a constant instead of duplicating this literal "github_token" 3 times. Open
$authToken = $db->getKeyValue('github_token');
- Read upRead up
- Exclude checks
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 "$scopes" which has the same name as the field declared at line 27. Open
$scopes = implode(', ', $this->scopes);
- Read upRead up
- Exclude checks
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
- CERT, DCL51-J. - Do not shadow or obscure identifiers in subscopes
Avoid unused parameters such as '$isMergeRequest'. Open
public static function getProjectIssueSeparator($isMergeRequest)
- Read upRead up
- Exclude checks
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)
- Read upRead up
- Exclude checks
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 dokuwiki\plugin\issuelinks\services\count() function in do loops. Open
do {
usleep($waittime);
try {
$data = $this->makeGitHubRequest($endpoint, [], 'GET', []);
} catch (ExternalServerException $e) {
- Read upRead up
- Exclude checks
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
Property \dokuwiki\plugin\issuelinks\services\GitHub->dokuHTTPClient
has undeclared type \DokuHTTPClient
Open
protected $dokuHTTPClient;
- Exclude checks
Call to method __construct
from undeclared class \DokuHTTPClient
Open
$this->dokuHTTPClient = new \DokuHTTPClient();
- Exclude checks
Call to undeclared function \hsc()
Open
$this->configError = 'The GitHub authentication failed with message: ' . hsc($e->getMessage());
- Exclude checks
Call to undeclared function \dbglog()
Open
dbglog('Error repeats. Aborting Requests.', -1);
- Exclude checks
Reference to instance property resp_headers
from undeclared class \DokuHTTPClient
Open
$links = $utils->parseHTTPLinkHeaders($this->dokuHTTPClient->resp_headers['link']);
- Exclude checks
Reference to instance property resp_headers
from undeclared class \DokuHTTPClient
Open
$headers = $this->dokuHTTPClient->resp_headers;
- Exclude checks
Call to method addTextInput
from undeclared class \dokuwiki\Form\Form
Open
$configForm->addTextInput('githubToken', 'GitHub AccessToken')->useInput(false);
- Exclude checks
Call to undeclared function \blank()
Open
$valid = !blank($summary);
- Exclude checks
Call to method addHTML
from undeclared class \dokuwiki\Form\Form
Open
$configForm->addHTML($message);
- Exclude checks
Call to undeclared function \blank()
Open
$valid &= !blank($status);
- Exclude checks
Invalid offset "login"
of array type array{}
Open
return $this->user['login'];
- Exclude checks
Saw unextractable annotation for comment '* @return'
Open
* @return
- Exclude checks
Call to undeclared function \plugin_load()
Open
$db = plugin_load('helper', 'issuelinks_db');
- Exclude checks
Reference to instance property resp_headers
from undeclared class \DokuHTTPClient
Open
$headers = $this->dokuHTTPClient->resp_headers;
- Exclude checks
Call to undeclared function \dformat()
Open
dformat($this->dokuHTTPClient->resp_headers['x-ratelimit-reset'])
- Exclude checks
Call to undeclared function \msg()
Open
msg(hsc($e->getMessage()), -1);
- Exclude checks
Call to undeclared function \msg()
Open
msg('Error repeats. Aborting Requests.', -1);
- Exclude checks
Call to undeclared function \plugin_load()
Open
$util = plugin_load('helper', 'issuelinks_util');
- Exclude checks
Call to undeclared function \plugin_load()
Open
$db = plugin_load('helper', 'issuelinks_db');
- Exclude checks
Reference to instance property resp_headers
from undeclared class \DokuHTTPClient
Open
if ($this->dokuHTTPClient->resp_headers['x-ratelimit-remaining'] < 500) {
- Exclude checks
Reference to instance property resp_headers
from undeclared class \DokuHTTPClient
Open
dformat($this->dokuHTTPClient->resp_headers['x-ratelimit-reset'])
- Exclude checks
Reference to instance property status
from undeclared class \DokuHTTPClient
Open
$status = $this->dokuHTTPClient->status;
- Exclude checks
Call to undeclared function \msg()
Open
msg("Server Error occured. Waiting $waittime ms between requests and repeating request.", -1);
- Exclude checks
Reference to instance property status
from undeclared class \DokuHTTPClient
Open
$status = $this->dokuHTTPClient->status;
- Exclude checks
Call to undeclared function \plugin_load()
Open
$db = plugin_load('helper', 'issuelinks_db');
- Exclude checks
Call to undeclared function \hsc()
Open
msg(hsc($e->getMessage()), -1);
- Exclude checks
Returning type int
but isIssueValid()
is declared to return bool
Open
return $valid;
- Exclude checks
Call to undeclared function \msg()
Open
msg(sprintf(
- Exclude checks
Parameter $configForm
has undeclared type \dokuwiki\Form\Form
Open
public function hydrateConfigForm(Form $configForm)
- Exclude checks
Call to undeclared function \plugin_load()
Open
$db = plugin_load('helper', 'issuelinks_db');
- Exclude checks
Call to undeclared function \plugin_load()
Open
$utils = plugin_load('helper', 'issuelinks_util');
- Exclude checks
Call to undeclared function \dbglog()
Open
dbglog("Server Error occured. Waiting $waittime ms between requests and repeating request.", -1);
- Exclude checks
Call to undeclared function \plugin_load()
Open
$db = plugin_load('helper', 'issuelinks_db');
- Exclude checks
Reference to instance property resp_headers
from undeclared class \DokuHTTPClient
Open
if (empty($this->dokuHTTPClient->resp_headers['link'])) {
- Exclude checks
Call to undeclared function \plugin_load()
Open
$db = plugin_load('helper', 'issuelinks_db');
- Exclude checks
Call to undeclared function \blank()
Open
$valid &= !blank($type);
- Exclude checks
Call to undeclared function \plugin_load()
Open
$db = plugin_load('helper', 'issuelinks_db');
- Exclude checks
Call to undeclared function \msg()
Open
msg($e->getMessage() . ' ' . $e->getCode(), -1);
- Exclude checks
Similar blocks of code found in 2 locations. Consider refactoring. Open
protected function parseMergeRequestDescription($currentProject, $description)
{
$issues = [];
$issueOwnRepoPattern = '/(?:\W|^)#([1-9]\d*)\b/';
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
protected function getTypeFromLabels(array $labels)
{
$bugTypeLabels = ['bug'];
$improvementTypeLabels = ['enhancement'];
$storyTypeLabels = ['feature'];
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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'])) {
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
public static function isIssueValid(Issue $issue)
{
$summary = $issue->getSummary();
$valid = !blank($summary);
$status = $issue->getStatus();
- Read upRead up
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 92.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Avoid excessively long variable names like $improvementTypeLabels. Keep variable name length under 20. Open
$improvementTypeLabels = ['enhancement'];
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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 $id. Configured minimum length is 3. Open
$id = $data['id'];
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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 $repo_id is not named in camelCase. Open
protected function isSignatureValid($body, $repo_id)
{
global $INPUT;
if (!$INPUT->server->has('HTTP_X_HUB_SIGNATURE')) {
return false;
- Read upRead up
- Exclude checks
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
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = plugin_load('helper', 'issuelinks_db');
- Read upRead up
- Exclude checks
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 function handleAuthorization()
{
global $INPUT;
$token = $INPUT->str('githubToken');
- Read upRead up
- Exclude checks
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;
$userAgent = $INPUT->server->str('HTTP_USER_AGENT');
return strpos($userAgent, self::WEBHOOK_UA) === 0;
- Read upRead up
- Exclude checks
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 $missing_scopes is not named in camelCase. Open
public function isConfigured()
{
/** @var \helper_plugin_issuelinks_db $db */
$db = plugin_load('helper', 'issuelinks_db');
$authToken = $db->getKeyValue('github_token');
- Read upRead up
- Exclude checks
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;
$userAgent = $INPUT->server->str('HTTP_USER_AGENT');
return strpos($userAgent, self::WEBHOOK_UA) === 0;
- Read upRead up
- Exclude checks
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 $missing_scopes is not named in camelCase. Open
public function isConfigured()
{
/** @var \helper_plugin_issuelinks_db $db */
$db = plugin_load('helper', 'issuelinks_db');
$authToken = $db->getKeyValue('github_token');
- Read upRead up
- Exclude checks
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 $signature_github is not named in camelCase. Open
protected function isSignatureValid($body, $repo_id)
{
global $INPUT;
if (!$INPUT->server->has('HTTP_X_HUB_SIGNATURE')) {
return false;
- Read upRead up
- Exclude checks
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 $signature_local is not named in camelCase. Open
protected function isSignatureValid($body, $repo_id)
{
global $INPUT;
if (!$INPUT->server->has('HTTP_X_HUB_SIGNATURE')) {
return false;
- Read upRead up
- Exclude checks
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 handleWebhook($webhookBody)
{
global $INPUT;
$data = json_decode($webhookBody, true);
$event = $INPUT->server->str('HTTP_X_GITHUB_EVENT');
- Read upRead up
- Exclude checks
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('githubToken');
- Read upRead up
- Exclude checks
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 isSignatureValid($body, $repo_id)
{
global $INPUT;
if (!$INPUT->server->has('HTTP_X_HUB_SIGNATURE')) {
return false;
- Read upRead up
- Exclude checks
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 $signature_github is not named in camelCase. Open
protected function isSignatureValid($body, $repo_id)
{
global $INPUT;
if (!$INPUT->server->has('HTTP_X_HUB_SIGNATURE')) {
return false;
- Read upRead up
- Exclude checks
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 isSignatureValid($body, $repo_id)
{
global $INPUT;
if (!$INPUT->server->has('HTTP_X_HUB_SIGNATURE')) {
return false;
- Read upRead up
- Exclude checks
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 $missing_scopes is not named in camelCase. Open
public function isConfigured()
{
/** @var \helper_plugin_issuelinks_db $db */
$db = plugin_load('helper', 'issuelinks_db');
$authToken = $db->getKeyValue('github_token');
- Read upRead up
- Exclude checks
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 $repo_id is not named in camelCase. Open
protected function isSignatureValid($body, $repo_id)
{
global $INPUT;
if (!$INPUT->server->has('HTTP_X_HUB_SIGNATURE')) {
return false;
- Read upRead up
- Exclude checks
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 $signature_local is not named in camelCase. Open
protected function isSignatureValid($body, $repo_id)
{
global $INPUT;
if (!$INPUT->server->has('HTTP_X_HUB_SIGNATURE')) {
return false;
- Read upRead up
- Exclude checks
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 isSignatureValid($body, $repo_id)
{
global $INPUT;
if (!$INPUT->server->has('HTTP_X_HUB_SIGNATURE')) {
return false;
- Read upRead up
- Exclude checks
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 handleWebhook($webhookBody)
{
global $INPUT;
$data = json_decode($webhookBody, true);
$event = $INPUT->server->str('HTTP_X_GITHUB_EVENT');
- Read upRead up
- Exclude checks
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();
}
}