Showing 14 of 14 total issues
File canned.js
has 375 lines of code (exceeds 250 allowed). Consider refactoring. Open
"use strict";
var url = require('url')
var fs = require('fs')
var util = require('util')
Function responder
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
Canned.prototype.responder = function(body, req, res) {
var responseHandler
var httpObj = {}
var that = this
var parsedurl = url.parse(req.url)
- 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 _getFileFromRequest
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
Canned.prototype._getFileFromRequest = function(httpObj, files) {
if (!files) return false
var m, i, e, matchString, fileMatch, ctype
- 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 responder
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
Canned.prototype.responder = function(body, req, res) {
var responseHandler
var httpObj = {}
var that = this
var parsedurl = url.parse(req.url)
Function parseMetaData
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Canned.prototype.parseMetaData = function(response) {
var metaData = {}
// convert CR+LF => LF+LF, CR => LF, fixes line breaks causing issues in windows
response = response.replace("\r", "\n");
var lines = response.split("\n")
Function responseFilter
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Canned.prototype.responseFilter = function (req, res) {
var that = this
var body = ''
// assemble response body if GET/POST/PUT
Function _responseForFile
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Canned.prototype._responseForFile = function (httpObj, files, cb) {
var that = this
var fileObject = this._getFileFromRequest(httpObj, files);
httpObj.filename = fileObject.fname
if (fileObject) {
Function exports
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
var lookup = module.exports = function (path, wildcard) {
// Split the path and calculate how many paths will be generated
var parts = path.split('/')
var matches = path.match(/\/\d+(\/|$)/gi)
Function _getFileFromRequest
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Canned.prototype._getFileFromRequest = function(httpObj, files) {
if (!files) return false
var m, i, e, matchString, fileMatch, ctype
Function getSelectedResponse
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Canned.prototype.getSelectedResponse = function(responses, content, headers) {
var that = this
var inputObj
var response = responses[0]
var metaData = that.parseMetaData(response)
Function Response
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function Response(content_type, content, statusCode, res, options, custom_headers) {
Function exports
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
var lookup = module.exports = function (path, wildcard) {
// Split the path and calculate how many paths will be generated
var parts = path.split('/')
var matches = path.match(/\/\d+(\/|$)/gi)
- 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 deeply nested control flow statements. Open
if(Response.content_types[type] === httpObj.accept[i].trim()){
httpObj.matchingContentTypes.push(type);
}
Function matchFileWithExactQuery
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function matchFileWithExactQuery(matchString, fname, queryString, method, ctype) {