um-cseg/chez-betty

View on GitHub
chezbetty/static/js/chezbetty-terminal.js

Summary

Maintainability
D
2 days
Test Coverage

File chezbetty-terminal.js has 564 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Chez Betty Main Terminal Javascript
 *
 */

Severity: Major
Found in chezbetty/static/js/chezbetty-terminal.js - About 1 day to fix

    Function calculate_total has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function calculate_total () {
        total = 0;
        $("#purchase-table tr.purchase-item").each(function (index) {
            if ($(this).attr('id') != "purchase-empty") {
                line_total = parseFloat(
    Severity: Minor
    Found in chezbetty/static/js/chezbetty-terminal.js - About 1 hr to fix

      Function submit_purchase has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function submit_purchase (this_btn, success_cb, error_cb) {
          purchase_alert_clear();
      
          if (this_btn != null) {
              $(this_btn).blur();
      Severity: Minor
      Found in chezbetty/static/js/chezbetty-terminal.js - About 1 hr to fix

        Function calculate_total has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        function calculate_total () {
            total = 0;
            $("#purchase-table tr.purchase-item").each(function (index) {
                if ($(this).attr('id') != "purchase-empty") {
                    line_total = parseFloat(
        Severity: Minor
        Found in chezbetty/static/js/chezbetty-terminal.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 calculate_wallofshame_fee_percent has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function calculate_wallofshame_fee_percent (balance, total) {
            // If not on wall of shame, nor going to be, no fee
            if (balance - total > -5.0) return 0.0;
        
            // Calculate the correct fee.
        Severity: Minor
        Found in chezbetty/static/js/chezbetty-terminal.js - About 1 hr to fix

          Function add_item_success has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          function add_item_success (data) {
              purchase_alert_clear();
          
              if ("error" in data) {
                  purchase_alert_error(data.error);
          Severity: Minor
          Found in chezbetty/static/js/chezbetty-terminal.js - About 55 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

          Function calculate_wallofshame_fee_percent has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          function calculate_wallofshame_fee_percent (balance, total) {
              // If not on wall of shame, nor going to be, no fee
              if (balance - total > -5.0) return 0.0;
          
              // Calculate the correct fee.
          Severity: Minor
          Found in chezbetty/static/js/chezbetty-terminal.js - About 45 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

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

          function show_correct_purchase_button () {
              if ($("#purchase-complete:visible").length == 1) {
                  // If we are on the purchase complete page, show logout
                  $("#purchase-button-purchaselogout").hide();
                  $("#purchase-button-purchase").hide();
          Severity: Minor
          Found in chezbetty/static/js/chezbetty-terminal.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 3 locations. Consider refactoring.
          Open

          $('#btn-nobarcode-tag-items-back').click(function () {
              $('#tag-items').hide();
              $('#tags').show();
          });
          Severity: Major
          Found in chezbetty/static/js/chezbetty-terminal.js and 2 other locations - About 50 mins to fix
          chezbetty/static/js/chezbetty-terminal.js on lines 732..735
          chezbetty/static/js/chezbetty-terminal.js on lines 738..741

          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 52.

          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 3 locations. Consider refactoring.
          Open

          $('#btn-nobarcode').click(function () {
              $('#panel-purchase').hide();
              $('#panel-nobarcode').show();
          });
          Severity: Major
          Found in chezbetty/static/js/chezbetty-terminal.js and 2 other locations - About 50 mins to fix
          chezbetty/static/js/chezbetty-terminal.js on lines 738..741
          chezbetty/static/js/chezbetty-terminal.js on lines 744..747

          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 52.

          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 3 locations. Consider refactoring.
          Open

          $('#btn-nobarcode-tags-back').click(function () {
              $('#panel-nobarcode').hide();
              $('#panel-purchase').show();
          });
          Severity: Major
          Found in chezbetty/static/js/chezbetty-terminal.js and 2 other locations - About 50 mins to fix
          chezbetty/static/js/chezbetty-terminal.js on lines 732..735
          chezbetty/static/js/chezbetty-terminal.js on lines 744..747

          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 52.

          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

              if ($("#purchase-complete:visible").length == 1) {
                  // If we are on the purchase complete page, show logout
                  $("#purchase-button-purchaselogout").hide();
                  $("#purchase-button-purchase").hide();
                  $("#purchase-button-logout").show();
          Severity: Minor
          Found in chezbetty/static/js/chezbetty-terminal.js and 1 other location - About 40 mins to fix
          chezbetty/static/js/chezbetty-terminal.js on lines 231..250

          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 48.

          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

              } else if ($("#purchase-empty:visible").length == 1) {
                  // If there is nothing in the cart, then it should be a logout button
                  $("#purchase-button-purchaselogout").hide();
                  $("#purchase-button-purchase").hide();
                  $("#purchase-button-logout").show();
          Severity: Minor
          Found in chezbetty/static/js/chezbetty-terminal.js and 1 other location - About 40 mins to fix
          chezbetty/static/js/chezbetty-terminal.js on lines 225..250

          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 48.

          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 7 locations. Consider refactoring.
          Open

          function deposit_alert_success (error_str) {
              html = '<div class="alert alert-success" role="alert">'+error_str+'</div>';
              deposit_alert_clear();
              $("#deposit-alerts").html(html);
          }
          Severity: Major
          Found in chezbetty/static/js/chezbetty-terminal.js and 6 other locations - About 30 mins to fix
          chezbetty/static/js/chezbetty-common.js on lines 10..14
          chezbetty/static/js/chezbetty-common.js on lines 16..20
          chezbetty/static/js/chezbetty-terminal.js on lines 47..51
          chezbetty/static/js/chezbetty-terminal.js on lines 57..61
          chezbetty/static/js/chezbetty-user.js on lines 37..41
          chezbetty/static/js/chezbetty-user.js on lines 43..47

          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 45.

          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

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

              $(this).parent().parent().find(".item-total").html(format_price(quantity*item_price));
          Severity: Minor
          Found in chezbetty/static/js/chezbetty-terminal.js and 1 other location - About 30 mins to fix
          chezbetty/static/js/chezbetty-terminal.js on lines 672..672

          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 45.

          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 7 locations. Consider refactoring.
          Open

          function purchase_alert_success (error_str) {
              html = '<div class="alert alert-success" role="alert">'+error_str+'</div>';
              purchase_alert_clear();
              $("#purchase-alerts").html(html);
          }
          Severity: Major
          Found in chezbetty/static/js/chezbetty-terminal.js and 6 other locations - About 30 mins to fix
          chezbetty/static/js/chezbetty-common.js on lines 10..14
          chezbetty/static/js/chezbetty-common.js on lines 16..20
          chezbetty/static/js/chezbetty-terminal.js on lines 41..45
          chezbetty/static/js/chezbetty-terminal.js on lines 47..51
          chezbetty/static/js/chezbetty-user.js on lines 37..41
          chezbetty/static/js/chezbetty-user.js on lines 43..47

          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 45.

          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 7 locations. Consider refactoring.
          Open

          function deposit_alert_error (error_str) {
              html = '<div class="alert alert-danger" role="alert">'+error_str+'</div>';
              deposit_alert_clear();
              $("#deposit-alerts").html(html);
          }
          Severity: Major
          Found in chezbetty/static/js/chezbetty-terminal.js and 6 other locations - About 30 mins to fix
          chezbetty/static/js/chezbetty-common.js on lines 10..14
          chezbetty/static/js/chezbetty-common.js on lines 16..20
          chezbetty/static/js/chezbetty-terminal.js on lines 41..45
          chezbetty/static/js/chezbetty-terminal.js on lines 57..61
          chezbetty/static/js/chezbetty-user.js on lines 37..41
          chezbetty/static/js/chezbetty-user.js on lines 43..47

          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 45.

          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

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

              $(this).parent().parent().find(".item-total").html(format_price(quantity*item_price));
          Severity: Minor
          Found in chezbetty/static/js/chezbetty-terminal.js and 1 other location - About 30 mins to fix
          chezbetty/static/js/chezbetty-terminal.js on lines 654..654

          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 45.

          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