roqua/quby_engine

View on GitHub
app/assets/javascripts/quby/answers/rest.js

Summary

Maintainability
C
1 day
Test Coverage

File rest.js has 286 lines of code (exceeds 250 allowed). Consider refactoring.
Open

function initShowsHides(untilPanelId) {
  Quby.panels.find(function (bbPanel) {
    bbPanel.initShowsHides(Quby.questions);
    return bbPanel.get('panelId') == untilPanelId;
  });
Severity: Minor
Found in app/assets/javascripts/quby/answers/rest.js - About 2 hrs to fix

    Function assignValue has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    function assignValue(qkey, val){
        var inputs;
        if(val instanceof Object){//checkbox vals are passed as an object hash
            inputs = $("[name^='answer["+qkey+"_'][type!='hidden']");
        } else {
    Severity: Minor
    Found in app/assets/javascripts/quby/answers/rest.js - About 2 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 setAllCheckboxes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    function setAllCheckboxes(checked, allKey, nothingKey, question, checkValue){
        if(checked){
            // Setting all other checkboxes to checkValue
            check_boxes = $("#answer_"+question+"_input").find("input[type=checkbox]:not(:disabled)");
            if(check_boxes.length == 0){
    Severity: Minor
    Found in app/assets/javascripts/quby/answers/rest.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 handleAjaxFormRequests has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function handleAjaxFormRequests(prepareDisplayModeCallback) {
      $(document).on('ajax:success', "form", function(event, data, status, xhr) {
        content_type = (xhr.getResponseHeader("content-type")||"").split(';')[0];
        if (content_type == 'text/html') { // not json response
          $('#content').replaceWith(data);
    Severity: Minor
    Found in app/assets/javascripts/quby/answers/rest.js - About 1 hr to fix

      Function assignValue has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function assignValue(qkey, val){
          var inputs;
          if(val instanceof Object){//checkbox vals are passed as an object hash
              inputs = $("[name^='answer["+qkey+"_'][type!='hidden']");
          } else {
      Severity: Minor
      Found in app/assets/javascripts/quby/answers/rest.js - About 1 hr to fix

        Function setAllCheckboxes has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        function setAllCheckboxes(checked, allKey, nothingKey, question, checkValue){
        Severity: Minor
        Found in app/assets/javascripts/quby/answers/rest.js - About 35 mins to fix

          Function activatePanel has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          function activatePanel(panel, forward) {
              if (shownFlash) {
                  $('.flash').hide();
              }
              shownFlash = true;
          Severity: Minor
          Found in app/assets/javascripts/quby/answers/rest.js - About 35 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

          There are no issues that match your filters.

          Category
          Status