puffer/puffer_pages

View on GitHub

Showing 177 of 219 total issues

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

  function highlightLine(cm, line, state) {
    // A styles array always starts with a number identifying the
    // mode/overlays that it is based on (for easy invalidation).
    var st = [cm.view.modeGen];
    // Compute the base array of styles
Severity: Minor
Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

    Function addChange has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      function addChange(cm, start, added, old, origin, fromBefore, toBefore, fromAfter, toAfter) {
    Severity: Major
    Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

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

        function CodeMirror(place, options) {
          if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
          
          this.options = options = options || {};
          // Determine effective options based on given values and defaults.
      Severity: Minor
      Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

        Method read_template_file has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def read_template_file template_path, context
                source = case template_type(template_path)
                when :snippet then
                  template_path = template_path.gsub(/^snippets\//, '')
                  snippet = snippet(template_path)
        Severity: Minor
        Found in lib/puffer_pages/liquid/file_system.rb - About 1 hr to fix

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

              addWidget: function(pos, node, scroll, vert, horiz) {
                var display = this.display;
                pos = cursorCoords(this, clipPos(this.view.doc, pos));
                var top = pos.top, left = pos.left;
                node.style.position = "absolute";
          Severity: Minor
          Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

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

              function findMatchingBracket(cm) {
                var cur = cm.getCursor(), line = cm.getLineHandle(cur.line), pos = cur.ch - 1;
                var match = (pos >= 0 && matching[line.text.charAt(pos)]) || matching[line.text.charAt(++pos)];
                if (!match) return null;
                var forward = match.charAt(1) == ">", d = forward ? 1 : -1;
            Severity: Minor
            Found in app/assets/javascripts/puffer/matchbrackets.js - About 1 hr to fix

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

                select: function() {
                  if (this.dogPiling(arguments)) { return this; }
              
                  var result  = old_select.apply(this, arguments);
                  var url     = R(this.link.get('href'));
              Severity: Minor
              Found in app/assets/javascripts/puffer/right-tabs-src.js - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                    if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) && !posEq(sel.from, sel.to) &&
                        !posLess(start, sel.from) && !posLess(sel.to, start) && type == "single") {
                      var dragEnd = operation(cm, function(e2) {
                        if (webkit) display.scroller.draggable = false;
                        view.draggingText = false;
                Severity: Major
                Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

                  Method expires_in has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                          def expires_in expiration
                            fragments = expiration.to_s.split(' ').map(&:strip)
                            times = fragments.map do |fragment|
                              TIME_FORMATS.inject(nil) do |result, (format, multiplier)|
                                break result if result
                  Severity: Minor
                  Found in lib/puffer_pages/liquid/tags/cache.rb - About 55 mins to fix

                  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 updateDoc has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    function updateDoc(cm, from, to, newText, selUpdate, origin) {
                  Severity: Minor
                  Found in app/assets/javascripts/puffer/codemirror.js - About 45 mins to fix

                    Function updateDocNoUndo has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      function updateDocNoUndo(cm, from, to, lines, selUpdate, origin) {
                    Severity: Minor
                    Found in app/assets/javascripts/puffer/codemirror.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                  if (posEq(newPos, curPos)) {
                                    newPos.ch += dir;
                                    if (newPos.ch < 0) {
                                      if (newPos.line) newPos = clipPos(doc, {line: newPos.line - 1});
                                      else newPos = null;
                      Severity: Major
                      Found in app/assets/javascripts/puffer/codemirror.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                    if (m.className) spanStyle += " " + m.className;
                        Severity: Major
                        Found in app/assets/javascripts/puffer/codemirror.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                        if (pos < j) order.splice(at, 0, {from: pos, to: j, level: 1});
                          Severity: Major
                          Found in app/assets/javascripts/puffer/codemirror.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                        if (sameLine) (first || (first = [])).push(span);
                            Severity: Major
                            Found in app/assets/javascripts/puffer/codemirror.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                          if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle;
                              Severity: Major
                              Found in app/assets/javascripts/puffer/codemirror.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                            if (mayClear && m.clearOnEnter) {
                                              (toClear || (toClear = [])).push(m);
                                              continue;
                                            } else if (!m.atomic) continue;
                                Severity: Major
                                Found in app/assets/javascripts/puffer/codemirror.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                              if (sp.to != null && nextChange > sp.to) { nextChange = sp.to; spanEndStyle = ""; }
                                  Severity: Major
                                  Found in app/assets/javascripts/puffer/codemirror.js - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                            if (widgets) for (var i = 0; i < widgets.length; ++i)
                                              widgets[i].height = widgets[i].node.offsetHeight;
                                    Severity: Major
                                    Found in app/assets/javascripts/puffer/codemirror.js - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                  if (prev.nodeType == "pre") {
                                                    var wrap = elt("div", null, null, "position: relative");
                                                    prev.parentNode.replaceChild(wrap, prev);
                                                    wrap.appendChild(prev);
                                                    prev = wrap;
                                      Severity: Major
                                      Found in app/assets/javascripts/puffer/codemirror.js - About 45 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language