XoopsModules25x/xoopsinfo

View on GitHub
phpsysinfo/plugins/raid/js/raid.js

Summary

Maintainability
F
3 days
Test Coverage

Function raid_buildinfos has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

function raid_buildinfos(xml, id) {
    var html = "", prog = "", devname = "", devstatus = "", devlevel = "", devcontroller = "", devbattery = "", devsupported = "", devsize = 0, devstride = 0, devsubsets = 0, devdevs = 0, devspares = 0, devchunk = 0, devalgor = "", devpersist = 0, devreg = 0, devact = 0, devcache = 0, devbad = 0, devread = "", devwrite = "", button = "";

    prog = $(xml).attr("Program");
    devname = $(xml).attr("Name");
Severity: Minor
Found in phpsysinfo/plugins/raid/js/raid.js - About 3 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 raid_buildinfos has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function raid_buildinfos(xml, id) {
    var html = "", prog = "", devname = "", devstatus = "", devlevel = "", devcontroller = "", devbattery = "", devsupported = "", devsize = 0, devstride = 0, devsubsets = 0, devdevs = 0, devspares = 0, devchunk = 0, devalgor = "", devpersist = 0, devreg = 0, devact = 0, devcache = 0, devbad = 0, devread = "", devwrite = "", button = "";

    prog = $(xml).attr("Program");
    devname = $(xml).attr("Name");
Severity: Major
Found in phpsysinfo/plugins/raid/js/raid.js - About 2 hrs to fix

    Function raid_diskicon has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function raid_diskicon(xml, id) {
        $("RaidItems Item", xml).each(function raid_getitems(itemid) {
            var status = "", name = "", type = "", info = "", parentid = 0;
    
            status = $(this).attr("Status");
    Severity: Major
    Found in phpsysinfo/plugins/raid/js/raid.js - About 2 hrs to fix

      Function raid_getitems has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          $("RaidItems Item", xml).each(function raid_getitems(itemid) {
              var status = "", name = "", type = "", info = "", parentid = 0;
      
              status = $(this).attr("Status");
              name = $(this).attr("Name");
      Severity: Minor
      Found in phpsysinfo/plugins/raid/js/raid.js - About 2 hrs to fix

        Function raid_diskicon has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        function raid_diskicon(xml, id) {
            $("RaidItems Item", xml).each(function raid_getitems(itemid) {
                var status = "", name = "", type = "", info = "", parentid = 0;
        
                status = $(this).attr("Status");
        Severity: Minor
        Found in phpsysinfo/plugins/raid/js/raid.js - 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

        Function raid_populate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function raid_populate(xml) {
            $("#Plugin_RaidTable").empty();
            $("#Plugin_RaidTable").append("<tbody>");
            var arr = $("Plugins Plugin_Raid Raid", xml);
            arr.each(function raid_getdevice(id) {
        Severity: Minor
        Found in phpsysinfo/plugins/raid/js/raid.js - About 1 hr to fix

          Function raid_buildaction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          function raid_buildaction(xml) {
              var html = "", name = "", time = "", tunit = "", percent = 0;
              $("Action", xml).each(function mdstatus_getaction(id) {
                  name = $(this).attr("Name");
                  if (parseInt(name, 10) !== -1) {
          Severity: Minor
          Found in phpsysinfo/plugins/raid/js/raid.js - About 25 mins 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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  switch (status) {
                  case "ok":
                      img = "harddriveok.png";
                      alt = "ok";
                      bcolor = "green";
          Severity: Major
          Found in phpsysinfo/plugins/raid/js/raid.js and 1 other location - About 5 hrs to fix
          phpsysinfo/plugins/raid/js/raid_bootstrap.js on lines 30..62

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 150.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 12 locations. Consider refactoring.
          Open

          function raid_request() {
              $("#Reload_RaidTable").attr("title", "reload");
              $.ajax({
                  url: "xml.php?plugin=Raid",
                  dataType: "xml",
          Severity: Major
          Found in phpsysinfo/plugins/raid/js/raid.js and 11 other locations - About 4 hrs to fix
          phpsysinfo/plugins/bat/js/bat.js on lines 186..203
          phpsysinfo/plugins/docker/js/docker.js on lines 118..135
          phpsysinfo/plugins/hyperv/js/hyperv.js on lines 96..113
          phpsysinfo/plugins/iptables/js/iptables.js on lines 73..90
          phpsysinfo/plugins/pingtest/js/pingtest.js on lines 95..112
          phpsysinfo/plugins/ps/js/ps.js on lines 113..130
          phpsysinfo/plugins/psstatus/js/psstatus.js on lines 96..113
          phpsysinfo/plugins/quotas/js/quotas.js on lines 118..135
          phpsysinfo/plugins/snmppinfo/js/snmppinfo.js on lines 131..148
          phpsysinfo/plugins/stablebit/js/stablebit.js on lines 179..196
          phpsysinfo/plugins/uprecords/js/uprecords.js on lines 95..112

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 126.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  $("#sPlugin_Raid_Info" + id).click(function raid_showinfo() {
                      $("#Plugin_Raid_InfoTable" + id).slideDown("fast");
                      $("#sPlugin_Raid_Info" + id).hide();
                      $("#hPlugin_Raid_Info" + id).show();
                  });
          Severity: Major
          Found in phpsysinfo/plugins/raid/js/raid.js and 1 other location - About 2 hrs to fix
          phpsysinfo/plugins/raid/js/raid.js on lines 213..217

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 81.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  $("#hPlugin_Raid_Info" + id).click(function raid_hideinfo() {
                      $("#Plugin_Raid_InfoTable" + id).slideUp("fast");
                      $("#hPlugin_Raid_Info" + id).hide();
                      $("#sPlugin_Raid_Info" + id).show();
                  });
          Severity: Major
          Found in phpsysinfo/plugins/raid/js/raid.js and 1 other location - About 2 hrs to fix
          phpsysinfo/plugins/raid/js/raid.js on lines 208..212

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 81.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          There are no issues that match your filters.

          Category
          Status