Missing class import via use statement (line '51', column '30'). Open
$changelog = new PageChangelog($page_id);
- 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
The method getDiffUrl uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$changelog = new PageChangelog($page_id);
$previousRevision = $changelog->getRelativeRevision($revision, -1);
$url = wl(
$page_id,
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method sendResponse uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
http_status($code);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Call to undeclared function \hsc()
Open
msg(hsc($e->getMessage()), -1, $e->getLine(), $e->getFile());
- Exclude checks
Call to undeclared function \wl()
(Did you mean \dl()) Open
$url = wl(
- Exclude checks
Call to undeclared function \hsc()
Open
msg('<pre>' . hsc($e->getTraceAsString()) . '</pre>', -1);
- Exclude checks
Call to undeclared function \http_status()
Open
http_status($code);
- Exclude checks
Call to undeclared function \http_status()
Open
http_status(200);
- Exclude checks
Call to undeclared function \msg()
Open
msg(hsc($e->getMessage()), -1, $e->getLine(), $e->getFile());
- Exclude checks
Call to undeclared function \wl()
(Did you mean \dl()) Open
$url = wl(
- Exclude checks
Call to method __construct
from undeclared class \PageChangelog
Open
$changelog = new PageChangelog($page_id);
- Exclude checks
Call to undeclared function \wikiFN()
Open
$currentRevision = filemtime(wikiFN($page_id));
- Exclude checks
Call to method getRelativeRevision
from undeclared class \PageChangelog
Open
$previousRevision = $changelog->getRelativeRevision($revision, -1);
- Exclude checks
Class extends undeclared class \DokuWiki_Plugin
Open
class helper_plugin_issuelinks_util extends DokuWiki_Plugin
- Exclude checks
Call to undeclared function \msg()
Open
msg('<pre>' . hsc($e->getTraceAsString()) . '</pre>', -1);
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class helper_plugin_issuelinks_util extends DokuWiki_Plugin
- Exclude checks
Avoid variables with short names like $e. Configured minimum length is 3. Open
public function reportException(Exception $e)
- 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 class helper_plugin_issuelinks_util is not named in CamelCase. Open
class helper_plugin_issuelinks_util extends DokuWiki_Plugin
{
/**
* Parse the link header received by DokuHTTPClient
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
The parameter $page_id is not named in camelCase. Open
public function getDiffUrl($page_id, $revision = 0)
{
if (empty($revision)) {
$currentRevision = filemtime(wikiFN($page_id));
$url = wl(
- 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
Class name "helper_plugin_issuelinks_util" is not in camel caps format Open
class helper_plugin_issuelinks_util extends DokuWiki_Plugin
- Exclude checks
The variable $page_id is not named in camelCase. Open
public function getDiffUrl($page_id, $revision = 0)
{
if (empty($revision)) {
$currentRevision = filemtime(wikiFN($page_id));
$url = wl(
- 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 $page_id is not named in camelCase. Open
public function getDiffUrl($page_id, $revision = 0)
{
if (empty($revision)) {
$currentRevision = filemtime(wikiFN($page_id));
$url = wl(
- 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 $MSG is not named in camelCase. Open
public function sendResponse($code, $msg)
{
header('Content-Type: application/json');
if ((int)$code === 204) {
http_status(200);
- 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 $page_id is not named in camelCase. Open
public function getDiffUrl($page_id, $revision = 0)
{
if (empty($revision)) {
$currentRevision = filemtime(wikiFN($page_id));
$url = wl(
- 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 $page_id is not named in camelCase. Open
public function getDiffUrl($page_id, $revision = 0)
{
if (empty($revision)) {
$currentRevision = filemtime(wikiFN($page_id));
$url = wl(
- 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 $MSG is not named in camelCase. Open
public function sendResponse($code, $msg)
{
header('Content-Type: application/json');
if ((int)$code === 204) {
http_status(200);
- 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();
}
}