puffer/puffer_pages

View on GitHub

Showing 177 of 219 total issues

Function updateSelectionRange has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function updateSelectionRange(cm) {
    var display = cm.display, doc = cm.view.doc, sel = cm.view.sel;
    var fragment = document.createDocumentFragment();
    var clientWidth = display.lineSpace.offsetWidth, pl = paddingLeft(cm.display);

Severity: Major
Found in app/assets/javascripts/puffer/codemirror.js - About 2 hrs to fix

    Method read_template_file has a Cognitive Complexity of 18 (exceeds 5 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 2 hrs 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 tokenBase has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function tokenBase(stream, state) {
        var ch = stream.next();
        if (ch == "@") {stream.eatWhile(/[\w\\\-]/); return ret("def", stream.current());}
        else if (ch == "/" && stream.eat("*")) {
          state.tokenize = tokenCComment;
    Severity: Major
    Found in app/assets/javascripts/puffer/codemirror/css.js - About 2 hrs to fix

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

        function insertLineContent(line, builder, styles) {
          var spans = line.markedSpans;
          if (!spans) {
            for (var i = 1; i < styles.length; i+=2)
              builder.addToken(builder, styles[i], styleToClass(styles[i+1]));
      Severity: Major
      Found in app/assets/javascripts/puffer/codemirror.js - About 2 hrs to fix

        Function token has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                token: function(stream, state) {
                    var ch = stream.peek();
                    var esc = state.escaped;
                    state.escaped = false;
                    /* comments */
        Severity: Major
        Found in app/assets/javascripts/puffer/codemirror/yaml.js - About 2 hrs to fix

          Function inText has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function inText(stream, state) {
              function chain(parser) {
                state.tokenize = parser;
                return parser(stream, state);
              }
          Severity: Major
          Found in app/assets/javascripts/puffer/codemirror/xml.js - About 2 hrs to fix

            Function onScrollWheel has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function onScrollWheel(cm, e) {
                var dx = e.wheelDeltaX, dy = e.wheelDeltaY;
                if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) dx = e.detail;
                if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) dy = e.detail;
                else if (dy == null) dy = e.wheelDelta;
            Severity: Minor
            Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

              Function jsTokenBase has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                function jsTokenBase(stream, state) {
                  var ch = stream.next();
                  if (ch == '"' || ch == "'")
                    return chain(stream, state, jsTokenString(ch));
                  else if (/[\[\]{}\(\),;\:\.]/.test(ch))
              Severity: Minor
              Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 1 hr to fix

                Function makeDisplay has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  function makeDisplay(place) {
                    var d = {};
                    var input = d.input = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none;");
                    if (webkit) input.style.width = "1000px";
                    else input.setAttribute("wrap", "off");
                Severity: Minor
                Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

                  Function patchDisplay has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    function patchDisplay(cm, from, to, intact, updateNumbersFrom) {
                      var dims = getDimensions(cm);
                      var display = cm.display, lineNumbers = cm.options.lineNumbers;
                      if (!intact.length && (!webkit || !cm.display.currentWheelTarget))
                        removeChildren(display.lineDiv);
                  Severity: Minor
                  Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

                    Function markText has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      function markText(cm, from, to, options, type) {
                        var doc = cm.view.doc;
                        var marker = new TextMarker(cm, type);
                        if (type == "range" && !posLess(from, to)) return marker;
                        if (options) for (var opt in options) if (options.hasOwnProperty(opt))
                    Severity: Minor
                    Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

                      Method render has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def render *args
                          source, context = normalize_render_options *args
                          context = merge_context context, additional_render_options
                          source ||= inherited_layout
                      
                      
                      Severity: Minor
                      Found in lib/puffer_pages/backends/models/page.rb - About 1 hr 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 updateMarkedSpans has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        function updateMarkedSpans(oldFirst, oldLast, startCh, endCh, newText) {
                          if (!oldFirst && !oldLast) return newText;
                          // Get the spans that 'stick out' on both sides
                          var first = markedSpansBefore(oldFirst, startCh);
                          var last = markedSpansAfter(oldLast, startCh, endCh);
                      Severity: Minor
                      Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

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

                          function onDrop(e) {
                            var cm = this;
                            if (eventInWidget(cm.display, e) || (cm.options.onDragEvent && cm.options.onDragEvent(cm, addStop(e))))
                              return;
                            e_preventDefault(e);
                        Severity: Minor
                        Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

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

                            function onContextMenu(cm, e) {
                              var display = cm.display;
                              if (eventInWidget(display, e)) return;
                              
                              var sel = cm.view.sel;
                          Severity: Minor
                          Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

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

                              function skipAtomic(cm, pos, bias, mayClear) {
                                var doc = cm.view.doc, flipped = false, curPos = pos;
                                var dir = bias || 1;
                                cm.view.cantEdit = false;
                                search: for (;;) {
                            Severity: Minor
                            Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

                              Function fromTextArea has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                CodeMirror.fromTextArea = function(textarea, options) {
                                  if (!options) options = {};
                                  options.value = textarea.value;
                                  if (!options.tabindex && textarea.tabindex)
                                    options.tabindex = textarea.tabindex;
                              Severity: Minor
                              Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

                                Function measureLineInner has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  function measureLineInner(cm, line) {
                                    var display = cm.display, measure = emptyArray(line.text.length);
                                    var pre = lineContent(cm, line, measure);
                                
                                    // IE does not cache element positions of inline elements between
                                Severity: Minor
                                Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

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

                                  function Widget(tag_name, methods) {
                                    if (!methods) {
                                      methods = tag_name;
                                      tag_name = 'DIV';
                                    }
                                  Severity: Minor
                                  Found in app/assets/javascripts/puffer/right-tabs-src.js - About 1 hr to fix

                                    Function tokenize has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        var tokenize = function(stream, state) {
                                          var token = null;
                                    
                                          if (stream.peek() == '\'' || stream.peek() == '"') {
                                            token = inString(stream, state);
                                    Severity: Minor
                                    Found in app/assets/javascripts/puffer/codemirror/liquid.js - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language