codenautas/json4all

View on GitHub

Showing 27 of 27 total issues

File json4all.js has 533 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"use strict";

(function codenautasModuleDefinition(root, name, factory) {
    /* global define */
    /* istanbul ignore next */
Severity: Major
Found in json4all.js - About 1 day to fix

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

    json4all.parse = function parse(text, inner){
        var payload = text[0] === STAR ? text.substr(1) : text;
        if (payload[0] === BANG) {
            payload = payload.substr(1);
            if (payload === 'undefined') return undefined;
    Severity: Major
    Found in json4all.js - About 2 hrs to fix

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

      module.exports = function(config, preConfig) {
        config.set({
      
          // base path that will be used to resolve all patterns (eg. files, exclude)
          basePath: '',
      Severity: Minor
      Found in karma.conf.js - About 1 hr to fix

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

        json4all.reviver = function reviver(key, plainValue){
            var log=false;
            var result;
            if(key==='$escape'){
                return plainValue;
        Severity: Minor
        Found in json4all.js - About 1 hr to fix

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

          json4all.toUrlConstruct = function toUrlConstruct(value){
              if(value === null) return simpleValue("null");
              if(value === undefined) return simpleValue("!undefined");
              if(value instanceof Function) return simpleValue("!unset");
              var typeName = constructorName(value);
          Severity: Minor
          Found in json4all.js - About 1 hr to fix

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

            json4all.replacer = function replacer(key, value){
                var realValue = this[key];
                /* istanbul ignore next */ // For IE compatibility
                if(realValue===InternalValueForUndefined){
                    this[key]=undefined;
            Severity: Minor
            Found in json4all.js - About 1 hr to fix

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

              json4all.addType = function addType(typeConstructor, functions, skipIfExists){
                  functions = functions || {};
                  var constructorName = typeof typeConstructor === 'string'? typeConstructor: functionName(typeConstructor);
                  if(skipIfExists && types[constructorName]){
                      return;
              Severity: Minor
              Found in json4all.js - About 1 hr to fix

                Avoid deeply nested control flow statements.
                Open

                            if(typeDef){
                                result = new typeDef.construct(plainValue.$value, typeDef.constructor);
                            }else{
                                console.log("JSON4all.parse invalid $special", plainValue.$special);
                                throw new Error("JSON4all.parse invalid $special");
                Severity: Major
                Found in json4all.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                              for(var k in plainValue){
                                  if(plainValue[k]===InternalValueForUndefined){
                                      plainValue[k]=undefined;
                                  }
                              }
                  Severity: Major
                  Found in json4all.js - About 45 mins to fix

                    Function codenautasModuleDefinition has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    (function codenautasModuleDefinition(root, name, factory) {
                        /* global define */
                        /* istanbul ignore next */
                        if(typeof root.globalModuleName !== 'string'){
                            root.globalModuleName = name;
                    Severity: Minor
                    Found in json4all.js - About 35 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

                    Avoid too many return statements within this function.
                    Open

                        if (okDetected) return valueOk;
                    Severity: Major
                    Found in json4all.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return realValue;
                      Severity: Major
                      Found in json4all.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return value;
                        Severity: Major
                        Found in json4all.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return plainValue.$escape;
                          Severity: Major
                          Found in json4all.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                            return result;
                            Severity: Major
                            Found in json4all.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                  return result;
                              Severity: Major
                              Found in json4all.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                                if (typeof serializedValue === "string") return json4all.mesureString(serializedValue);
                                Severity: Major
                                Found in json4all.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                          return json4all.getPlainObject(payload, CHANNEL.array.separator, [], null);
                                  Severity: Major
                                  Found in json4all.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                        return json4all.mesureString(JSON.stringify(value, json4all.replacer));
                                    Severity: Major
                                    Found in json4all.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                              return json4all.convertPlain2$special(parsed);
                                      Severity: Major
                                      Found in json4all.js - About 30 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language