kzwang/node-git-lfs

View on GitHub

Showing 4 of 10 total issues

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

module.exports = function(app) {
    app.post('/:user/:repo/objects/batch', wrap(function* (req, res, next) {
        // validate request body according to JSON Schema
        try {
            var body = yield parse.json(req);
Severity: Major
Found in lib/routes/batch.js - About 2 hrs to fix

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

    var checkJWT = function(action) {
        return wrap(function*(req, res, next) {
            let user = req.params.user;
            let repo = req.params.repo;
            let oid = req.params.oid;
    Severity: Minor
    Found in lib/routes/objects.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 7 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = function(app) {
        app.post('/:user/:repo/objects/verify', checkJWT('verify'), wrap(function* (req, res, next) {
            try {
                var body = yield parse.json(req);
    
    
    Severity: Minor
    Found in lib/routes/verify.js - About 35 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

    Avoid too many return statements within this function.
    Open

                            return res.status(403).end();
    Severity: Major
    Found in lib/routes/batch.js - About 30 mins to fix
      Severity
      Category
      Status
      Source
      Language