d11n/uri-query

View on GitHub
source/strategies/default.js

Summary

Maintainability
C
1 day
Test Coverage

Function main has a Cognitive Complexity of 137 (exceeds 5 allowed). Consider refactoring.
Invalid

(function main(encode, decode) {
    return module.exports = Object.freeze({
        parse_query_string,
        parse_query_params,
        compose_query_string,
Severity: Minor
Found in source/strategies/default.js - About 2 days 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

Function main has 225 lines of code (exceeds 25 allowed). Consider refactoring.
Invalid

(function main(encode, decode) {
    return module.exports = Object.freeze({
        parse_query_string,
        parse_query_params,
        compose_query_string,
Severity: Major
Found in source/strategies/default.js - About 1 day to fix

    Function parse_query_string has 115 lines of code (exceeds 25 allowed). Consider refactoring.
    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('=');
    Severity: Major
    Found in source/strategies/default.js - About 4 hrs to fix

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

          function compose_query_string(query_params) {
              if (!query_params || 'object' !== typeof query_params) {
                  return '';
              }
              let uri_query = '';
      Severity: Major
      Found in source/strategies/default.js - About 2 hrs to fix

        Function add_composite_value has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        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];
        Severity: Major
        Found in source/strategies/default.js - About 2 hrs to fix

          Function get_path_keys has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          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('[');
          Severity: Minor
          Found in source/strategies/default.js - About 1 hr to fix

            Function parse_query_params has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            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) ? [] : {};
            Severity: Minor
            Found in source/strategies/default.js - About 1 hr to fix

              There are no issues that match your filters.

              Category
              Status