Function _info
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function _info()
{
if (empty($this->_output)) {
return;
}
- 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 _info
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function _info()
{
if (empty($this->_output)) {
return;
}
Missing class import via use statement (line '63', column '28'). Open
$dev = new UPSDevice();
- 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 'CommonFunctions' in method '__construct'. Open
if (CommonFunctions::executeProgram('pmset', '-g batt', $temp) && !empty($temp)) {
- 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
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Pmset extends UPS
- Exclude checks
The property $_output is not named in camelCase. Open
class Pmset extends UPS
{
/**
* internal storage for all gathered data
*
- 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
Method name "_info" should not be prefixed with an underscore to indicate visibility Open
private function _info()
- Exclude checks
Opening brace indented incorrectly; expected 3 spaces, found 4 Open
{
- Exclude checks
Property name "$_output" should not be prefixed with an underscore to indicate visibility Open
private $_output = array();
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 3 Open
private function _info()
- Exclude checks
Closing brace indented incorrectly; expected 3 spaces, found 4 Open
}
- Exclude checks
The method _info is not named in camelCase. Open
private function _info()
{
if (empty($this->_output)) {
return;
}
- 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() {
}
}