Function __construct
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function __construct()
{
parent::__construct();
$_wmi = null;
try {
- 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
Missing class import via use statement (line '86', column '24'). Open
$dev = new SensorDevice();
- 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
Missing class import via use statement (line '33', column '31'). Open
$objLocator = new COM('WbemScripting.SWbemLocator');
- 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
Missing class import via use statement (line '71', column '24'). Open
$dev = new SensorDevice();
- 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
Missing class import via use statement (line '56', column '24'). Open
$dev = new SensorDevice();
- 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
Missing class import via use statement (line '101', column '24'). Open
$dev = new SensorDevice();
- 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
$tmpbuf = CommonFunctions::getWMI($_wmi, 'Sensor', array('Parent', 'Name', 'SensorType', 'Value'));
- 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 OHM extends Sensors
- Exclude checks
The property $_buf is not named in camelCase. Open
class OHM extends Sensors
{
/**
* holds the COM object that we pull all the WMI data from
*
- 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
Expected 1 space after "=>"; 0 found Open
if (isset($this->_buf['Temperature'])) foreach ($this->_buf['Temperature'] as $name=>$value) {
- Exclude checks
Expected 1 space before "=>"; 0 found Open
if (isset($this->_buf['Power'])) foreach ($this->_buf['Power'] as $name=>$value) {
- Exclude checks
Expected 1 space before "=>"; 0 found Open
if (isset($this->_buf['Voltage'])) foreach ($this->_buf['Voltage'] as $name=>$value) {
- Exclude checks
Expected 1 space after "=>"; 0 found Open
if (isset($this->_buf['Fan'])) foreach ($this->_buf['Fan'] as $name=>$value) {
- Exclude checks
Method name "_power" should not be prefixed with an underscore to indicate visibility Open
private function _power()
- Exclude checks
Expected 1 space before "=>"; 0 found Open
if (isset($this->_buf['Temperature'])) foreach ($this->_buf['Temperature'] as $name=>$value) {
- Exclude checks
Method name "_temperature" should not be prefixed with an underscore to indicate visibility Open
private function _temperature()
- Exclude checks
Expected 1 space after "=>"; 0 found Open
if (isset($this->_buf['Voltage'])) foreach ($this->_buf['Voltage'] as $name=>$value) {
- Exclude checks
Method name "_fans" should not be prefixed with an underscore to indicate visibility Open
private function _fans()
- Exclude checks
Property name "$_buf" should not be prefixed with an underscore to indicate visibility Open
private $_buf = array();
- Exclude checks
Expected 1 space before "=>"; 0 found Open
if (isset($this->_buf['Fan'])) foreach ($this->_buf['Fan'] as $name=>$value) {
- Exclude checks
Expected 1 space after "=>"; 0 found Open
if (isset($this->_buf['Power'])) foreach ($this->_buf['Power'] as $name=>$value) {
- Exclude checks
Method name "_voltage" should not be prefixed with an underscore to indicate visibility Open
private function _voltage()
- Exclude checks
Inline control structures are not allowed Open
if (isset($this->_buf['Voltage'])) foreach ($this->_buf['Voltage'] as $name=>$value) {
- Exclude checks
Line exceeds 120 characters; contains 137 characters Open
$this->error->addError("WMI connect error", "PhpSysInfo can not connect to the WMI interface for OpenHardwareMonitor data.");
- Exclude checks
Inline control structures are not allowed Open
if (isset($this->_buf['Power'])) foreach ($this->_buf['Power'] as $name=>$value) {
- Exclude checks
Inline control structures are not allowed Open
if ($tmpbuf) foreach ($tmpbuf as $buffer) {
- Exclude checks
Inline control structures are not allowed Open
if (isset($this->_buf['Temperature'])) foreach ($this->_buf['Temperature'] as $name=>$value) {
- 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
Inline control structures are not allowed Open
if (isset($this->_buf['Fan'])) foreach ($this->_buf['Fan'] as $name=>$value) {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$this->_power();
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$this->_temperature();
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$this->_fans();
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$this->_voltage();
- Exclude checks
The variable $_wmi is not named in camelCase. Open
public function __construct()
{
parent::__construct();
$_wmi = null;
try {
- 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 $_wmi is not named in camelCase. Open
public function __construct()
{
parent::__construct();
$_wmi = null;
try {
- 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 $_wmi is not named in camelCase. Open
public function __construct()
{
parent::__construct();
$_wmi = null;
try {
- 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 $_wmi is not named in camelCase. Open
public function __construct()
{
parent::__construct();
$_wmi = null;
try {
- 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 _fans is not named in camelCase. Open
private function _fans()
{
if (isset($this->_buf['Fan'])) foreach ($this->_buf['Fan'] as $name=>$value) {
$dev = new SensorDevice();
$dev->setName($name);
- 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 _temperature is not named in camelCase. Open
private function _temperature()
{
if (isset($this->_buf['Temperature'])) foreach ($this->_buf['Temperature'] as $name=>$value) {
$dev = new SensorDevice();
$dev->setName($name);
- 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 _power is not named in camelCase. Open
private function _power()
{
if (isset($this->_buf['Power'])) foreach ($this->_buf['Power'] as $name=>$value) {
$dev = new SensorDevice();
$dev->setName($name);
- 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 _voltage is not named in camelCase. Open
private function _voltage()
{
if (isset($this->_buf['Voltage'])) foreach ($this->_buf['Voltage'] as $name=>$value) {
$dev = new SensorDevice();
$dev->setName($name);
- 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() {
}
}