um-cseg/chez-betty

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

Summary

Maintainability
F
4 days
Test Coverage

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

/* Functions to manipulate price strings and numbers.
 */
function format_price (price) {
    p = price.toFixed(2);

Severity: Minor
Found in chezbetty/static/js/chezbetty-admin.js - About 3 hrs to fix

    Function search_item_success has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    function search_item_success (data) {
        alert_clear();
        $("#restock-search-notice").text("");
        $(".restock-search-addedrows").remove();
    
    
    Severity: Minor
    Found in chezbetty/static/js/chezbetty-admin.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 search_item_only_success has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    function search_item_only_success (data, context, one_item_fn) {
        alert_clear();
        $("#" + context + "-notice-item").text("");
        $("." + context + "-item-addedrows").remove();
    
    
    Severity: Minor
    Found in chezbetty/static/js/chezbetty-admin.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 search_user_success has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    function search_user_success (data, prefix) {
        alert_clear();
        $("#"+prefix+"-notice").text("");
        $("."+prefix+"-addedrows").remove();
    
    
    Severity: Minor
    Found in chezbetty/static/js/chezbetty-admin.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 search_item_success has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function search_item_success (data) {
        alert_clear();
        $("#restock-search-notice").text("");
        $(".restock-search-addedrows").remove();
    
    
    Severity: Minor
    Found in chezbetty/static/js/chezbetty-admin.js - About 1 hr to fix

      Function search_item_only_success has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function search_item_only_success (data, context, one_item_fn) {
          alert_clear();
          $("#" + context + "-notice-item").text("");
          $("." + context + "-item-addedrows").remove();
      
      
      Severity: Minor
      Found in chezbetty/static/js/chezbetty-admin.js - About 1 hr to fix

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

        function user_purchase_add_item_success (data) {
            if (data.status != "success") {
                if (data.status == "unknown_barcode") {
                    alert_error("Could not find that item.");
                } else {
        Severity: Minor
        Found in chezbetty/static/js/chezbetty-admin.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 add_item_success has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        function add_item_success (data) {
            if (data.status != "success") {
                if (data.status == "unknown_barcode") {
                    alert_error("Could not find that item.");
                } else {
        Severity: Minor
        Found in chezbetty/static/js/chezbetty-admin.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 email_recall_add_item_success has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        function email_recall_add_item_success (data) {
            console.log(data);
            if (data.status != "success") {
                if (data.status == "unknown_barcode") {
                    alert_error("Could not find that item.");
        Severity: Minor
        Found in chezbetty/static/js/chezbetty-admin.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

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

                            new_row.find("button").each(function (index) {
                                start_id = $(this).attr("id");
                                splits = start_id.split("-");
                                splits[splits.length-1] = i+1;
                                new_id = splits.join("-");
        Severity: Major
        Found in chezbetty/static/js/chezbetty-admin.js and 1 other location - About 5 hrs to fix
        chezbetty/static/js/chezbetty-admin.js on lines 101..108

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

        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

                        new_row.find("button").each(function (index) {
                            start_id = $(this).attr("id");
                            splits = start_id.split("-");
                            splits[splits.length-1] = i+1;
                            new_id = splits.join("-");
        Severity: Major
        Found in chezbetty/static/js/chezbetty-admin.js and 1 other location - About 5 hrs to fix
        chezbetty/static/js/chezbetty-admin.js on lines 269..276

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

        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

        function format_price (price) {
            p = price.toFixed(2);
        
            if (p < 0) {
                return '<span class="negative">-$' + (p*-1.0).toFixed(2) + '</span>';
        Severity: Major
        Found in chezbetty/static/js/chezbetty-admin.js and 1 other location - About 2 hrs to fix
        chezbetty/static/js/chezbetty-user.js on lines 3..11

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

        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 (!isNaN(recipient_balance)) {
                var new_recipeint = recipient_balance + amount;
                $("#recipient-balance").html(format_price(new_recipeint));
            } else {
                $("#recipient-balance").html('');
        Severity: Major
        Found in chezbetty/static/js/chezbetty-admin.js and 1 other location - About 1 hr to fix
        chezbetty/static/js/chezbetty-admin.js on lines 413..418

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

        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 (!isNaN(sender_balance)) {
                var new_sender = sender_balance - amount;
                $("#sender-balance").html(format_price(new_sender));
            } else {
                $("#sender-balance").html('');
        Severity: Major
        Found in chezbetty/static/js/chezbetty-admin.js and 1 other location - About 1 hr to fix
        chezbetty/static/js/chezbetty-admin.js on lines 420..425

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

        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

        function add_item (barcode) {
            $.ajax({
                dataType: "json",
                url: "/admin/item/barcode/"+barcode+"/json",
                success: add_item_success,
        Severity: Minor
        Found in chezbetty/static/js/chezbetty-admin.js and 1 other location - About 50 mins to fix
        chezbetty/static/js/chezbetty-admin.js on lines 201..208

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

        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

        function user_purchase_add_item (id) {
            $.ajax({
                dataType: "json",
                url: "/admin/item/id/"+id+"/json",
                success: user_purchase_add_item_success,
        Severity: Minor
        Found in chezbetty/static/js/chezbetty-admin.js and 1 other location - About 50 mins to fix
        chezbetty/static/js/chezbetty-admin.js on lines 73..80

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

        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

                    new_row = $("#email-recall-item").clone().attr("id", "email-recall-item-"+data.type+"-" + data.id);
        Severity: Minor
        Found in chezbetty/static/js/chezbetty-admin.js and 1 other location - About 40 mins to fix
        chezbetty/static/js/chezbetty-admin.js on lines 176..176

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

        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

                    new_row = $("#user-purchase-add-item").clone().attr("id", "user-purchase-add-item-"+data.type+"-" + data.id);
        Severity: Minor
        Found in chezbetty/static/js/chezbetty-admin.js and 1 other location - About 40 mins to fix
        chezbetty/static/js/chezbetty-admin.js on lines 224..224

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

        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