source/strategies/default.js
Function main
has a Cognitive Complexity of 137 (exceeds 5 allowed). Consider refactoring. Invalid
Invalid
(function main(encode, decode) {
return module.exports = Object.freeze({
parse_query_string,
parse_query_params,
compose_query_string,
- 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
Function main
has 225 lines of code (exceeds 25 allowed). Consider refactoring. Invalid
Invalid
(function main(encode, decode) {
return module.exports = Object.freeze({
parse_query_string,
parse_query_params,
compose_query_string,
Function parse_query_string
has 115 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function parse_query_string(query_string) {
const query_object = {};
const query_pairs = query_string.split(/&+/);
for (const pair of query_pairs) {
let separator_index = pair.indexOf('=');
Function compose_query_string
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function compose_query_string(query_params) {
if (!query_params || 'object' !== typeof query_params) {
return '';
}
let uri_query = '';
Function add_composite_value
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function add_composite_value(key, value) {
const path_keys = get_path_keys(key);
let query_object_value = query_object;
for (let i = 0, n = path_keys.length - 1; i <= n; i++) {
const path_key = path_keys[i];
Function get_path_keys
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function get_path_keys(path_string) {
const path_keys = [];
let unparsed_path = path_string;
while (unparsed_path) {
const open_brack_i = unparsed_path.indexOf('[');
Function parse_query_params
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function parse_query_params(query_params) {
if (query_params instanceof Set) {
return new Set(parse_query_params(Array.from(query_params)));
}
const query_object = Array.isArray(query_params) ? [] : {};