madbob/GASdottoNG

View on GitHub
code/resources/assets/js/callables.js

Summary

Maintainability
C
1 day
Test Coverage

Callables has 26 functions (exceeds 20 allowed). Consider refactoring.
Open

class Callables {
    static attachUserRole(role_id, user_id, target_id, target_class) {
        utils.postAjax({
            method: 'POST',
            url: 'roles/attach',
Severity: Minor
Found in code/resources/assets/js/callables.js - About 3 hrs to fix

    File callables.js has 261 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    window.$ = window.jQuery = global.$ = global.jQuery = require('jquery');
    require('bootstrap');
    
    import utils from "./utils";
    import lists from "./lists";
    Severity: Minor
    Found in code/resources/assets/js/callables.js - About 2 hrs to fix

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

          static displayRecalculatedBalances(form, data) {
              var modal = $('#display-recalculated-balance-modal');
      
              if (data.diffs.length != 0) {
                  var table = modal.find('.broken.hidden').removeClass('hidden').find('tbody');
      Severity: Minor
      Found in code/resources/assets/js/callables.js - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          static afterBookingSaved(form, data) {
              var modal = form.closest('.modal');
      
              /*
                  In questo caso, ho aggiunto una prenotazione dal modale di "Aggiungi
      Severity: Minor
      Found in code/resources/assets/js/callables.js - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          static evaluateEmptyBooking(form) {
              if (form.find('input:hidden[name=action]').val() == 'shipped') {
                  var test = false;
      
                  form.find('.booking-total').each(function() {
      Severity: Minor
      Found in code/resources/assets/js/callables.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 2 locations. Consider refactoring.
      Open

          static detachUserRole(role_id, user_id, target_id, target_class) {
              utils.postAjax({
                  method: 'POST',
                  url: 'roles/detach',
                  data: {
      Severity: Major
      Found in code/resources/assets/js/callables.js and 1 other location - About 1 hr to fix
      code/resources/assets/js/callables.js on lines 8..19

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

      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

          static attachUserRole(role_id, user_id, target_id, target_class) {
              utils.postAjax({
                  method: 'POST',
                  url: 'roles/attach',
                  data: {
      Severity: Major
      Found in code/resources/assets/js/callables.js and 1 other location - About 1 hr to fix
      code/resources/assets/js/callables.js on lines 21..32

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

      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.action != 'approve') {
                  var upper = lists.closeParent(form);
                  var list = upper.closest('.loadable-list');
                  upper.remove();
                  lists.testListsEmptiness(list);
      Severity: Minor
      Found in code/resources/assets/js/callables.js and 1 other location - About 55 mins to fix
      code/resources/assets/js/gasdotto.js on lines 525..530

      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

          static supplierDetachUser(list, user_id) {
              var supplier_id = list.attr('data-supplier-id');
              var role_id = list.attr('data-role-id');
              Callables.detachUserRole(role_id, user_id, supplier_id, 'App\\Supplier');
          }
      Severity: Minor
      Found in code/resources/assets/js/callables.js and 1 other location - About 40 mins to fix
      code/resources/assets/js/callables.js on lines 34..38

      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

          static supplierAttachUser(list, user_id) {
              var supplier_id = list.attr('data-supplier-id');
              var role_id = list.attr('data-role-id');
              Callables.attachUserRole(role_id, user_id, supplier_id, 'App\\Supplier');
          }
      Severity: Minor
      Found in code/resources/assets/js/callables.js and 1 other location - About 40 mins to fix
      code/resources/assets/js/callables.js on lines 40..44

      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