CORE-POS/IS4C

View on GitHub
fannie/ordering/orderview.js

Summary

Maintainability
F
1 wk
Test Coverage

Function orderView has 413 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var orderView = (function($) {
    var mod = {};
    var forceUPC = true;

    mod.forceUPC = function(f) {
Severity: Major
Found in fannie/ordering/orderview.js - About 2 days to fix

    File orderview.js has 435 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    var orderView = (function($) {
        var mod = {};
        var forceUPC = true;
    
        mod.forceUPC = function(f) {
    Severity: Minor
    Found in fannie/ordering/orderview.js - About 6 hrs to fix

      Function orderView has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

      var orderView = (function($) {
          var mod = {};
          var forceUPC = true;
      
          mod.forceUPC = function(f) {
      Severity: Minor
      Found in fannie/ordering/orderview.js - About 4 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 afterLoadItems has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          mod.afterLoadItems = function() {
              $('.item-field').change(mod.saveItem);
              if ($('#newqty').length) {
                  $('#newqty').focus();    
                  $('#itemDiv form').submit(function (e) {
      Severity: Major
      Found in fannie/ordering/orderview.js - About 2 hrs to fix

        Function memNumEntered has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            mod.memNumEntered = function(){
                var oid = $('#orderID').val();
                var cardno = $('#memNum').val();    
                $.ajax({
                    type: 'get',
        Severity: Major
        Found in fannie/ordering/orderview.js - About 2 hrs to fix

          Function afterLoadCustomer has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              mod.afterLoadCustomer = function() {
                  $('.contact-field').change(mod.saveContactInfo);
                  $('#memNum').change(mod.memNumEntered);
                  $('#s_personNum').change(function() {
                      mod.savePN($('#orderID').val(), $(this).val());
          Severity: Minor
          Found in fannie/ordering/orderview.js - About 1 hr to fix

            Function validateAndHome has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                mod.validateAndHome = function (){
                    var dcheck=false;
                    $('select.editDept').each(function(){
                        if ($(this).val() === '0'){
                            dcheck=true;
            Severity: Minor
            Found in fannie/ordering/orderview.js - About 1 hr to fix

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

                  mod.validateAndHome = function (){
                      var dcheck=false;
                      $('select.editDept').each(function(){
                          if ($(this).val() === '0'){
                              dcheck=true;
              Severity: Major
              Found in fannie/ordering/orderview.js and 1 other location - About 1 day to fix
              fannie/ordering/view.js on lines 349..382

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

              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

                  mod.newQty = function (oid,tid){
                      var qty = $('#newqty').val();
                      $.ajax({
                          type: 'post',
                          data: 'orderID='+oid+'&transID='+tid+'&qty='+qty
              Severity: Major
              Found in fannie/ordering/orderview.js and 1 other location - About 4 hrs to fix
              fannie/ordering/orderview.js on lines 273..282

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

              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

                  mod.newDept = function (oid,tid){
                      var dstr = $('.more-item-info :input').serialize();
                      $.ajax({
                          type: 'post',
                          data: 'orderID='+oid+'&transID='+tid+'&'+dstr
              Severity: Major
              Found in fannie/ordering/orderview.js and 1 other location - About 4 hrs to fix
              fannie/ordering/orderview.js on lines 263..272

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

              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

                  mod.getComms = function(oid) {
                      $.ajax({
                          url: 'OrderAjax.php',
                          type: 'get',
                          data: 'id='+oid+'&comms=1'
              Severity: Major
              Found in fannie/ordering/orderview.js and 1 other location - About 1 hr to fix
              fannie/item/departments/super.js on lines 65..73

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

              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-delete').click(function (e) {
                          mod.deleteID($(this).data('order'), $(this).data('trans'));
                          e.preventDefault();
                          return false;
                      });
              Severity: Major
              Found in fannie/ordering/orderview.js and 2 other locations - About 1 hr to fix
              fannie/ordering/orderview.js on lines 177..181
              fannie/ordering/orderview.js on lines 185..189

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

              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

                          $('#itemDiv form').submit(function (e) {
                              mod.newDept($(this).data('order'), $(this).data('trans'));
                              e.preventDefault();
                              return false;
                          });
              Severity: Major
              Found in fannie/ordering/orderview.js and 2 other locations - About 1 hr to fix
              fannie/ordering/orderview.js on lines 177..181
              fannie/ordering/orderview.js on lines 202..206

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

              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

                          $('#itemDiv form').submit(function (e) {
                              mod.newQty($(this).data('order'), $(this).data('trans'));
                              e.preventDefault();
                              return false;
                          });
              Severity: Major
              Found in fannie/ordering/orderview.js and 2 other locations - About 1 hr to fix
              fannie/ordering/orderview.js on lines 185..189
              fannie/ordering/orderview.js on lines 202..206

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

              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

                  mod.savePN = function (oid,val){
                      $.ajax({
                          url: 'OrderAjax.php',
                          type: 'post',
                          data: 'pn='+val+'&id='+oid
              Severity: Major
              Found in fannie/ordering/orderview.js and 2 other locations - About 1 hr to fix
              fannie/item/likecodes/skuMap.js on lines 71..77
              fannie/ordering/orderview.js on lines 100..106

              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

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

                  mod.saveCtC = function (val,oid){
                      $.ajax({
                          url: 'OrderAjax.php',
                          type: 'post',
                          data: 'id='+oid+'&ctc='+val
              Severity: Major
              Found in fannie/ordering/orderview.js and 2 other locations - About 1 hr to fix
              fannie/item/likecodes/skuMap.js on lines 71..77
              fannie/ordering/orderview.js on lines 283..289

              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

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

                  $('#ctcselect').change(function() {
                      orderView.saveCtC($(this).val(), $('#orderID').val());
                  });
              Severity: Minor
              Found in fannie/ordering/orderview.js and 1 other location - About 55 mins to fix
              fannie/ordering/orderview.js on lines 121..123

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

              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

                      $('#orderStore').change(function() {
                          mod.updateStore($('#orderID').val(), $(this).val());
                      });
              Severity: Minor
              Found in fannie/ordering/orderview.js and 1 other location - About 55 mins to fix
              fannie/ordering/orderview.js on lines 62..64

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

              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

                      $('#s_personNum').change(function() {
                          mod.savePN($('#orderID').val(), $(this).val());
                      });
              Severity: Minor
              Found in fannie/ordering/orderview.js and 1 other location - About 55 mins to fix
              fannie/ordering/orderview.js on lines 78..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 54.

              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

                              $('#ctcselect').change(function() {
                                  mod.saveCtC($(this).val(), $('#orderID').val());
                              });
              Severity: Minor
              Found in fannie/ordering/orderview.js and 1 other location - About 55 mins to fix
              fannie/ordering/orderview.js on lines 445..447

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

              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

                              $('#confirm-date').change(function(e) {
                                  mod.saveConfirmDate(e.target.checked, $('#orderID').val());
                              });
              Severity: Minor
              Found in fannie/ordering/orderview.js and 1 other location - About 50 mins to fix
              fannie/ordering/orderview.js on lines 453..455

              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

                  $('#confirm-date').change(function(e) {
                      orderView.saveConfirmDate(e.target.checked, $('#orderID').val());
                  });
              Severity: Minor
              Found in fannie/ordering/orderview.js and 1 other location - About 50 mins to fix
              fannie/ordering/orderview.js on lines 118..120

              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

              There are no issues that match your filters.

              Category
              Status