The method _retrieveCurrentValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->current_value = false;
}
- 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
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class PhpSecInfo_Test_Core_Gid extends PhpSecInfo_Test_Core
- Exclude checks
The property $recommended_value is not named in camelCase. Open
class PhpSecInfo_Test_Core_Gid extends PhpSecInfo_Test_Core
{
/**
* This should be a <b>unique</b>, human-readable identifier for this test
*
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The class PhpSecInfo_Test_Core_Gid is not named in CamelCase. Open
class PhpSecInfo_Test_Core_Gid extends PhpSecInfo_Test_Core
{
/**
* This should be a <b>unique</b>, human-readable identifier for this test
*
- 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 property $test_name is not named in camelCase. Open
class PhpSecInfo_Test_Core_Gid extends PhpSecInfo_Test_Core
{
/**
* This should be a <b>unique</b>, human-readable identifier for this test
*
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Avoid variables with short names like $id. Configured minimum length is 3. Open
$id = $this->getUnixId();
- 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
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 21 and the first side effect is on line 14. Open
<?php
- Exclude checks
Method name "_execTest" should not be prefixed with an underscore to indicate visibility Open
public function _execTest()
- Exclude checks
Method name "_setMessages" should not be prefixed with an underscore to indicate visibility Open
public function _setMessages()
- Exclude checks
Method name "_retrieveCurrentValue" should not be prefixed with an underscore to indicate visibility Open
public function _retrieveCurrentValue()
- Exclude checks
Line exceeds 120 characters; contains 131 characters Open
$this->setMessageForResult(PHPSECINFO_TEST_RESULT_OK, 'en', 'PHP is executing as what is probably a non-privileged group');
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
$this->setMessageForResult(PHPSECINFO_TEST_RESULT_NOTRUN, 'en', 'Functions required to retrieve group ID not available');
- Exclude checks
Line exceeds 120 characters; contains 168 characters Open
$this->setMessageForResult(PHPSECINFO_TEST_RESULT_WARN, 'en', 'PHP may be executing as a "privileged" group, which could be a serious security vulnerability.');
- Exclude checks
Class name "PhpSecInfo_Test_Core_Gid" is not in camel caps format Open
class PhpSecInfo_Test_Core_Gid extends PhpSecInfo_Test_Core
- Exclude checks
The variable $lowest_gid is not named in camelCase. Open
public function _retrieveCurrentValue()
{
$id = $this->getUnixId();
if (is_array($id)) {
- 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 $lowest_gid is not named in camelCase. Open
public function _retrieveCurrentValue()
{
$id = $this->getUnixId();
if (is_array($id)) {
- 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 method _retrieveCurrentValue is not named in camelCase. Open
public function _retrieveCurrentValue()
{
$id = $this->getUnixId();
if (is_array($id)) {
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method _execTest is not named in camelCase. Open
public function _execTest()
{
if ($this->current_value >= $this->recommended_value) {
return PHPSECINFO_TEST_RESULT_OK;
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method _setMessages is not named in camelCase. Open
public function _setMessages()
{
parent::_setMessages();
$this->setMessageForResult(PHPSECINFO_TEST_RESULT_OK, 'en', 'PHP is executing as what is probably a non-privileged group');
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}