XoopsModules25x/xoopsinfo

View on GitHub
phpsysinfo/includes/mb/class.ohm.inc.php

Summary

Maintainability
A
1 hr
Test Coverage

Function __construct has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct()
    {
        parent::__construct();
        $_wmi = null;
        try {
Severity: Minor
Found in phpsysinfo/includes/mb/class.ohm.inc.php - About 1 hr to fix

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();

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');

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();

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();

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();

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'));

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

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
     *

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) {

Expected 1 space before "=>"; 0 found
Open

        if (isset($this->_buf['Power'])) foreach ($this->_buf['Power'] as $name=>$value) {

Expected 1 space before "=>"; 0 found
Open

        if (isset($this->_buf['Voltage'])) foreach ($this->_buf['Voltage'] as $name=>$value) {

Expected 1 space after "=>"; 0 found
Open

        if (isset($this->_buf['Fan'])) foreach ($this->_buf['Fan'] as $name=>$value) {

Method name "_power" should not be prefixed with an underscore to indicate visibility
Open

    private function _power()

Expected 1 space before "=>"; 0 found
Open

        if (isset($this->_buf['Temperature'])) foreach ($this->_buf['Temperature'] as $name=>$value) {

Method name "_temperature" should not be prefixed with an underscore to indicate visibility
Open

    private function _temperature()

Expected 1 space after "=>"; 0 found
Open

        if (isset($this->_buf['Voltage'])) foreach ($this->_buf['Voltage'] as $name=>$value) {

Method name "_fans" should not be prefixed with an underscore to indicate visibility
Open

    private function _fans()

Property name "$_buf" should not be prefixed with an underscore to indicate visibility
Open

    private $_buf = array();

Expected 1 space before "=>"; 0 found
Open

        if (isset($this->_buf['Fan'])) foreach ($this->_buf['Fan'] as $name=>$value) {

Expected 1 space after "=>"; 0 found
Open

        if (isset($this->_buf['Power'])) foreach ($this->_buf['Power'] as $name=>$value) {

Method name "_voltage" should not be prefixed with an underscore to indicate visibility
Open

    private function _voltage()

Inline control structures are not allowed
Open

        if (isset($this->_buf['Voltage'])) foreach ($this->_buf['Voltage'] as $name=>$value) {

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.");

Inline control structures are not allowed
Open

        if (isset($this->_buf['Power'])) foreach ($this->_buf['Power'] as $name=>$value) {

Inline control structures are not allowed
Open

            if ($tmpbuf) foreach ($tmpbuf as $buffer) {

Inline control structures are not allowed
Open

        if (isset($this->_buf['Temperature'])) foreach ($this->_buf['Temperature'] as $name=>$value) {

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

Inline control structures are not allowed
Open

        if (isset($this->_buf['Fan'])) foreach ($this->_buf['Fan'] as $name=>$value) {

Line indented incorrectly; expected at least 8 spaces, found 6
Open

      $this->_power();

Line indented incorrectly; expected at least 8 spaces, found 6
Open

      $this->_temperature();

Line indented incorrectly; expected at least 8 spaces, found 6
Open

      $this->_fans();

Line indented incorrectly; expected at least 8 spaces, found 6
Open

      $this->_voltage();

The variable $_wmi is not named in camelCase.
Open

    public function __construct()
    {
        parent::__construct();
        $_wmi = null;
        try {

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 {

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 {

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 {

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);

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);

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);

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);

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

There are no issues that match your filters.

Category
Status