Showing 14 of 14 total issues
File request-listener.js
has 266 lines of code (exceeds 250 allowed). Consider refactoring. Open
import fibers from 'fibers';
import url from 'url';
import querystring from 'querystring';
import { isFunction, getReturnObject, getNestedValue } from './util';
RequestListener
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class RequestListener {
constructor(server, request, response) {
this._server = server;
this._request = request;
this._response = response;
Function start
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
start() {
const startupMessage = `Collection API v${this.version}`;
if (this.options.standAlone === true) {
let httpServer = http;
Function constructor
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(server, request, response) {
this._server = server;
this._request = request;
this._response = response;
Function put
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
put() {
if (!this._requestPath.collectionId) {
return this._notFoundResponse('Missing _id');
}
Function get
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
get(fromRequest = 'GET') {
fibers(() => {
try {
const { collectionId } = this._requestPath;
let cursor = null;
Function _authenticate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
_authenticate(...args) {
const collectionOptions = this._collectionOptions;
let authCount = 0;
// Check the global auth token
- 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 constructor
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
constructor(server, request, response) {
this._server = server;
this._request = request;
this._response = response;
- 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
Avoid too many return
statements within this function. Open
return this._createdResponse(stringify(records));
Avoid too many return
statements within this function. Open
return this.get('PUT');
Avoid too many return
statements within this function. Open
return this._okResponse(stringify(records));
Avoid too many return
statements within this function. Open
return this._notFoundResponse('No Record(s) Found');
Avoid too many return
statements within this function. Open
return this._internalServerErrorResponse(e);
Function start
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
start() {
const startupMessage = `Collection API v${this.version}`;
if (this.options.standAlone === true) {
let httpServer = http;
- 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"