puffer/puffer_pages

View on GitHub

Showing 219 of 219 total issues

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

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

                      updateLine(cm, firstLine, firstLine.text.slice(0, from.ch) + hlText(lines[0]) +
                                 lastLine.text.slice(to.ch), hlSpans(lines[0]));
                Severity: Major
                Found in app/assets/javascripts/puffer/codemirror.js and 1 other location - About 1 hr to fix
                app/assets/javascripts/puffer/codemirror.js on lines 2003..2004

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

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

                        updateLine(cm, firstLine, firstLine.text.slice(0, from.ch) + hlText(lines[0]) +
                                   firstLine.text.slice(to.ch), hlSpans(lines[0]));
                Severity: Major
                Found in app/assets/javascripts/puffer/codemirror.js and 1 other location - About 1 hr to fix
                app/assets/javascripts/puffer/codemirror.js on lines 2013..2014

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

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

                    for (var i = 0; i < chunk.lines.length; ++i) {
                      var line = chunk.lines[i];
                      if (line == lineObj) break;
                      else h += line.height;
                    }
                Severity: Major
                Found in app/assets/javascripts/puffer/codemirror.js and 1 other location - About 1 hr to fix
                app/assets/javascripts/puffer/codemirror.js on lines 4152..4156

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

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

                      for (var i = 0; i < p.children.length; ++i) {
                        var cur = p.children[i];
                        if (cur == chunk) break;
                        else h += cur.height;
                      }
                Severity: Major
                Found in app/assets/javascripts/puffer/codemirror.js and 1 other location - About 1 hr to fix
                app/assets/javascripts/puffer/codemirror.js on lines 4146..4150

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

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

                      for (var i = 1, e = lines.length - 1; i < e; ++i)
                        added.push(makeLine(hlText(lines[i]), hlSpans(lines[i]), th));
                Severity: Major
                Found in app/assets/javascripts/puffer/codemirror.js and 1 other location - About 1 hr to fix
                app/assets/javascripts/puffer/codemirror.js on lines 1996..1997

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

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

                      for (var i = 0, e = lines.length - 1; i < e; ++i)
                        added.push(makeLine(hlText(lines[i]), hlSpans(lines[i]), th));
                Severity: Major
                Found in app/assets/javascripts/puffer/codemirror.js and 1 other location - About 1 hr to fix
                app/assets/javascripts/puffer/codemirror.js on lines 2020..2021

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

                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

                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

                    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

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

                              if (scrollPos.scrollTop != null) {
                                setScrollTop(cm, scrollPos.scrollTop);
                                if (Math.abs(cm.view.scrollTop - startTop) > 1) changed = true;
                              }
                        Severity: Major
                        Found in app/assets/javascripts/puffer/codemirror.js and 1 other location - About 1 hr to fix
                        app/assets/javascripts/puffer/codemirror.js on lines 2243..2246

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

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language