kuasha/cosmos

View on GitHub
samples/adminpanel/app/bower_components/ace-builds/src/ext-language_tools.js

Summary

Maintainability
F
4 mos
Test Coverage

File ext-language_tools.js has 1629 lines of code (exceeds 250 allowed). Consider refactoring.
Open

define("ace/snippets",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/anchor","ace/keyboard/hash_handler","ace/tokenizer","ace/lib/dom","ace/editor"], function(require, exports, module) {
"use strict";
var oop = require("./lib/oop");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var lang = require("./lib/lang");

    Function AcePopup has 201 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var AcePopup = function(parentNode) {
        var el = dom.createElement("div");
        var popup = new $singleLineEditor(el);
    
        if (parentNode)

      Function insertSnippetForSelection has 97 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          this.insertSnippetForSelection = function(editor, snippetText) {
              var cursor = editor.getCursorPosition();
              var line = editor.session.getLine(cursor.row);
              var tabString = editor.session.getTabString();
              var indentString = line.match(/^\s*/)[0];

        Function getTokenizer has 82 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            this.getTokenizer = function() {
                function TabstopToken(str, _, stack) {
                    str = str.substr(1);
                    if (/^\d+$/.test(str) && !stack.inFormatString)
                        return [{tabstopId: parseInt(str, 10)}];

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

              this.register = function(snippets, scope) {
                  var snippetMap = this.snippetMap;
                  var snippetNameMap = this.snippetNameMap;
                  var self = this;
                  function wrapRegexp(src) {

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

                this.addTabstops = function(tabstops, start, end) {
                    if (!this.$openTabstops)
                        this.$openTabstops = [];
                    if (!tabstops[0]) {
                        var p = Range.fromPoints(end, end);

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

                  this.onChange = function(e) {
                      var changeRange = e.data.range;
                      var isRemove = e.data.action[0] == "r";
                      var start = changeRange.start;
                      var end = changeRange.end;

                Function resolveVariables has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    this.resolveVariables = function(snippet, editor) {
                        var result = [];
                        for (var i = 0; i < snippet.length; i++) {
                            var ch = snippet[i];
                            if (typeof ch == "string") {

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

                      this.updateCompletions = function(keepPopupPosition) {
                          if (keepPopupPosition && this.base && this.completions) {
                              var pos = this.editor.getCursorPosition();
                              var prefix = this.editor.session.getTextRange({start: this.base, end: pos});
                              if (prefix == this.completions.filterText)

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

                        this.tmStrFormat = function(str, ch, editor) {
                            var flag = ch.flag || "";
                            var re = ch.guard;
                            re = new RegExp(re, flag.replace(/[^gi]/, ""));
                            var fmtTokens = this.tokenizeTmSnippet(ch.fmt, "formatString");

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

                          this.$getDefaultValue = function(editor, name) {
                              if (/^[A-Z]\d+$/.test(name)) {
                                  var i = name.substr(1);
                                  return (this.variables[name[0] + "__"] || {})[i];
                              }

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

                            this.filterCompletions = function(items, needle) {
                                var results = [];
                                var upper = needle.toUpperCase();
                                var lower = needle.toLowerCase();
                                loop: for (var i = 0, item; item = items[i]; i++) {

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

                              this.parseSnippetFile = function(str) {
                                  str = str.replace(/\r/g, "");
                                  var list = [], snippet = {};
                                  var re = /^#.*|^({[\s\S]*})\s*$|^(\S+) (.*)$|^((?:\n*\t.*)+)/gm;
                                  var m;

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

                                bgTokenizer.$tokenizeRow = function(i) {
                                    var data = popup.data[i];
                                    var tokens = [];
                                    if (!data)
                                        return tokens;

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

                                      var formatted = str.replace(re, function() {
                                          _self.variables.__ = arguments;
                                          var fmtParts = _self.resolveVariables(fmtTokens, editor);
                                          var gChangeCase = "E";
                                          for (var i  = 0; i < fmtParts.length; i++) {

                                Avoid deeply nested control flow statements.
                                Open

                                                            if (ch.changeCase == "u")
                                                                fmtParts[i] = next[0].toUpperCase();
                                                            else
                                                                fmtParts[i] = next[0].toLowerCase();

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

                                      exports.getCompletions = function(editor, session, pos, prefix, callback) {

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

                                        getCompletions: function(editor, session, pos, prefix, callback) {

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

                                          getCompletions: function(editor, session, pos, prefix, callback) {

                                        Avoid too many return statements within this function.
                                        Open

                                                        return this.insertMatch(filtered[0]);

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

                                          define("ace/snippets",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/anchor","ace/keyboard/hash_handler","ace/tokenizer","ace/lib/dom","ace/editor"], function(require, exports, module) {
                                          "use strict";
                                          var oop = require("./lib/oop");
                                          var EventEmitter = require("./lib/event_emitter").EventEmitter;
                                          var lang = require("./lib/lang");
                                          samples/adminpanel/app/bower_components/ace-builds/demo/kitchen-sink/demo.js on lines 4233..5130
                                          samples/adminpanel/app/bower_components/ace-builds/src/ext-emmet.js on lines 1..898
                                          samples/adminpanel/app/bower_components/ace-builds/src/mode-jsoniq.js on lines 2715..3612
                                          samples/adminpanel/app/bower_components/ace-builds/src/mode-xquery.js on lines 2749..3646

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

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

                                          define("ace/autocomplete",["require","exports","module","ace/keyboard/hash_handler","ace/autocomplete/popup","ace/autocomplete/util","ace/lib/event","ace/lib/lang","ace/snippets"], function(require, exports, module) {
                                          "use strict";
                                          
                                          var HashHandler = require("./keyboard/hash_handler").HashHandler;
                                          var AcePopup = require("./autocomplete/popup").AcePopup;
                                          samples/adminpanel/app/bower_components/ace-builds/demo/kitchen-sink/demo.js on lines 5746..6092
                                          samples/adminpanel/app/bower_components/ace-builds/src/mode-jsoniq.js on lines 3963..4309
                                          samples/adminpanel/app/bower_components/ace-builds/src/mode-xquery.js on lines 3997..4343

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

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

                                          define("ace/autocomplete/popup",["require","exports","module","ace/edit_session","ace/virtual_renderer","ace/editor","ace/range","ace/lib/event","ace/lib/lang","ace/lib/dom"], function(require, exports, module) {
                                          "use strict";
                                          
                                          var EditSession = require("../edit_session").EditSession;
                                          var Renderer = require("../virtual_renderer").VirtualRenderer;
                                          samples/adminpanel/app/bower_components/ace-builds/demo/kitchen-sink/demo.js on lines 5397..5699
                                          samples/adminpanel/app/bower_components/ace-builds/src/mode-jsoniq.js on lines 3614..3916
                                          samples/adminpanel/app/bower_components/ace-builds/src/mode-xquery.js on lines 3648..3950

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

                                          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

                                          define("ace/ext/language_tools",["require","exports","module","ace/snippets","ace/autocomplete","ace/config","ace/autocomplete/util","ace/autocomplete/text_completer","ace/editor","ace/config"], function(require, exports, module) {
                                          "use strict";
                                          
                                          var snippetManager = require("../snippets").snippetManager;
                                          var Autocomplete = require("../autocomplete").Autocomplete;
                                          samples/adminpanel/app/bower_components/ace-builds/demo/kitchen-sink/demo.js on lines 6138..6305
                                          samples/adminpanel/app/bower_components/ace-builds/src/mode-jsoniq.js on lines 4355..4522
                                          samples/adminpanel/app/bower_components/ace-builds/src/mode-xquery.js on lines 4389..4556

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

                                          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

                                          define("ace/autocomplete/text_completer",["require","exports","module","ace/range"], function(require, exports, module) {
                                              var Range = require("../range").Range;
                                              
                                              var splitRegex = /[^a-zA-Z_0-9\$\-\u00C0-\u1FFF\u2C00-\uD7FF\w]+/;
                                          
                                          
                                          samples/adminpanel/app/bower_components/ace-builds/demo/kitchen-sink/demo.js on lines 6094..6136
                                          samples/adminpanel/app/bower_components/ace-builds/src/mode-jsoniq.js on lines 4311..4353
                                          samples/adminpanel/app/bower_components/ace-builds/src/mode-xquery.js on lines 4345..4387

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

                                          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

                                          define("ace/autocomplete/util",["require","exports","module"], function(require, exports, module) {
                                          "use strict";
                                          
                                          exports.parForEach = function(array, fn, callback) {
                                              var completed = 0;
                                          samples/adminpanel/app/bower_components/ace-builds/demo/kitchen-sink/demo.js on lines 5701..5744
                                          samples/adminpanel/app/bower_components/ace-builds/src/mode-jsoniq.js on lines 3918..3961
                                          samples/adminpanel/app/bower_components/ace-builds/src/mode-xquery.js on lines 3952..3995

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

                                          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