Showing 27 of 27 total issues
File json4all.js
has 533 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
"use strict";
(function codenautasModuleDefinition(root, name, factory) {
/* global define */
/* istanbul ignore next */
Function parse
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
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;
Function exports
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports = function(config, preConfig) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
Function reviver
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
json4all.reviver = function reviver(key, plainValue){
var log=false;
var result;
if(key==='$escape'){
return plainValue;
Function toUrlConstruct
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
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);
Function replacer
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
json4all.replacer = function replacer(key, value){
var realValue = this[key];
/* istanbul ignore next */ // For IE compatibility
if(realValue===InternalValueForUndefined){
this[key]=undefined;
Function addType
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
json4all.addType = function addType(typeConstructor, functions, skipIfExists){
functions = functions || {};
var constructorName = typeof typeConstructor === 'string'? typeConstructor: functionName(typeConstructor);
if(skipIfExists && types[constructorName]){
return;
Avoid deeply nested control flow statements. Open
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");
Avoid deeply nested control flow statements. Open
Open
for(var k in plainValue){
if(plainValue[k]===InternalValueForUndefined){
plainValue[k]=undefined;
}
}
Function codenautasModuleDefinition
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
(function codenautasModuleDefinition(root, name, factory) {
/* global define */
/* istanbul ignore next */
if(typeof root.globalModuleName !== 'string'){
root.globalModuleName = name;
- Read upRead up
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
Open
if (okDetected) return valueOk;
Avoid too many return
statements within this function. Open
Open
return realValue;
Avoid too many return
statements within this function. Open
Open
return value;
Avoid too many return
statements within this function. Open
Open
return plainValue.$escape;
Avoid too many return
statements within this function. Open
Open
return result;
Avoid too many return
statements within this function. Open
Open
return result;
Avoid too many return
statements within this function. Open
Open
if (typeof serializedValue === "string") return json4all.mesureString(serializedValue);
Avoid too many return
statements within this function. Open
Open
return json4all.getPlainObject(payload, CHANNEL.array.separator, [], null);
Avoid too many return
statements within this function. Open
Open
return json4all.mesureString(JSON.stringify(value, json4all.replacer));
Avoid too many return
statements within this function. Open
Open
return json4all.convertPlain2$special(parsed);