redmine/redmine

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

Summary

Maintainability
D
1 day
Test Coverage

Function contextMenuClick has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

function contextMenuClick(event) {
  var target = $(event.target);
  var lastSelected;

  if (target.is('a') && target.hasClass('submenu')) {
Severity: Minor
Found in app/assets/javascripts/context_menu.js - About 5 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 contextMenuClick has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function contextMenuClick(event) {
  var target = $(event.target);
  var lastSelected;

  if (target.is('a') && target.hasClass('submenu')) {
Severity: Major
Found in app/assets/javascripts/context_menu.js - About 2 hrs to fix

    Function contextMenuShow has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    function contextMenuShow(event) {
      var mouse_x = event.pageX;
      var mouse_y = event.pageY;
      var mouse_y_c = event.clientY;
      var render_x = mouse_x;
    Severity: Minor
    Found in app/assets/javascripts/context_menu.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

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

    function contextMenuShow(event) {
      var mouse_x = event.pageX;
      var mouse_y = event.pageY;
      var mouse_y_c = event.clientY;
      var render_x = mouse_x;
    Severity: Major
    Found in app/assets/javascripts/context_menu.js - About 2 hrs to fix

      Function success has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          success: function(data, textStatus, jqXHR) {
            $('#context-menu').html(data);
            menu_width = $('#context-menu').width();
            menu_height = $('#context-menu').height();
            max_width = mouse_x + 2*menu_width;
      Severity: Minor
      Found in app/assets/javascripts/context_menu.js - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                  if (lastSelected.length) {
                    var toggling = false;
                    $('.hascontextmenu').each(function(){
                      $elm = $(this)
                      if (!$elm.is(lastSelected) && (toggling || $elm.is(tr))) {
        Severity: Major
        Found in app/assets/javascripts/context_menu.js - About 45 mins to fix

          There are no issues that match your filters.

          Category
          Status