adobe/brackets

View on GitHub
src/document/DocumentCommandHandlers.js

Summary

Maintainability
F
1 wk
Test Coverage

File DocumentCommandHandlers.js has 1116 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/document/DocumentCommandHandlers.js - About 2 days to fix

    Function _doSaveAs has 107 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function _doSaveAs(doc, settings) {
            var origPath,
                saveAsDefaultPath,
                defaultName,
                result = new $.Deferred();
    Severity: Major
    Found in src/document/DocumentCommandHandlers.js - About 4 hrs to fix

      Function handleFileClose has 87 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function handleFileClose(commandData) {
              var file,
                  promptOnly,
                  _forceClose,
                  _spawnedRequest,
      Severity: Major
      Found in src/document/DocumentCommandHandlers.js - About 3 hrs to fix

        Function doSave has 77 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function doSave(docToSave, force) {
                var result = new $.Deferred(),
                    file = docToSave.file;
        
                function handleError(error) {
        Severity: Major
        Found in src/document/DocumentCommandHandlers.js - About 3 hrs to fix

          Function _closeList has 63 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function _closeList(list, promptOnly, _forceClose) {
                  var result      = new $.Deferred(),
                      unsavedDocs = [];
          
                  list.forEach(function (file) {
          Severity: Major
          Found in src/document/DocumentCommandHandlers.js - About 2 hrs to fix

            Function _doSaveAfterSaveDialog has 63 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    function _doSaveAfterSaveDialog(path) {
                        var newFile;
            
                        // Reconstruct old doc's editor's view state, & finally resolve overall promise
                        function _configureEditorAndResolve() {
            Severity: Major
            Found in src/document/DocumentCommandHandlers.js - About 2 hrs to fix

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

                  function _doOpen(fullPath, silent, paneId, options) {
                      var result = new $.Deferred();
              
                      // workaround for https://github.com/adobe/brackets/issues/6001
                      // TODO should be removed once bug is closed.
              Severity: Major
              Found in src/document/DocumentCommandHandlers.js - About 2 hrs to fix

                Function _updateTitle has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function _updateTitle() {
                        var currentDoc          = DocumentManager.getCurrentDocument(),
                            windowTitle         = brackets.config.app_title,
                            currentlyViewedFile = MainViewManager.getCurrentlyViewedFile(MainViewManager.ACTIVE_PANE),
                            currentlyViewedPath = currentlyViewedFile && currentlyViewedFile.fullPath,
                Severity: Minor
                Found in src/document/DocumentCommandHandlers.js - About 1 hr to fix

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

                          function handleContentsModified() {
                              Dialogs.showModalDialog(
                                  DefaultDialogs.DIALOG_ID_ERROR,
                                  Strings.EXT_MODIFIED_TITLE,
                                  StringUtils.format(
                  Severity: Minor
                  Found in src/document/DocumentCommandHandlers.js - About 1 hr to fix

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

                        function _doOpenWithOptionalPath(fullPath, silent, paneId, options) {
                            var result;
                            paneId = paneId || MainViewManager.ACTIVE_PANE;
                            if (!fullPath) {
                                // Create placeholder deferred
                    Severity: Minor
                    Found in src/document/DocumentCommandHandlers.js - About 1 hr to fix

                      Function _disableCache has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function _disableCache() {
                              var result = new $.Deferred();
                      
                              if (brackets.inBrowser) {
                                  result.resolve();
                      Severity: Minor
                      Found in src/document/DocumentCommandHandlers.js - About 1 hr to fix

                        Function _saveFileList has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            function _saveFileList(fileList) {
                                // Do in serial because doSave shows error UI for each file, and we don't want to stack
                                // multiple dialogs on top of each other
                                var userCanceled = false,
                                    filesAfterSave = [];
                        Severity: Minor
                        Found in src/document/DocumentCommandHandlers.js - About 1 hr to fix

                          Function handleFileDelete has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              function handleFileDelete() {
                                  var entry = ProjectManager.getSelectedItem();
                                  Dialogs.showModalDialog(
                                      DefaultDialogs.DIALOG_ID_EXT_DELETED,
                                      Strings.CONFIRM_DELETE_TITLE,
                          Severity: Minor
                          Found in src/document/DocumentCommandHandlers.js - About 1 hr to fix

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

                                            [
                                                {
                                                    className : Dialogs.DIALOG_BTN_CLASS_LEFT,
                                                    id        : Dialogs.DIALOG_BTN_DONTSAVE,
                                                    text      : Strings.DONT_SAVE
                            Severity: Major
                            Found in src/document/DocumentCommandHandlers.js and 2 other locations - About 2 hrs to fix
                            src/document/DocumentCommandHandlers.js on lines 763..779
                            src/document/DocumentCommandHandlers.js on lines 1231..1247

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

                            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

                                            [
                                                {
                                                    className : Dialogs.DIALOG_BTN_CLASS_LEFT,
                                                    id        : Dialogs.DIALOG_BTN_DONTSAVE,
                                                    text      : Strings.DONT_SAVE
                            Severity: Major
                            Found in src/document/DocumentCommandHandlers.js and 2 other locations - About 2 hrs to fix
                            src/document/DocumentCommandHandlers.js on lines 763..779
                            src/document/DocumentCommandHandlers.js on lines 1337..1353

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

                            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

                                            [
                                                {
                                                    className : Dialogs.DIALOG_BTN_CLASS_LEFT,
                                                    id        : Dialogs.DIALOG_BTN_SAVE_AS,
                                                    text      : Strings.SAVE_AS
                            Severity: Major
                            Found in src/document/DocumentCommandHandlers.js and 2 other locations - About 2 hrs to fix
                            src/document/DocumentCommandHandlers.js on lines 1231..1247
                            src/document/DocumentCommandHandlers.js on lines 1337..1353

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

                            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

                                    handleFileOpen(commandData)
                                        .done(function (file) {
                                            // if we succeeded with an open file
                                            //  then we need to resolve that to a document.
                                            //  getOpenDocumentForPath will return null if there isn't a
                            Severity: Major
                            Found in src/document/DocumentCommandHandlers.js and 1 other location - About 2 hrs to fix
                            src/document/DocumentCommandHandlers.js on lines 580..591

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

                            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

                                    handleFileAddToWorkingSetAndOpen(commandData)
                                        .done(function (file) {
                                            // if we succeeded with an open file
                                            //  then we need to resolve that to a document.
                                            //  getOpenDocumentForPath will return null if there isn't a
                            Severity: Major
                            Found in src/document/DocumentCommandHandlers.js and 1 other location - About 2 hrs to fix
                            src/document/DocumentCommandHandlers.js on lines 527..538

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

                            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

                                function showFileOpenError(name, path) {
                                    return Dialogs.showModalDialog(
                                        DefaultDialogs.DIALOG_ID_ERROR,
                                        Strings.ERROR_OPENING_FILE_TITLE,
                                        StringUtils.format(
                            Severity: Major
                            Found in src/document/DocumentCommandHandlers.js and 1 other location - About 1 hr to fix
                            src/document/DocumentCommandHandlers.js on lines 725..735

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

                            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

                                function _showSaveFileError(name, path) {
                                    return Dialogs.showModalDialog(
                                        DefaultDialogs.DIALOG_ID_ERROR,
                                        Strings.ERROR_SAVING_FILE_TITLE,
                                        StringUtils.format(
                            Severity: Major
                            Found in src/document/DocumentCommandHandlers.js and 1 other location - About 1 hr to fix
                            src/document/DocumentCommandHandlers.js on lines 272..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 65.

                            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 4 locations. Consider refactoring.
                            Open

                                            var projectRoot = ProjectManager.getProjectRoot(),
                                                context = {
                                                    location : {
                                                        scope: "user",
                                                        layer: "project",
                            Severity: Major
                            Found in src/document/DocumentCommandHandlers.js and 3 other locations - About 30 mins to fix
                            src/document/DocumentCommandHandlers.js on lines 948..955
                            src/document/DocumentManager.js on lines 503..510
                            src/editor/EditorStatusBar.js on lines 542..549

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

                            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 4 locations. Consider refactoring.
                            Open

                                            var projectRoot = ProjectManager.getProjectRoot(),
                                                context = {
                                                    location : {
                                                        scope: "user",
                                                        layer: "project",
                            Severity: Major
                            Found in src/document/DocumentCommandHandlers.js and 3 other locations - About 30 mins to fix
                            src/document/DocumentCommandHandlers.js on lines 338..345
                            src/document/DocumentManager.js on lines 503..510
                            src/editor/EditorStatusBar.js on lines 542..549

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

                            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