Mashape/mockbin

View on GitHub

Showing 16 of 32 total issues

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

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

    req.on("data", (chunk) => {
        req.bodyChunks.push(chunk);
Severity: Major
Found in lib/middleware/body-parser.js - About 4 hrs to fix

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

module.exports = (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 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = (client) => (req, res, next) => {
    client.get(`bin:${req.params.uuid}`, (err, value) => {
        if (err) {
            debug(err);

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

Function bins has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function bins(dsnStr) {
    // parse redis dsn
    const dsn = new URL(dsnStr);

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

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

    const processFormData = (event) => {
        const response = {
            status: "",
            statusText: "",
            httpVersion: "HTTP/1.1",
Severity: Major
Found in src/static/bin/create.js - About 2 hrs to fix

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

module.exports = (client) => (req, res, next) => {
    let mock = req.jsonBody;

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

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

module.exports = (client) => (req, res, next) => {
    const id = req.params.uuid;
    const path = req.params[0];
    const compoundId = id + path;

Severity: Minor
Found in lib/routes/bins/update.js - About 1 hr to fix

Function router has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

    const defaults = [
        mw.forwarded,
Severity: Minor
Found in lib/index.js - About 1 hr to fix

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

module.exports = (client) => (req, res, next) => {
    let mock = req.jsonBody;

    // check for full HAR
    if (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 exports has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = (options, done) => {
    if (!options) {
        throw Error("missing options");
    }

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

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

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

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

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

module.exports = function redirect(req, res, next) {
    let count = req.params.count ? parseInt(req.params.count, 10) : 1;
    const status = parseInt(req.params.status_code, 10) || 302;
    const 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

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

module.exports = (client) => (req, res, next) => {
    // compoundId allows us to provide paths in the id to resolve to a specific bin
    const compoundId = req.params.uuid + req.params[0];
    client.get(`bin:${compoundId}`, function (err, value) {
        if (err) {
Severity: Minor
Found in lib/routes/bins/run.js - About 1 hr to fix

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

module.exports = (client) => (req, res, next) => {
    const id = req.params.uuid;
    const path = req.params[0];
    const compoundId = id + path;

Severity: Minor
Found in lib/routes/bins/update.js - About 55 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 exports has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = (client) => (req, res, next) => {
    client.get(`bin:${req.params.uuid + req.params[0]}`, (err, value) => {
        if (err) {
            debug(err);

Severity: Minor
Found in lib/routes/bins/view.js - About 25 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 exports has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = (client) => (req, res, next) => {
    client.get(`bin:${req.params.uuid}`, (err, value) => {
        if (err) {
            debug(err);

Severity: Minor
Found in lib/routes/bins/sample.js - About 25 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