ericduran/chromeHAR

View on GitHub
bower_components/json3/lib/json3.js

Summary

Maintainability
F
6 days
Test Coverage

File json3.js has 541 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*! JSON v3.2.5 | http://bestiejs.github.io/json3 | Copyright 2012-2013, Kit Cambridge | http://kit.mit-license.org */
;(function (window) {
  // Convenience aliases.
  var getClass = {}.toString, isProperty, forEach, undef;

Severity: Major
Found in bower_components/json3/lib/json3.js - About 1 day to fix

    Consider simplifying this complex logical expression.
    Open

            if (stringifySupported) {
              // A test function object with a custom `toJSON` method.
              (value = function () {
                return 1;
              }).toJSON = value;
    Severity: Critical
    Found in bower_components/json3/lib/json3.js - About 4 hrs to fix

      Function lex has 104 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            var lex = function () {
              var source = Source, length = source.length, value, begin, position, isSigned, charCode;
              while (Index < length) {
                charCode = source.charCodeAt(Index);
                switch (charCode) {
      Severity: Major
      Found in bower_components/json3/lib/json3.js - About 4 hrs to fix

        Function serialize has 81 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              var serialize = function (property, object, callback, properties, whitespace, indentation, stack) {
                var value = object[property], className, year, month, date, time, hours, minutes, seconds, milliseconds, results, element, index, length, prefix, hasMembers, result;
                try {
                  // Necessary for host object support.
                  value = object[property];
        Severity: Major
        Found in bower_components/json3/lib/json3.js - About 3 hrs to fix

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

            function has(name) {
              if (name == "bug-string-char-index") {
                // IE <= 7 doesn't support accessing string characters using square
                // bracket notation. IE 8 only supports this for primitives.
                return "a"[0] != "a";
          Severity: Major
          Found in bower_components/json3/lib/json3.js - About 2 hrs to fix

            Function get has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  var get = function (value) {
                    var results, hasMembers;
                    if (value == "$") {
                      // Unexpected end of input.
                      abort();
            Severity: Major
            Found in bower_components/json3/lib/json3.js - About 2 hrs to fix

              Function serialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                    var serialize = function (property, object, callback, properties, whitespace, indentation, stack) {
              Severity: Major
              Found in bower_components/json3/lib/json3.js - About 50 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            for (index = 0, length = value.length; index < length; hasMembers || (hasMembers = true), index++) {
                              element = serialize(index, value, callback, properties, whitespace, indentation, stack);
                              results.push(element === undef ? "null" : element);
                            }
                Severity: Major
                Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                for (value = "@", Index++; Index < length;) {
                                  charCode = source.charCodeAt(Index);
                                  if (charCode < 32) {
                                    // Unescaped ASCII control characters (those with a code unit
                                    // less than the space character) are not permitted.
                  Severity: Major
                  Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                  if (charCode == 45) {
                                    isSigned = true;
                                    charCode = source.charCodeAt(++Index);
                                  }
                    Severity: Major
                    Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                    if (source.charCodeAt(Index) == 34) {
                                      // Advance to the next character and return the revived string.
                                      Index++;
                                      return value;
                                    }
                      Severity: Major
                      Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                      if (isSigned) {
                                        abort();
                                      }
                        Severity: Major
                        Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                      if (!(isFunction && property == "prototype") && isProperty.call(object, property) && !(isConstructor = property === "constructor")) {
                                        callback(property);
                                      }
                          Severity: Major
                          Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                          if (parseSupported) {
                                            try {
                                              // Safari <= 5.1.2 and FF 3.1b1 allow unescaped tabs in strings.
                                              parseSupported = !parse('"\t"');
                                            } catch (exception) {}
                            Severity: Major
                            Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                          if (!(isFunction && property == "prototype") && !isProperty.call(members, property) && (members[property] = 1) && isProperty.call(object, property)) {
                                            callback(property);
                                          }
                              Severity: Major
                              Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                              if (charCode < 32) {
                                                result += unicodePrefix + toPaddedString(2, charCode.toString(16));
                                                break;
                                              }
                                Severity: Major
                                Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                              if (stack[length] === value) {
                                                // Cyclic structures cannot be serialized by `JSON.stringify`.
                                                throw TypeError();
                                              }
                                  Severity: Major
                                  Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                  if (charCode >= 48 && charCode <= 57) {
                                                    // Leading zeroes are interpreted as octal literals.
                                                    if (charCode == 48 && ((charCode = source.charCodeAt(Index + 1)), charCode >= 48 && charCode <= 57)) {
                                                      // Illegal octal literal.
                                                      abort();
                                    Severity: Major
                                    Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                  if (value > -1 / 0 && value < 1 / 0) {
                                                    // Dates are serialized according to the `Date#toJSON` method
                                                    // specified in ES 5.1 section 15.9.5.44. See section 15.9.1.15
                                                    // for the ISO 8601 date time string format.
                                                    if (getDay) {
                                      Severity: Major
                                      Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                                      if (element !== undef) {
                                                        // According to ES 5.1 section 15.12.3: "If `gap` {whitespace}
                                                        // is not the empty string, let `member` {quote(property) + ":"}
                                                        // be the concatenation of `member` and the `space` character."
                                                        // The "`space` character" refers to the literal space
                                        Severity: Major
                                        Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                        if (source.slice(Index, Index + 4) == "true") {
                                                          Index += 4;
                                                          return true;
                                                        } else if (source.slice(Index, Index + 5) == "false") {
                                                          Index += 5;
                                          Severity: Major
                                          Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                                            Avoid deeply nested control flow statements.
                                            Open

                                                        for (var index = 0, length = filter.length, value; index < length; value = filter[index++], ((getClass.call(value) == stringClass || getClass.call(value) == numberClass) && (properties[value] = 1)));
                                            Severity: Major
                                            Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                                              Avoid deeply nested control flow statements.
                                              Open

                                                          if ((width -= width % 1) > 0) {
                                                            for (whitespace = "", width > 10 && (width = 10); whitespace.length < width; whitespace += " ");
                                                          }
                                              Severity: Major
                                              Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                                                Avoid deeply nested control flow statements.
                                                Open

                                                          } else if (getClass.call(width) == stringClass) {
                                                            whitespace = width.length <= 10 ? width : width.slice(0, 10);
                                                          }
                                                Severity: Major
                                                Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                                                  Avoid deeply nested control flow statements.
                                                  Open

                                                              for (;; hasMembers || (hasMembers = true)) {
                                                                value = lex();
                                                                // A closing square bracket marks the end of the array literal.
                                                                if (value == "]") {
                                                                  break;
                                                  Severity: Major
                                                  Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                                                    Avoid deeply nested control flow statements.
                                                    Open

                                                              } else if (typeof value.toJSON == "function" && ((className != numberClass && className != stringClass && className != arrayClass) || isProperty.call(value, "toJSON"))) {
                                                                // Prototype <= 1.6.1 adds non-standard `toJSON` methods to the
                                                                // `Number`, `String`, `Date`, and `Array` prototypes. JSON 3
                                                                // ignores all `toJSON` methods on these objects unless they are
                                                                // defined directly on an instance.
                                                    Severity: Major
                                                    Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                                                      Avoid deeply nested control flow statements.
                                                      Open

                                                                } else if (value == "{") {
                                                                  // Parses a JSON object, returning a new JavaScript object.
                                                                  results = {};
                                                                  for (;; hasMembers || (hasMembers = true)) {
                                                                    value = lex();
                                                      Severity: Major
                                                      Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                                                        Avoid deeply nested control flow statements.
                                                        Open

                                                                    for (length = value.length; length--;) {
                                                                      update(value, length, callback);
                                                                    }
                                                        Severity: Major
                                                        Found in bower_components/json3/lib/json3.js - About 45 mins to fix

                                                          Consider simplifying this complex logical expression.
                                                          Open

                                                                                  if (!(charCode >= 48 && charCode <= 57 || charCode >= 97 && charCode <= 102 || charCode >= 65 && charCode <= 70)) {
                                                                                    // Invalid Unicode escape sequence.
                                                                                    abort();
                                                                                  }
                                                          Severity: Major
                                                          Found in bower_components/json3/lib/json3.js - About 40 mins to fix

                                                            Avoid too many return statements within this function.
                                                            Open

                                                                      return result;
                                                            Severity: Major
                                                            Found in bower_components/json3/lib/json3.js - About 30 mins to fix

                                                              Avoid too many return statements within this function.
                                                              Open

                                                                      return "$";
                                                              Severity: Major
                                                              Found in bower_components/json3/lib/json3.js - About 30 mins to fix

                                                                Avoid too many return statements within this function.
                                                                Open

                                                                                return false;
                                                                Severity: Major
                                                                Found in bower_components/json3/lib/json3.js - About 30 mins to fix

                                                                  Avoid too many return statements within this function.
                                                                  Open

                                                                                  return null;
                                                                  Severity: Major
                                                                  Found in bower_components/json3/lib/json3.js - About 30 mins to fix

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

                                                                                result = hasMembers ? (whitespace ? "[\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "]" : ("[" + results.join(",") + "]")) : "[]";
                                                                    Severity: Major
                                                                    Found in bower_components/json3/lib/json3.js and 1 other location - About 1 hr to fix
                                                                    bower_components/json3/lib/json3.js on lines 472..472

                                                                    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

                                                                                result = hasMembers ? (whitespace ? "{\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "}" : ("{" + results.join(",") + "}")) : "{}";
                                                                    Severity: Major
                                                                    Found in bower_components/json3/lib/json3.js and 1 other location - About 1 hr to fix
                                                                    bower_components/json3/lib/json3.js on lines 454..454

                                                                    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

                                                                                  if (hasMembers) {
                                                                                    if (value == ",") {
                                                                                      value = lex();
                                                                                      if (value == "]") {
                                                                                        // Unexpected trailing `,` in array literal.
                                                                    Severity: Major
                                                                    Found in bower_components/json3/lib/json3.js and 1 other location - About 1 hr to fix
                                                                    bower_components/json3/lib/json3.js on lines 751..762

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

                                                                    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

                                                                                  if (hasMembers) {
                                                                                    if (value == ",") {
                                                                                      value = lex();
                                                                                      if (value == "}") {
                                                                                        // Unexpected trailing `,` in object literal.
                                                                    Severity: Major
                                                                    Found in bower_components/json3/lib/json3.js and 1 other location - About 1 hr to fix
                                                                    bower_components/json3/lib/json3.js on lines 721..732

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

                                                                    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