adobe/brackets

View on GitHub
src/editor/Editor.js

Summary

Maintainability
F
1 wk
Test Coverage

File Editor.js has 1458 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/editor/Editor.js - About 3 days to fix

    Function Editor has 126 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function Editor(document, makeMasterEditor, container, range, options) {
            var self = this;
    
            var isReadOnly = (options && options.isReadOnly) || !document.editable;
    
    
    Severity: Major
    Found in src/editor/Editor.js - About 5 hrs to fix

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

          Editor.prototype.displayErrorMessageAtCursor = function (errorMsg) {
              var arrowBelow, cursorPos, cursorCoord, popoverRect,
                  top, left, clip, arrowCenter, arrowLeft,
                  self = this,
                  POPOVER_MARGIN = 10,
      Severity: Major
      Found in src/editor/Editor.js - About 3 hrs to fix

        Function _installEditorListeners has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            Editor.prototype._installEditorListeners = function () {
                var self = this;
        
                // Redispatch these CodeMirror key events as Editor events
                function _onKeyEvent(instance, event) {
        Severity: Major
        Found in src/editor/Editor.js - About 2 hrs to fix

          Function _handleSoftTabNavigation has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              Editor.prototype._handleSoftTabNavigation = function (direction, functionName) {
                  var instance = this._codeMirror,
                      overallJump = null;
          
                  if (!instance.getOption("indentWithTabs") && PreferencesManager.get(SOFT_TABS)) {
          Severity: Minor
          Found in src/editor/Editor.js - About 1 hr to fix

            Function setInlineWidgetHeight has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                Editor.prototype.setInlineWidgetHeight = function (inlineWidget, height, ensureVisible) {
                    var self = this,
                        node = inlineWidget.htmlContent,
                        oldHeight = (node && $(node).height()) || 0,
                        changed = (oldHeight !== height),
            Severity: Minor
            Found in src/editor/Editor.js - About 1 hr to fix

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

                  Editor.prototype.getModeForSelection = function () {
                      // Check for mixed mode info
                      var self        = this,
                          sels        = this.getSelections(),
                          primarySel  = this.getSelection(),
              Severity: Minor
              Found in src/editor/Editor.js - About 1 hr to fix

                Function _updateOption has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    Editor.prototype._updateOption = function (prefName) {
                        var oldValue = this._currentOptions[prefName],
                            newValue = this._getOption(prefName);
                
                        if (oldValue !== newValue) {
                Severity: Minor
                Found in src/editor/Editor.js - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                              if (endInclusive) {
                                  return (start.line < pos.line || start.ch <= pos.ch) &&  // inclusive
                                      (end.line > pos.line   || end.ch >= pos.ch);      // inclusive
                              } else {
                                  return (start.line < pos.line || start.ch <= pos.ch) &&  // inclusive
                  Severity: Major
                  Found in src/editor/Editor.js - About 1 hr to fix

                    Function Editor has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        function Editor(document, makeMasterEditor, container, range, options) {
                    Severity: Minor
                    Found in src/editor/Editor.js - About 35 mins to fix

                      Function setSelection has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          Editor.prototype.setSelection = function (start, end, center, centerOptions, origin) {
                      Severity: Minor
                      Found in src/editor/Editor.js - About 35 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return this._codeMirror.getOption("mode");
                        Severity: Major
                        Found in src/editor/Editor.js - About 30 mins to fix

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

                                      if (result.start.line === primarySel.start.line && result.start.ch === primarySel.start.ch &&
                                              result.end.line === primarySel.end.line && result.end.ch === primarySel.end.ch) {
                          Severity: Major
                          Found in src/editor/Editor.js and 1 other location - About 2 hrs to fix
                          src/extensions/default/CodeFolding/main.js on lines 99..100

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

                          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

                                  for (i = 0; i < line.length; i++) {
                                      if (line[i] === '\t') {
                                          if (tabSize === null) {
                                              tabSize = Editor.getTabSize();
                                          }
                          Severity: Major
                          Found in src/editor/Editor.js and 1 other location - About 2 hrs to fix
                          src/editor/Editor.js on lines 1190..1201

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

                          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

                                  for (i = 0; iCol < column; i++) {
                                      if (line[i] === '\t') {
                                          if (tabSize === null) {
                                              tabSize = Editor.getTabSize();
                                          }
                          Severity: Major
                          Found in src/editor/Editor.js and 1 other location - About 2 hrs to fix
                          src/editor/Editor.js on lines 1162..1173

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

                          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

                                      } else {
                                          return (start.line < pos.line || start.ch <= pos.ch) &&  // inclusive
                                              (end.line > pos.line   || end.ch > pos.ch);       // exclusive
                                      }
                          Severity: Major
                          Found in src/editor/Editor.js and 1 other location - About 1 hr to fix
                          src/editor/Editor.js on lines 1297..1300

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

                          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 (endInclusive) {
                                          return (start.line < pos.line || start.ch <= pos.ch) &&  // inclusive
                                              (end.line > pos.line   || end.ch >= pos.ch);      // inclusive
                                      } else {
                          Severity: Major
                          Found in src/editor/Editor.js and 1 other location - About 1 hr to fix
                          src/editor/Editor.js on lines 1300..1303

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

                          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.left > 0) {
                                      left += clip.left;
                                  } else if (clip.right > 0) {
                                      left -= clip.right;
                                  }
                          Severity: Major
                          Found in src/editor/Editor.js and 1 other location - About 1 hr to fix
                          src/extensions/default/QuickView/main.js on lines 140..144

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

                              Editor.setWordWrap = function (value, fullPath) {
                                  var options = fullPath && {context: fullPath};
                                  return PreferencesManager.set(WORD_WRAP, value, options);
                              };
                          Severity: Major
                          Found in src/editor/Editor.js and 5 other locations - About 50 mins to fix
                          src/editor/Editor.js on lines 2600..2603
                          src/editor/Editor.js on lines 2621..2624
                          src/editor/Editor.js on lines 2642..2645
                          src/editor/Editor.js on lines 2663..2666
                          src/editor/Editor.js on lines 2725..2728

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

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

                              Editor.setSpaceUnits = function (value, fullPath) {
                                  var options = fullPath && {context: fullPath};
                                  return PreferencesManager.set(SPACE_UNITS, value, options);
                              };
                          Severity: Major
                          Found in src/editor/Editor.js and 5 other locations - About 50 mins to fix
                          src/editor/Editor.js on lines 2600..2603
                          src/editor/Editor.js on lines 2642..2645
                          src/editor/Editor.js on lines 2663..2666
                          src/editor/Editor.js on lines 2704..2707
                          src/editor/Editor.js on lines 2725..2728

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

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

                              Editor.setCloseBrackets = function (value, fullPath) {
                                  var options = fullPath && {context: fullPath};
                                  return PreferencesManager.set(CLOSE_BRACKETS, value, options);
                              };
                          Severity: Major
                          Found in src/editor/Editor.js and 5 other locations - About 50 mins to fix
                          src/editor/Editor.js on lines 2600..2603
                          src/editor/Editor.js on lines 2621..2624
                          src/editor/Editor.js on lines 2663..2666
                          src/editor/Editor.js on lines 2704..2707
                          src/editor/Editor.js on lines 2725..2728

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

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

                              Editor.setShowLineNumbers = function (value, fullPath) {
                                  var options = fullPath && {context: fullPath};
                                  return PreferencesManager.set(SHOW_LINE_NUMBERS, value, options);
                              };
                          Severity: Major
                          Found in src/editor/Editor.js and 5 other locations - About 50 mins to fix
                          src/editor/Editor.js on lines 2600..2603
                          src/editor/Editor.js on lines 2621..2624
                          src/editor/Editor.js on lines 2642..2645
                          src/editor/Editor.js on lines 2704..2707
                          src/editor/Editor.js on lines 2725..2728

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

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

                              Editor.setTabSize = function (value, fullPath) {
                                  var options = fullPath && {context: fullPath};
                                  return PreferencesManager.set(TAB_SIZE, value, options);
                              };
                          Severity: Major
                          Found in src/editor/Editor.js and 5 other locations - About 50 mins to fix
                          src/editor/Editor.js on lines 2621..2624
                          src/editor/Editor.js on lines 2642..2645
                          src/editor/Editor.js on lines 2663..2666
                          src/editor/Editor.js on lines 2704..2707
                          src/editor/Editor.js on lines 2725..2728

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

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

                              Editor.setIndentLineComment = function (value, fullPath) {
                                  var options = fullPath && {context: fullPath};
                                  return PreferencesManager.set(INDENT_LINE_COMMENT, value, options);
                              };
                          Severity: Major
                          Found in src/editor/Editor.js and 5 other locations - About 50 mins to fix
                          src/editor/Editor.js on lines 2600..2603
                          src/editor/Editor.js on lines 2621..2624
                          src/editor/Editor.js on lines 2642..2645
                          src/editor/Editor.js on lines 2663..2666
                          src/editor/Editor.js on lines 2704..2707

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

                          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 (CodeMirror.cmpPos(sel.start, newSel.start) !== 0 ||
                                                  CodeMirror.cmpPos(sel.end, newSel.end) !== 0 ||
                          Severity: Minor
                          Found in src/editor/Editor.js and 1 other location - About 35 mins to fix
                          src/search/FindReplace.js on lines 264..264

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

                          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