puffer/puffer_pages

View on GitHub

Showing 177 of 219 total issues

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

        def render(context)
          key = context[@key]
          options = @options.each_with_object({}) do |(name, value), result|
            result[name] = context[value] unless I18n::RESERVED_KEYS.include?(name)
          end
Severity: Minor
Found in lib/puffer_pages/liquid/tags/translate.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 buildLineElement has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function buildLineElement(cm, line, lineNo, dims) {
    var lineElement = lineContent(cm, line);
    var markers = line.gutterMarkers, display = cm.display;

    if (!cm.options.lineNumbers && !markers && !line.bgClass && !line.wrapClass &&
Severity: Minor
Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

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

      function buildToken(builder, text, style, startStyle, endStyle) {
        if (!text) return;
        if (!tokenSpecialChars.test(text)) {
          builder.col += text.length;
          var content = document.createTextNode(text);
    Severity: Minor
    Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

          if (options.resizeFx && RightJS.Fx && prev_panel && (swapping || loading)) {
            controller.__working = true;
            var unlock = function() { controller.__working = false; };
      
            // calculating the visual effects durations
      Severity: Critical
      Found in app/assets/javascripts/puffer/right-tabs-src.js - About 1 hr to fix

        Function addChange has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function addChange(cm, start, added, old, origin, fromBefore, toBefore, fromAfter, toAfter) {
            var history = cm.view.history;
            history.undone.length = 0;
            var time = +new Date, cur = lst(history.done);
            
        Severity: Minor
        Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

          Method translatable has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                    def translatable *fields
                      if PufferPages.localize
                        translates *fields, fallbacks_for_empty_translations: true
                        translation_class.send(:include, ActiveUUID::UUID)
          
          
          Severity: Minor
          Found in lib/puffer_pages/backends/models/mixins/translatable.rb - About 1 hr to fix

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

                token: function(stream, state) {
                  if (!state.innerActive) {
                    var cutOff = Infinity, oldContent = stream.string;
                    for (var i = 0; i < n_others; ++i) {
                      var other = others[i];
            Severity: Minor
            Found in app/assets/javascripts/puffer/multiplex.js - About 1 hr to fix

              Function highlightWorker has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                function highlightWorker(cm) {
                  var view = cm.view, doc = view.doc;
                  if (view.frontier >= cm.display.showingTo) return;
                  var end = +new Date + cm.options.workTime;
                  var state = copyState(view.mode, getStateBefore(cm, view.frontier));
              Severity: Minor
              Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

                Method initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                        def initialize(tag_name, markup, tokens)
                          if markup =~ Syntax
                
                            @helper_name, @arguments, @attributes = $1, [], {}
                
                
                Severity: Minor
                Found in lib/puffer_pages/liquid/tags/url.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

                Method arranged has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                  def arranged
                    arranged = ActiveSupport::OrderedHash.new
                    insertion_points = [arranged]
                    depth = 0
                    each do |node|
                Severity: Minor
                Found in lib/puffer_pages/extensions/core.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 moveVisually has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  function moveVisually(line, start, dir, byUnit) {
                    var bidi = getOrder(line);
                    if (!bidi) return moveLogically(line, start, dir, byUnit);
                    var moveOneUnit = byUnit ? function(pos, dir) {
                      do pos += dir;
                Severity: Minor
                Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

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

                    function handleKeyBinding(cm, e) {
                      // Handle auto keymap transitions
                      var startMap = getKeyMap(cm.options.keyMap), next = startMap.auto;
                      clearTimeout(maybeTransition);
                      if (next && !isModifierKey(e)) maybeTransition = setTimeout(function() {
                  Severity: Minor
                  Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

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

                      var keywords = function(){
                        function kw(type) {return {type: type, style: "keyword"};}
                        var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
                        var operator = kw("operator"), atom = {type: "atom", style: "atom"};
                        
                    Severity: Minor
                    Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 1 hr to fix

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

                        function coordsCharInner(cm, lineObj, lineNo, x, y) {
                          var innerOff = y - heightAtLine(cm, lineObj);
                          var wrongLine = false, cWidth = cm.display.wrapper.clientWidth;
                          var measurement = measureLine(cm, lineObj);
                      
                      
                      Severity: Minor
                      Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

                        Function clear has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          TextMarker.prototype.clear = function() {
                            if (this.explicitlyCleared) return;
                            startOperation(this.cm);
                            var view = this.cm.view, min = null, max = null;
                            for (var i = 0; i < this.lines.length; ++i) {
                        Severity: Minor
                        Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

                          Function findPosH has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            function findPosH(cm, dir, unit, visually) {
                              var doc = cm.view.doc, end = cm.view.sel.head, line = end.line, ch = end.ch;
                              var lineObj = getLine(doc, line);
                              function findNextLine() {
                                var l = line + dir;
                          Severity: Minor
                          Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

                            Function cursorCoords has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              function cursorCoords(cm, pos, context, lineObj, measurement) {
                                lineObj = lineObj || getLine(cm.view.doc, pos.line);
                                if (!measurement) measurement = measureLine(cm, lineObj);
                                function get(ch, right) {
                                  var m = measureChar(cm, lineObj, ch, measurement);
                            Severity: Minor
                            Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

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

                                function lineContent(cm, realLine, measure) {
                                  var merged, line = realLine, lineBefore, sawBefore, simple = true;
                                  while (merged = collapsedSpanAtStart(line)) {
                                    simple = false;
                                    line = getLine(cm.view.doc, merged.find().from.line);
                              Severity: Minor
                              Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

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

                                  function endOperation(cm) {
                                    var op = cm.curOp;
                                    if (--op.depth) return;
                                    cm.curOp = null;
                                    var view = cm.view, display = cm.display;
                                Severity: Minor
                                Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix

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

                                    function indentLine(cm, n, how, aggressive) {
                                      var doc = cm.view.doc;
                                      if (!how) how = "add";
                                      if (how == "smart") {
                                        if (!cm.view.mode.indent) how = "prev";
                                  Severity: Minor
                                  Found in app/assets/javascripts/puffer/codemirror.js - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language