pretenderjs/pretender

View on GitHub

Showing 13 of 13 total issues

Function createPassthrough has 75 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function createPassthrough(fakeXHR, nativeXMLHttpRequest) {
  // event types to handle on the xhr
  var evts = ['error', 'timeout', 'abort', 'readystatechange'];

  // event types to handle on the xhr.upload
Severity: Major
Found in src/create-passthrough.ts - About 3 hrs to fix

    File pretender.ts has 291 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import * as FakeFetch from 'whatwg-fetch';
    import FakeXMLHttpRequest from 'fake-xml-http-request';
    import { Params, QueryParams } from 'route-recognizer';
    import { ResponseHandler, ResponseHandlerInstance } from '../index.d';
    import Hosts from './hosts';
    Severity: Minor
    Found in src/pretender.ts - About 3 hrs to fix

      Function createPassthrough has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      export function createPassthrough(fakeXHR, nativeXMLHttpRequest) {
        // event types to handle on the xhr
        var evts = ['error', 'timeout', 'abort', 'readystatechange'];
      
        // event types to handle on the xhr.upload
      Severity: Minor
      Found in src/create-passthrough.ts - About 2 hrs 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 interceptor has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function interceptor(ctx) {
        function FakeRequest() {
          // super()
          FakeXMLHttpRequest.call(this);
        }
      Severity: Minor
      Found in src/interceptor.ts - About 2 hrs to fix

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

          handleRequest(request: FakeRequest) {
            let verb = request.method.toUpperCase();
            let path = request.url;
        
            let handler = this._handlerFor(verb, path, request);
        Severity: Minor
        Found in src/pretender.ts - About 1 hr to fix

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

          module.exports = function (config) {
            config.set({
              // base path that will be used to resolve all patterns (eg. files, exclude)
              basePath: "",
          
          
          Severity: Minor
          Found in karma.conf.js - About 1 hr to fix

            Function handleRequest has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              handleRequest(request: FakeRequest) {
                let verb = request.method.toUpperCase();
                let path = request.url;
            
                let handler = this._handlerFor(verb, path, request);
            Severity: Minor
            Found in src/pretender.ts - About 1 hr 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 scheduleProgressEvent has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function scheduleProgressEvent(request, startTime, totalTime) {
              let totalSize = 0;
              const body = request.requestBody;
              if (body) {
                if (body instanceof FormData) {
            Severity: Minor
            Found in src/pretender.ts - About 1 hr to fix

              Function interceptor has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              export function interceptor(ctx) {
                function FakeRequest() {
                  // super()
                  FakeXMLHttpRequest.call(this);
                }
              Severity: Minor
              Found in src/interceptor.ts - About 1 hr 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 constructor has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                constructor() {
                  let lastArg = arguments[arguments.length - 1];
                  let options = typeof lastArg === 'object' ? lastArg : null;
                  let shouldNotTrack = options && options.trackRequests === false;
              
              
              Severity: Minor
              Found in src/pretender.ts - About 1 hr to fix

                Function constructor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  constructor() {
                    let lastArg = arguments[arguments.length - 1];
                    let options = typeof lastArg === 'object' ? lastArg : null;
                    let shouldNotTrack = options && options.trackRequests === false;
                
                
                Severity: Minor
                Found in src/pretender.ts - About 45 mins 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 Pretender has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                var Pretender = (function(self) {
                  function getModuleDefault(module) {
                    return module.default || module;
                  }
                
                
                Severity: Minor
                Found in iife-wrapper.js - About 35 mins 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 handleResponse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  handleResponse(request: FakeRequest, strategy, callback: Function) {
                    let delay = typeof strategy === 'function' ? strategy() : strategy;
                    delay = typeof delay === 'boolean' || typeof delay === 'number' ? delay : 0;
                
                    if (delay === false) {
                Severity: Minor
                Found in src/pretender.ts - About 35 mins 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

                Severity
                Category
                Status
                Source
                Language