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';
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);
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);
- Read upRead up
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) {
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;
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;
- Read upRead up
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) {
- Read upRead up
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"