sazze/node-pm

View on GitHub
docs/scripts/URI.js

Summary

Maintainability
F
3 mos
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 docs/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 docs/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 docs/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 docs/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 docs/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 docs/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 docs/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 docs/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 docs/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 docs/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 docs/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 docs/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 docs/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 docs/scripts/URI.js - About 1 hr to fix

                              Avoid deeply nested control flow statements.
                              Open

                                          if (one_map[key][i] !== two_map[key][i]) {
                                            return false;
                                          }
                              Severity: Major
                              Found in docs/scripts/URI.js - About 45 mins 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 docs/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 docs/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 docs/scripts/URI.js - About 40 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

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

                                        Avoid too many return statements within this function.
                                        Open

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

                                          Avoid too many return statements within this function.
                                          Open

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

                                            Avoid too many return statements within this function.
                                            Open

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

                                              Avoid too many return statements within this function.
                                              Open

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

                                                Avoid too many return statements within this function.
                                                Open

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

                                                  Avoid too many return statements within this function.
                                                  Open

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

                                                    Avoid too many return statements within this function.
                                                    Open

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

                                                      Avoid too many return statements within this function.
                                                      Open

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

                                                        Avoid too many return statements within this function.
                                                        Open

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

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

                                                          (function(root, factory) {
                                                            // https://github.com/umdjs/umd/blob/master/returnExports.js
                                                            if (typeof exports === 'object') {
                                                              // Node
                                                              module.exports = factory(require('./punycode'), require('./IPv6'), require('./SecondLevelDomains'));
                                                          Severity: Major
                                                          Found in docs/scripts/URI.js and 1 other location - About 3 mos to fix
                                                          docs/template/static/scripts/URI.js on lines 14..1429

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

                                                          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