adobe/brackets

View on GitHub
src/command/Menus.js

Summary

Maintainability
F
6 days
Test Coverage

File Menus.js has 786 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright (c) 2012 - present Adobe Systems Incorporated. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
Severity: Major
Found in src/command/Menus.js - About 1 day to fix

    Function addMenuItem has 100 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        Menu.prototype.addMenuItem = function (command, keyBindings, position, relativeID) {
            var menuID = this.id,
                id,
                $menuItem,
                menuItem,
    Severity: Major
    Found in src/command/Menus.js - About 4 hrs to fix

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

          ContextMenu.prototype.open = function (mouseOrLocation) {
      
              if (!this.parentMenuItem &&
                 (!mouseOrLocation || !mouseOrLocation.hasOwnProperty("pageX") || !mouseOrLocation.hasOwnProperty("pageY"))) {
                  console.error("ContextMenu open(): missing required parameter");
      Severity: Major
      Found in src/command/Menus.js - About 2 hrs to fix

        Function _getRelativeMenuItem has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            Menu.prototype._getRelativeMenuItem = function (relativeID, position) {
                var $relativeElement;
        
                if (relativeID) {
                    if (position === FIRST_IN_SECTION || position === LAST_IN_SECTION) {
        Severity: Minor
        Found in src/command/Menus.js - About 1 hr to fix

          Function addMenu has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function addMenu(name, id, position, relativeID) {
                  name = _.escape(name);
                  var $menubar = $("#titlebar .nav"),
                      menu;
          
          
          Severity: Minor
          Found in src/command/Menus.js - About 1 hr to fix

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

                Menu.prototype.addSubMenu = function (name, id, position, relativeID) {
            
                    if (!name || !id) {
                        console.error("addSubMenu(): missing required parameters: name and id");
                        return null;
            Severity: Minor
            Found in src/command/Menus.js - About 1 hr to fix

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

                  Menu.prototype.removeMenuDivider = function (menuItemID) {
                      var menuItem,
                          $HTMLMenuItem;
              
                      if (!menuItemID) {
              Severity: Minor
              Found in src/command/Menus.js - About 1 hr to fix

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

                    Menu.prototype.removeSubMenu = function (subMenuID) {
                        var subMenu,
                            parentMenuItem,
                            commandID = "";
                
                
                Severity: Minor
                Found in src/command/Menus.js - About 1 hr to fix

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

                      function removeMenu(id) {
                          var menu,
                              commandID = "";
                  
                          if (!id) {
                  Severity: Minor
                  Found in src/command/Menus.js - About 1 hr to fix

                    Function removeMenuItem has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        Menu.prototype.removeMenuItem = function (command) {
                            var menuItemID,
                                commandID;
                    
                            if (!command) {
                    Severity: Minor
                    Found in src/command/Menus.js - About 1 hr to fix

                      Avoid too many return statements within this function.
                      Open

                              return menuItem;
                      Severity: Major
                      Found in src/command/Menus.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return null;
                        Severity: Major
                        Found in src/command/Menus.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return;
                          Severity: Major
                          Found in src/command/Menus.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return $relativeElement;
                            Severity: Major
                            Found in src/command/Menus.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                          return $relativeElement;
                              Severity: Major
                              Found in src/command/Menus.js - About 30 mins to fix

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

                                        _.forEach(menuItemMap, function (value, key) {
                                            if (_.startsWith(key, subMenuID)) {
                                                if (value.isDivider) {
                                                    subMenu.removeMenuDivider(key);
                                                } else {
                                Severity: Major
                                Found in src/command/Menus.js and 1 other location - About 2 hrs to fix
                                src/command/Menus.js on lines 1130..1139

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

                                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

                                        _.forEach(menuItemMap, function (value, key) {
                                            if (_.startsWith(key, id)) {
                                                if (value.isDivider) {
                                                    menu.removeMenuDivider(key);
                                                } else {
                                Severity: Major
                                Found in src/command/Menus.js and 1 other location - About 2 hrs to fix
                                src/command/Menus.js on lines 871..880

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

                                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 elementRect = {
                                                top:    posTop,
                                                left:   posLeft,
                                                height: $menuWindow.height() + 25,
                                                width:  $menuWindow.width()
                                Severity: Major
                                Found in src/command/Menus.js and 1 other location - About 1 hr to fix
                                src/command/Menus.js on lines 1273..1279

                                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

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

                                            var elementRect = {
                                                top:    posTop,
                                                left:   posLeft,
                                                height: $menuWindow.height() + 25,
                                                width:  $menuWindow.width()
                                Severity: Major
                                Found in src/command/Menus.js and 1 other location - About 1 hr to fix
                                src/command/Menus.js on lines 1246..1252

                                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 (_isHTMLMenu(this.id)) {
                                            // Targeting parent to get the menu item <a> and the <li> that contains it
                                            $(_getHTMLMenuItem(menuItemID)).parent().remove();
                                        } else {
                                            brackets.app.removeMenuItem(commandID, function (err) {
                                Severity: Major
                                Found in src/command/Menus.js and 1 other location - About 1 hr to fix
                                src/command/Menus.js on lines 1141..1149

                                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 (_isHTMLMenu(id)) {
                                            $(_getHTMLMenu(id)).remove();
                                        } else {
                                            brackets.app.removeMenu(id, function (err) {
                                                if (err) {
                                Severity: Major
                                Found in src/command/Menus.js and 1 other location - About 1 hr to fix
                                src/command/Menus.js on lines 470..479

                                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

                                    Menu.prototype.closeSubMenu = function() {
                                        if (this.openSubMenu) {
                                            this.openSubMenu.close();
                                            this.openSubMenu = null;
                                        }
                                Severity: Major
                                Found in src/command/Menus.js and 1 other location - About 1 hr to fix
                                src/search/QuickSearchField.js on lines 244..249

                                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

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

                                            brackets.app.setMenuItemState(this._command.getID(), enabled, checked, function (err) {
                                                if (err) {
                                                    console.log("Error setting menu item state: " + err);
                                                }
                                            });
                                Severity: Major
                                Found in src/command/Menus.js and 1 other location - About 1 hr to fix
                                src/command/Menus.js on lines 957..961

                                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

                                            brackets.app.setMenuItemState(this._command.getID(), enabled, checked, function (err) {
                                                if (err) {
                                                    console.log("Error setting menu item state: " + err);
                                                }
                                            });
                                Severity: Major
                                Found in src/command/Menus.js and 1 other location - About 1 hr to fix
                                src/command/Menus.js on lines 940..944

                                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

                                            if (clip.bottom > 0) {
                                                posTop = Math.max(0, posTop + $parentMenuItem.height() - $menuWindow.height());
                                            }
                                Severity: Minor
                                Found in src/command/Menus.js and 1 other location - About 55 mins to fix
                                src/command/Menus.js on lines 1261..1263

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

                                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 (clip.right > 0) {
                                                posLeft = Math.max(0, posLeft - $parentMenuItem.outerWidth() - $menuWindow.outerWidth());
                                            }
                                Severity: Minor
                                Found in src/command/Menus.js and 1 other location - About 55 mins to fix
                                src/command/Menus.js on lines 1254..1256

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

                                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