Moogsoft/node-moog

View on GitHub
doc/scripts/URI.js

Summary

Maintainability
F
1 wk
Test Coverage

File URI.js has 1284 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
 * URI.js - Mutating URLs
 *
 * Version: 1.8.3
 *
Severity: Major
Found in doc/scripts/URI.js - About 3 days to fix

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

      p.equals = function(uri) {
        var one = this.clone();
        var two = new URI(uri);
        var one_map = {};
        var two_map = {};
    Severity: Major
    Found in doc/scripts/URI.js - About 2 hrs to fix

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

        p.is = function(what) {
          var ip = false;
          var ip4 = false;
          var ip6 = false;
          var name = false;
      Severity: Minor
      Found in doc/scripts/URI.js - About 1 hr to fix

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

          p.normalizePath = function(build) {
            if (this._parts.urn) {
              return this;
            }
            if (!this._parts.path || this._parts.path === '/') {
        Severity: Minor
        Found in doc/scripts/URI.js - About 1 hr to fix

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

            p.relativeTo = function(base) {
              var relative = this.clone();
              var properties = ['protocol', 'username', 'password', 'hostname', 'port'];
              var common, _base, _this, _base_diff, _this_diff;
              if (this._parts.urn) {
          Severity: Minor
          Found in doc/scripts/URI.js - About 1 hr to fix

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

              p.segment = function(segment, v, build) {
                var separator = this._parts.urn ? ':' : '/';
                var path = this.path();
                var absolute = path.substring(0, 1) === '/';
                var segments = path.split(separator);
            Severity: Minor
            Found in doc/scripts/URI.js - About 1 hr to fix

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

                p.suffix = function(v, build) {
                  if (this._parts.urn) {
                    return v === undefined ? '' : this;
                  }
                  if (v === undefined || v === true) {
              Severity: Minor
              Found in doc/scripts/URI.js - About 1 hr to fix

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

                  URI.parse = function(string, parts) {
                    var pos, t;
                    if (!parts) {
                      parts = {};
                    }
                Severity: Minor
                Found in doc/scripts/URI.js - About 1 hr to fix

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

                    p.tld = function(v, build) {
                      if (this._parts.urn) {
                        return v === undefined ? '' : this;
                      }
                      if (typeof v === 'boolean') {
                  Severity: Minor
                  Found in doc/scripts/URI.js - About 1 hr to fix

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

                      p.directory = function(v, build) {
                        if (this._parts.urn) {
                          return v === undefined ? '' : this;
                        }
                        if (v === undefined || v === true) {
                    Severity: Minor
                    Found in doc/scripts/URI.js - About 1 hr to fix

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

                        p.readable = function() {
                          var uri = this.clone();
                          // removing username, password, because they shouldn't be displayed according to RFC 3986
                          uri.username("").password("").normalize();
                          var t = '';
                      Severity: Minor
                      Found in doc/scripts/URI.js - About 1 hr to fix

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

                          p.domain = function(v, build) {
                            if (this._parts.urn) {
                              return v === undefined ? '' : this;
                            }
                            if (typeof v === 'boolean') {
                        Severity: Minor
                        Found in doc/scripts/URI.js - About 1 hr to fix

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

                            p.absoluteTo = function(base) {
                              var resolved = this.clone();
                              var properties = ['protocol', 'username', 'password', 'hostname', 'port'];
                              var basedir, i, p;
                              if (this._parts.urn) {
                          Severity: Minor
                          Found in doc/scripts/URI.js - About 1 hr to fix

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

                              p.filename = function(v, build) {
                                if (this._parts.urn) {
                                  return v === undefined ? '' : this;
                                }
                                if (v === undefined || v === true) {
                            Severity: Minor
                            Found in doc/scripts/URI.js - About 1 hr to fix

                              Avoid deeply nested control flow statements.
                              Open

                                          if (data[key][i] !== undefined && unique[data[key][i] + ""] === undefined) {
                                            t += "&" + URI.buildQueryParameter(key, data[key][i]);
                                            if (duplicates !== true) {
                                              unique[data[key][i] + ""] = true;
                                            }
                              Severity: Major
                              Found in doc/scripts/URI.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                            if (one_map[key][i] !== two_map[key][i]) {
                                              return false;
                                            }
                                Severity: Major
                                Found in doc/scripts/URI.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                          if (data[name] === value) {
                                            data[name] = undefined;
                                          } else if (isArray(data[name])) {
                                            data[name] = filterArrayValues(data[name], value);
                                          }
                                  Severity: Major
                                  Found in doc/scripts/URI.js - About 45 mins to fix

                                    Consider simplifying this complex logical expression.
                                    Open

                                        if (this._parts.hostname) {
                                          relative = false;
                                          ip4 = URI.ip4_expression.test(this._parts.hostname);
                                          ip6 = URI.ip6_expression.test(this._parts.hostname);
                                          ip = ip4 || ip6;
                                    Severity: Major
                                    Found in doc/scripts/URI.js - About 40 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                            return this;
                                      Severity: Major
                                      Found in doc/scripts/URI.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                            return true;
                                        Severity: Major
                                        Found in doc/scripts/URI.js - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                      return false;
                                          Severity: Major
                                          Found in doc/scripts/URI.js - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                        return false;
                                            Severity: Major
                                            Found in doc/scripts/URI.js - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                        return false;
                                              Severity: Major
                                              Found in doc/scripts/URI.js - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                          return this;
                                                Severity: Major
                                                Found in doc/scripts/URI.js - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                        return this;
                                                  Severity: Major
                                                  Found in doc/scripts/URI.js - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                                  return false;
                                                    Severity: Major
                                                    Found in doc/scripts/URI.js - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                            return this;
                                                      Severity: Major
                                                      Found in doc/scripts/URI.js - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                              return this;
                                                        Severity: Major
                                                        Found in doc/scripts/URI.js - About 30 mins to fix

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

                                                            p.authority = function(v, build) {
                                                              if (this._parts.urn) {
                                                                return v === undefined ? '' : this;
                                                              }
                                                              if (v === undefined) {
                                                          Severity: Major
                                                          Found in doc/scripts/URI.js and 1 other location - About 4 hrs to fix
                                                          doc/scripts/URI.js on lines 764..775

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

                                                          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

                                                            p.host = function(v, build) {
                                                              if (this._parts.urn) {
                                                                return v === undefined ? '' : this;
                                                              }
                                                              if (v === undefined) {
                                                          Severity: Major
                                                          Found in doc/scripts/URI.js and 1 other location - About 4 hrs to fix
                                                          doc/scripts/URI.js on lines 776..787

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

                                                          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

                                                            p.unicode = function() {
                                                              // expect iso8859 input, unicode output
                                                              var e = URI.encode;
                                                              var d = URI.decode;
                                                              URI.encode = strictEncodeURIComponent;
                                                          Severity: Major
                                                          Found in doc/scripts/URI.js and 1 other location - About 3 hrs to fix
                                                          doc/scripts/URI.js on lines 1220..1230

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

                                                          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

                                                            p.iso8859 = function() {
                                                              // expect unicode input, iso8859 output
                                                              var e = URI.encode;
                                                              var d = URI.decode;
                                                              URI.encode = escape;
                                                          Severity: Major
                                                          Found in doc/scripts/URI.js and 1 other location - About 3 hrs to fix
                                                          doc/scripts/URI.js on lines 1231..1241

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

                                                          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

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

                                                                  if (SLD && SLD.is(v)) {
                                                                    replace = new RegExp(escapeRegEx(this.tld()) + "$");
                                                                    this._parts.hostname = this._parts.hostname.replace(replace, v);
                                                                  } else {
                                                          Severity: Major
                                                          Found in doc/scripts/URI.js and 1 other location - About 1 hr to fix
                                                          doc/scripts/URI.js on lines 916..919

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

                                                          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

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

                                                                } else {
                                                                  replace = new RegExp(escapeRegEx(this.tld()) + "$");
                                                                  this._parts.hostname = this._parts.hostname.replace(replace, v);
                                                                }
                                                          Severity: Major
                                                          Found in doc/scripts/URI.js and 1 other location - About 1 hr to fix
                                                          doc/scripts/URI.js on lines 908..911

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

                                                          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 (pos > -1) {
                                                                // escaping?
                                                                parts.query = string.substring(pos + 1) || null;
                                                                string = string.substring(0, pos);
                                                              }
                                                          Severity: Major
                                                          Found in doc/scripts/URI.js and 1 other location - About 1 hr to fix
                                                          doc/scripts/URI.js on lines 240..244

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

                                                          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 (pos > -1) {
                                                                // escaping?
                                                                parts.fragment = string.substring(pos + 1) || null;
                                                                string = string.substring(0, pos);
                                                              }
                                                          Severity: Major
                                                          Found in doc/scripts/URI.js and 1 other location - About 1 hr to fix
                                                          doc/scripts/URI.js on lines 247..251

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

                                                          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