Method run
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run()
{
/** @var \helper_plugin_issuelinks_util $util */
$util = plugin_load('helper', 'issuelinks_util');
if (!$util) {
Function run
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function run()
{
/** @var \helper_plugin_issuelinks_util $util */
$util = plugin_load('helper', 'issuelinks_util');
if (!$util) {
- 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
Reduce the number of returns of this function 4, down to the maximum allowed 3. Open
public function run()
- 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; }
Avoid using static access to class 'dokuwiki\plugin\issuelinks\classes\ServiceProvider' in method 'run'. Open
$serviceProvider = classes\ServiceProvider::getInstance();
- 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
Class extends undeclared class \DokuWiki_Plugin
Open
class Webhook extends \DokuWiki_Plugin
- Exclude checks
Call to undeclared function \http_status()
Open
http_status(424);
- Exclude checks
Call to undeclared function \dbglog()
Open
dbglog($userAgent);
- Exclude checks
Call to undeclared function \dbglog()
Open
dbglog($INPUT->server);
- Exclude checks
Call to undeclared function \plugin_load()
Open
$util = plugin_load('helper', 'issuelinks_util');
- Exclude checks
Call to undeclared function \dbglog()
Open
dbglog(json_decode($body, true));
- Exclude checks
Call to undeclared function \dbglog()
Open
dbglog('user agent: ' . $userAgent);
- Exclude checks
Call to undeclared function \dbglog()
Open
dbglog('webhook could not be indentified', __FILE__ . ': ' . __LINE__);
- Exclude checks
The variable $INPUT is not named in camelCase. Open
public function run()
{
/** @var \helper_plugin_issuelinks_util $util */
$util = plugin_load('helper', 'issuelinks_util');
if (!$util) {
- 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 run()
{
/** @var \helper_plugin_issuelinks_util $util */
$util = plugin_load('helper', 'issuelinks_util');
if (!$util) {
- 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 run()
{
/** @var \helper_plugin_issuelinks_util $util */
$util = plugin_load('helper', 'issuelinks_util');
if (!$util) {
- 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();
}
}