CartoDB/cartodb20

View on GitHub
lib/assets/javascripts/builder/components/code-mirror/show-hint.code-mirror.js

Summary

Maintainability
F
1 wk
Test Coverage

Function exports has a Cognitive Complexity of 187 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function (CodeMirror) {
  "use strict";

  var HINT_ELEMENT_CLASS        = "CodeMirror-hint";
  var ACTIVE_HINT_ELEMENT_CLASS = "CodeMirror-hint-active";

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function exports has 387 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function (CodeMirror) {
  "use strict";

  var HINT_ELEMENT_CLASS        = "CodeMirror-hint";
  var ACTIVE_HINT_ELEMENT_CLASS = "CodeMirror-hint-active";

    File show-hint.code-mirror.js has 390 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // CodeMirror, copyright (c) by Marijn Haverbeke and others
    // Distributed under an MIT license: http://codemirror.net/LICENSE
    
    /* eslint-disable */
    module.exports = function (CodeMirror) {

      Function Widget has 93 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function Widget(completion, data) {
          this.completion = completion;
          this.data = data;
          this.picked = false;
          var widget = this, cm = completion.cm;

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

          function buildKeyMap(completion, handle) {
            var baseMap = {
              Up: function() {handle.moveFocus(-1);},
              Down: function() {handle.moveFocus(1);},
              PageUp: function() {handle.moveFocus(-handle.menuSize() + 1, true);},

          Consider simplifying this complex logical expression.
          Open

                if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch ||
                    pos.ch < this.startPos.ch || this.cm.somethingSelected() ||
                    (pos.ch && this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) {
                  this.close();
                } else {

            There are no issues that match your filters.

            Category
            Status