puffer/puffer_pages

View on GitHub

Showing 219 of 219 total issues

Avoid deeply nested control flow statements.
Open

              for (++j; j < i && countsAsNum.test(types[j]); ++j) {}
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

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

        function updateDocInner(cm, from, to, newText, 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 (m.endStyle && sp.to == nextChange) spanEndStyle += " " + m.endStyle;
        Severity: Major
        Found in app/assets/javascripts/puffer/codemirror.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                  } else if (context == "@mediaType") {
                    if (atMediaTypes[stream.current()]) {
                      style = "attribute";
                    } else if (stream.current().toLowerCase() == "and") {
                      style = "operator";
          Severity: Major
          Found in app/assets/javascripts/puffer/codemirror/css.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

                        } else if (sp.from > pos && nextChange > sp.from) {
                          nextChange = sp.from;
                        }
              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 (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 (atMediaTypes[stream.current()]) {
                                style = "attribute"; // Known attribute
                              } else if (/^(only|not)$/i.test(stream.current())) {
                                style = "keyword";
                              } else if (stream.current().toLowerCase() == "and") {
                    Severity: Major
                    Found in app/assets/javascripts/puffer/codemirror/css.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

                        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 (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

                            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

                              Method import_json has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                                        def import_json json
                                          data = json.is_a?(String) ? ActiveSupport::JSON.decode(json) : json.map(&:stringify_keys!)
                              
                                          import_destroy
                              
                              
                              Severity: Minor
                              Found in lib/puffer_pages/backends/models/mixins/importable.rb - About 45 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

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

                                      setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight)));
                              Severity: Minor
                              Found in app/assets/javascripts/puffer/codemirror.js and 1 other location - About 45 mins to fix
                              app/assets/javascripts/puffer/codemirror.js on lines 1697..1697

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

                              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

                              Method resolve_with_interpolation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                                      def resolve_with_interpolation key
                                        if key.is_a? Symbol
                                          scope = @scopes.detect { |s| s.key? key }
                                          scope ||= @environments.detect { |s| s.key? key }
                                          scope[key] if scope
                              Severity: Minor
                              Found in lib/puffer_pages/extensions/context.rb - About 45 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

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

                                    setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth)));
                              Severity: Minor
                              Found in app/assets/javascripts/puffer/codemirror.js and 1 other location - About 45 mins to fix
                              app/assets/javascripts/puffer/codemirror.js on lines 1696..1696

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

                              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

                              Consider simplifying this complex logical expression.
                              Open

                                    if (display.wheelStartX == null) {
                                      display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop;
                                      display.wheelDX = dx; display.wheelDY = dy;
                                      setTimeout(function() {
                                        if (display.wheelStartX == null) return;
                              Severity: Major
                              Found in app/assets/javascripts/puffer/codemirror.js - About 40 mins to fix

                                Consider simplifying this complex logical expression.
                                Open

                                      if (endsAfter || marker.type == "bookmark" && span.from == endCh && span.from != startCh) {
                                        var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh);
                                        (nw || (nw = [])).push({from: startsBefore ? null : span.from - endCh,
                                                                to: span.to == null ? null : span.to - endCh,
                                                                marker: marker});
                                Severity: Major
                                Found in app/assets/javascripts/puffer/codemirror.js - About 40 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language