Mashape/mockbin

View on GitHub

Showing 10 of 26 total issues

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

module.exports = function (req, res, next) {
  req.bodyChunks = []

  req.on('data', function (chunk) {
    req.bodyChunks.push(chunk)
Severity: Major
Found in lib/middleware/body-parser.js - About 3 hrs to fix

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

module.exports = function (req, res, next) {
  res.bodyXmlObj = {
    response: res.body
  }

Severity: Major
Found in lib/middleware/negotiate-content.js - About 2 hrs to fix

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

module.exports = function (req, res, next) {
  this.client.get('bin:' + req.params.uuid, function (err, value) {
    if (err) {
      debug(err)

Severity: Major
Found in lib/routes/bins/sample.js - About 2 hrs to fix

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

  var processFormData = function (event) {
    var response = {
      status: '',
      statusText: '',
      httpVersion: 'HTTP/1.1',
Severity: Minor
Found in src/static/bin/create.js - About 1 hr to fix

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

module.exports = function (req, res, next) {
  var mock = req.jsonBody

  // check for full HAR
  if (req.jsonBody && req.jsonBody.response) {
Severity: Minor
Found in lib/routes/bins/create.js - About 1 hr to fix

Function exports has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function (req, res, next) {
  this.client.get('bin:' + req.params.uuid, function (err, value) {
    if (err) {
      debug(err)

Severity: Minor
Found in lib/routes/bins/run.js - 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 router has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function router (options) {
  var router = express.Router()

  var defaults = [mw.forwarded, mw.errorHandler, mw.bodyParser, null, mw.cors, mw.poweredBy, mw.negotiateContent]

Severity: Minor
Found in lib/index.js - About 1 hr to fix

Function createHar has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  createHar: function (req) {
    return {
      log: {
        version: '1.2',
        creator: {
Severity: Minor
Found in lib/utils.js - About 1 hr to fix

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

module.exports = function (req, res, next) {
  var mock = req.jsonBody

  // check for full HAR
  if (req.jsonBody && req.jsonBody.response) {
Severity: Minor
Found in lib/routes/bins/create.js - 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 redirect has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function redirect (req, res, next) {
  var count = req.params.count ? parseInt(req.params.count, 10) : 1
  var status = parseInt(req.params.status_code, 10) || 302
  var valid = [300, 301, 302, 303, 307, 308]

Severity: Minor
Found in lib/routes/redirect.js - 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

Severity
Category
Status
Source
Language