puffer/puffer_pages

View on GitHub
app/assets/javascripts/puffer/codemirror/javascript.js

Summary

Maintainability
D
2 days
Test Coverage

File javascript.js has 370 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// TODO actually recognize syntax of TypeScript constructs

CodeMirror.defineMode("javascript", function(config, parserConfig) {
  var indentUnit = config.indentUnit;
  var jsonMode = parserConfig.json;
Severity: Minor
Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 4 hrs 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 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 JSLexical has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          function JSLexical(indented, column, type, align, prev, info) {
        Severity: Minor
        Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 45 mins to fix

          Function parseJS has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            function parseJS(state, style, type, content, stream) {
          Severity: Minor
          Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 35 mins to fix

            Avoid too many return statements within this function.
            Open

                if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
                                                    statement, poplex, popcontext);
            Severity: Major
            Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  if (type == "case") return cont(expression, expect(":"));
              Severity: Major
              Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return (known && state.lastType != ".") ? ret(known.type, known.style, word) :
                                     ret("variable", "variable", word);
                Severity: Major
                Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return chain(stream, state, jsTokenComment);
                  Severity: Major
                  Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return pass(pushlex("stat"), expression, expect(";"), poplex);
                    Severity: Major
                    Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            else return lexical.indented + (closing ? 0 : indentUnit);
                      Severity: Major
                      Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return ret("comment", "comment");
                        Severity: Major
                        Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return ret("operator", null, stream.current());
                          Severity: Major
                          Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                if (type == "for") return cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"),
                                                                  poplex, statement, poplex);
                            Severity: Major
                            Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                  if (type == "variable") return cont(pushlex("stat"), maybelabel);
                              Severity: Major
                              Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                        return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? indentUnit : 0);
                                Severity: Major
                                Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                          return ret("regexp", "string-2");
                                  Severity: Major
                                  Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                        if (type == ";") return cont();
                                    Severity: Major
                                    Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                          if (type == "function") return cont(functiondef);
                                      Severity: Major
                                      Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                            if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
                                                                                 block, poplex, poplex);
                                        Severity: Major
                                        Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                              if (type == ".") return cont(property, maybeoperator);
                                          Severity: Major
                                          Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                if (type == "default") return cont(expect(":"));
                                            Severity: Major
                                            Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                  if (type == "operator") return cont(expression);
                                              Severity: Major
                                              Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                        return ret("error", "error");
                                                Severity: Major
                                                Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                      return cont();
                                                  Severity: Major
                                                  Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                        if (type == "{") return cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator);
                                                    Severity: Major
                                                    Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                          if (type == "[") return cont(pushlex("]"), expression, expect("]"), poplex, maybeoperator);
                                                      Severity: Major
                                                      Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                              else if (type == "form") return lexical.indented + indentUnit;
                                                        Severity: Major
                                                        Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                                                          Avoid too many return statements within this function.
                                                          Open

                                                              if (type == "[") return cont(pushlex("]"), commasep(expression, "]"), poplex, maybeoperator);
                                                          Severity: Major
                                                          Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                                                            Avoid too many return statements within this function.
                                                            Open

                                                                  else if (lexical.align) return lexical.column + (closing ? 0 : 1);
                                                            Severity: Major
                                                            Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                                                              Avoid too many return statements within this function.
                                                              Open

                                                                      return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
                                                              Severity: Major
                                                              Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

                                                                Avoid too many return statements within this function.
                                                                Open

                                                                      return ret("operator", null, stream.current());
                                                                Severity: Major
                                                                Found in app/assets/javascripts/puffer/codemirror/javascript.js - About 30 mins to fix

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

                                                                    function pass() {
                                                                      for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
                                                                    }
                                                                  Severity: Major
                                                                  Found in app/assets/javascripts/puffer/codemirror/javascript.js and 1 other location - About 1 hr to fix
                                                                  app/assets/javascripts/puffer/codemirror/xml.js on lines 169..171

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

                                                                  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

                                                                  There are no issues that match your filters.

                                                                  Category
                                                                  Status