CORE-POS/IS4C

View on GitHub
fannie/item/modules/baseItem.js

Summary

Maintainability
F
4 days
Test Coverage

Function baseItem has 265 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var baseItem = (function() {
    var mod = {};

    mod.chainSubs = function(store_id) {
        chainSubDepartments(
Severity: Major
Found in fannie/item/modules/baseItem.js - About 1 day to fix

    Function baseItem has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    var baseItem = (function() {
        var mod = {};
    
        mod.chainSubs = function(store_id) {
            chainSubDepartments(
    Severity: Minor
    Found in fannie/item/modules/baseItem.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

    File baseItem.js has 267 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    var baseItem = (function() {
        var mod = {};
    
        mod.chainSubs = function(store_id) {
            chainSubDepartments(
    Severity: Minor
    Found in fannie/item/modules/baseItem.js - About 2 hrs to fix

      Function addVendorDialog has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          mod.addVendorDialog = function() {
              var v_dialog = $('#newVendorDialog').dialog({
                  autoOpen: false,
                  height: 300,
                  width: 300,
      Severity: Major
      Found in fannie/item/modules/baseItem.js - About 2 hrs to fix

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

            mod.chainSubs = function(store_id) {
                chainSubDepartments(
                    '../ws/',
                    {
                        super_id: '#super-dept'+store_id,
        Severity: Major
        Found in fannie/item/modules/baseItem.js - About 2 hrs to fix

          Function callback has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                          callback: function() {
                              $('#subdept'+store_id+' option:first').html('None').val(0);
                              $('#subdept'+store_id).trigger('chosen:updated');
                              $.ajax({
                                  url: 'modules/ajax/BaseItemAjax.php',
          Severity: Minor
          Found in fannie/item/modules/baseItem.js - About 1 hr to fix

            Function markUnSynced has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                mod.markUnSynced = function() {
                    var store_id = $('.tab-pane.active .store-id:first').val();
                    var current = syncNamesValues('#store-tab-'+store_id+' .syncable-input', function(obj, ret) {
                        ret[obj.attr('name')] = obj.val();
                        return ret;
            Severity: Minor
            Found in fannie/item/modules/baseItem.js - About 1 hr to fix

              Function vendorChanged has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  mod.vendorChanged = function(newVal) {
                      var vendors = [];
                      $('#CatalogContents tr').each(function(){
                          let tmpVendorName = $(this).find('td:nth-child(1)').text();
                          let tmpSku = $(this).find('td:nth-child(2)').text();
              Severity: Minor
              Found in fannie/item/modules/baseItem.js - About 1 hr to fix

                Function syncStoreTabs has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    mod.syncStoreTabs = function() {
                        if ($('#store-sync').prop('checked') === false) {
                            mod.markUnSynced();
                            return true;
                        }
                Severity: Minor
                Found in fannie/item/modules/baseItem.js - About 1 hr to fix

                  Function addVendorCallback has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          function addVendorCallback() {
                              var data = 'action=addVendor';
                              data += '&' + $('#newVendorDialog :input').serialize();
                              $.ajax({
                                  url: 'modules/ajax/BaseItemAjax.php',
                  Severity: Minor
                  Found in fannie/item/modules/baseItem.js - About 1 hr to fix

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

                            var checkboxes = syncNamesValues('#store-tab-'+store_id+' .syncable-checkbox', function(obj, ret) {
                                ret[obj.attr('name')] = obj.prop('checked');
                                return ret;
                            });
                    Severity: Major
                    Found in fannie/item/modules/baseItem.js and 1 other location - About 1 hr to fix
                    fannie/item/modules/baseItem.js on lines 213..216

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

                    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

                            var checkboxes = syncNamesValues('#store-tab-'+store_id+' .syncable-checkbox', function(obj, ret) {
                                ret[obj.attr('name')] = obj.prop('checked');
                                return ret;
                            });
                    Severity: Major
                    Found in fannie/item/modules/baseItem.js and 1 other location - About 1 hr to fix
                    fannie/item/modules/baseItem.js on lines 253..256

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

                    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

                            var current = syncNamesValues('#store-tab-'+store_id+' .syncable-input', function(obj, ret) {
                                ret[obj.attr('name')] = obj.val();
                                return ret;
                            });
                    Severity: Major
                    Found in fannie/item/modules/baseItem.js and 1 other location - About 1 hr to fix
                    fannie/item/modules/baseItem.js on lines 195..198

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

                    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

                            var current = syncNamesValues('#store-tab-'+store_id+' .syncable-input', function(obj, ret) {
                                ret[obj.attr('name')] = obj.val();
                                return ret;
                            });
                    Severity: Major
                    Found in fannie/item/modules/baseItem.js and 1 other location - About 1 hr to fix
                    fannie/item/modules/baseItem.js on lines 238..241

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

                    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 (data.wic) {
                                                $('#wic'+store_id).prop('checked', true);
                                            } else {
                                                $('#wic'+store_id).prop('checked', false);
                                            }
                    Severity: Major
                    Found in fannie/item/modules/baseItem.js and 1 other location - About 1 hr to fix
                    fannie/item/modules/baseItem.js on lines 24..28

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

                    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 (data.fs) {
                                                $('#FS'+store_id).prop('checked',true);
                                            } else {
                                                $('#FS'+store_id).prop('checked', false);
                                            }
                    Severity: Major
                    Found in fannie/item/modules/baseItem.js and 1 other location - About 1 hr to fix
                    fannie/item/modules/baseItem.js on lines 29..33

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

                    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 (tmpVendorName == newVal) {
                                    $('input[name="vendorSKU"]').val(tmpSku);
                                    $('input[name="caseSize"]').val(tmpUnits);
                                    $('input[name="cost[]"]').val(tmpCost);
                                }
                    Severity: Minor
                    Found in fannie/item/modules/baseItem.js and 1 other location - About 40 mins to fix
                    fannie/modules/plugins2.0/WfcHoursTracking/eval/view.js on lines 2..6

                    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

                    There are no issues that match your filters.

                    Category
                    Status