XoopsModules25x/xoopsinfo

View on GitHub
phpsysinfo/plugins/smart/js/smart_bootstrap.js

Summary

Maintainability
C
1 day
Test Coverage

Function renderPlugin_smart has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

function renderPlugin_smart(data) {

    if ((data.Plugins.Plugin_SMART !== undefined) && (data.Plugins.Plugin_SMART.columns !== undefined) && (items(data.Plugins.Plugin_SMART.columns.column).length > 0) && (data.Plugins.Plugin_SMART.disks !== undefined) && (items(data.Plugins.Plugin_SMART.disks.disk).length > 0)) {
        var smartitems = items(data.Plugins.Plugin_SMART.columns.column);
        var smartnames = {
Severity: Minor
Found in phpsysinfo/plugins/smart/js/smart_bootstrap.js - About 4 hrs 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

Function renderPlugin_smart has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function renderPlugin_smart(data) {

    if ((data.Plugins.Plugin_SMART !== undefined) && (data.Plugins.Plugin_SMART.columns !== undefined) && (items(data.Plugins.Plugin_SMART.columns.column).length > 0) && (data.Plugins.Plugin_SMART.disks !== undefined) && (items(data.Plugins.Plugin_SMART.disks.disk).length > 0)) {
        var smartitems = items(data.Plugins.Plugin_SMART.columns.column);
        var smartnames = {
Severity: Major
Found in phpsysinfo/plugins/smart/js/smart_bootstrap.js - About 3 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                        if (smartid === "194") {
                            html += '<td class="rightCell">' + formatTemp(itemvalue, data.Options["@attributes"].tempFormat) + '</td>';
                        } else {
                            html += '<td class="rightCell">' + itemvalue + '</td>';
                        }
    Severity: Major
    Found in phpsysinfo/plugins/smart/js/smart_bootstrap.js - About 45 mins to fix

      There are no issues that match your filters.

      Category
      Status