unsplit/unsplit

View on GitHub
src/plugins/page.js

Summary

Maintainability
F
4 days
Test Coverage

Function 1 has 274 lines of code (exceeds 25 allowed). Consider refactoring.
Open

!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.page=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function (process){
  /* globals require, module */

  'use strict';
Severity: Major
Found in src/plugins/page.js - About 1 day to fix

    File page.js has 448 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.page=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
    (function (process){
      /* globals require, module */
    
      'use strict';
    Severity: Minor
    Found in src/plugins/page.js - About 6 hrs to fix

      Function 3 has 96 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      },{}],3:[function(require,module,exports){
      var isArray = require('isarray');
      
      /**
       * Expose `pathToRegexp`.
      Severity: Major
      Found in src/plugins/page.js - About 3 hrs to fix

        Function 2 has 69 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        },{"_process":2,"path-to-regexp":3}],2:[function(require,module,exports){
        // shim for using process in browser
        
        var process = module.exports = {};
        
        
        Severity: Major
        Found in src/plugins/page.js - About 2 hrs to fix

          Function nextTick has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          process.nextTick = (function () {
              var canSetImmediate = typeof window !== 'undefined'
              && window.setImmediate;
              var canMutationObserver = typeof window !== 'undefined'
              && window.MutationObserver;
          Severity: Minor
          Found in src/plugins/page.js - About 1 hr to fix

            Function replacePath has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function replacePath (path, keys) {
              var index = 0;
            
              function replace (_, escaped, prefix, key, capture, group, suffix, escape) {
                if (escaped) {
            Severity: Minor
            Found in src/plugins/page.js - About 1 hr to fix

              Function pathToRegexp has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function pathToRegexp (path, keys, options) {
                keys = keys || [];
              
                if (!isArray(keys)) {
                  options = keys;
              Severity: Minor
              Found in src/plugins/page.js - About 1 hr to fix

                Function replace has 8 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  function replace (_, escaped, prefix, key, capture, group, suffix, escape) {
                Severity: Major
                Found in src/plugins/page.js - About 1 hr to fix

                  Avoid too many return statements within this function.
                  Open

                      if (!hashbang && el.pathname === location.pathname && (el.hash || '#' === link)) return;
                  Severity: Major
                  Found in src/plugins/page.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        if (base && orig === path) return;
                    Severity: Major
                    Found in src/plugins/page.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          if (link && link.indexOf('mailto:') > -1) return;
                      Severity: Major
                      Found in src/plugins/page.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                            if (el.target) return;
                        Severity: Major
                        Found in src/plugins/page.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              if (!sameOrigin(el.href)) return;
                          Severity: Major
                          Found in src/plugins/page.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                if (el.hasAttribute('download') || el.getAttribute('rel') === 'external') return;
                            Severity: Major
                            Found in src/plugins/page.js - About 30 mins to fix

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

                                  history.replaceState(this.state, this.title, hashbang && this.path !== '/' ? '#!' + this.path : this.canonicalPath);
                              Severity: Minor
                              Found in src/plugins/page.js and 1 other location - About 50 mins to fix
                              src/plugins/page.js on lines 419..419

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

                              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

                                  history.pushState(this.state, this.title, hashbang && this.path !== '/' ? '#!' + this.path : this.canonicalPath);
                              Severity: Minor
                              Found in src/plugins/page.js and 1 other location - About 50 mins to fix
                              src/plugins/page.js on lines 429..429

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

                              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