expertiza/expertiza

View on GitHub
app/assets/javascripts/userDeleteConfirmBox.js

Summary

Maintainability
B
4 hrs
Test Coverage

Function showConfirmDialogSpecial has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

$.rails.showConfirmDialogSpecial = function(link) {
  var message = link.attr('data-confirm');
  var html1 = "<div class=\"modal\" id=\"dialog-confirm1\" title=\"Delete This User?\">\n  <div class=\"modal-body\">\n    <p>" + message + "</p>\n";

  var html2 = "<div class=\"modal\" id=\"dialog-confirm2\" title=\"System Information\">\n  <div class=\"modal-body\">\n    <p>This user cannot be deleted. Do you want to rename the user account to <b>" + link.attr('data-username') + "_hidden</b>?</p>\n"; 
Severity: Major
Found in app/assets/javascripts/userDeleteConfirmBox.js - About 2 hrs to fix

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

            "Yes": function() {
              //return $.rails.confirmed(link);
              $( this ).dialog( "close" );
              $(html2).modal();
              $("#dialog-confirm2").dialog({
    Severity: Minor
    Found in app/assets/javascripts/userDeleteConfirmBox.js - About 1 hr to fix

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

      $.rails.allowAction = function(link) {
        //use normal confirm dialog, when link does not have 'data-overridden' attribute.
        if (!link.attr("confirm")){
          if (link.attr('data-confirm')){
            if (link.attr('data-overridden')){
      Severity: Minor
      Found in app/assets/javascripts/userDeleteConfirmBox.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

      There are no issues that match your filters.

      Category
      Status