mvader/micro-auth

View on GitHub

Showing 5 of 7 total issues

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

module.exports = function (TokenModel, UserModel, options) {
    options = options || {};

    /**
     * Handler for signing the user up if there is no account associated with the given username or sign the user in in
Severity: Major
Found in lib/controllers.js - About 3 hrs to fix

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

    module.exports = function (TokenModel, UserModel, options) {
        options = options || {};
    
        /**
         * Handler for signing the user up if there is no account associated with the given username or sign the user in in
    Severity: Minor
    Found in lib/controllers.js - About 3 hrs 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 loginOrSignup has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        var loginOrSignup = function (req, res, next) {
            var createToken = function (user) {
                    TokenModel.create(TokenModel.newToken(user._id), function (err, token) {
                        if (err) next(err);
    
    
    Severity: Minor
    Found in lib/controllers.js - About 1 hr to fix

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

      function createUserModel(options) {
          options = options || {};
      
          var userSchema = new Schema(_.merge({
              username: {type: String, trim: true},
      Severity: Minor
      Found in lib/user.js - About 1 hr to fix

        Function addMethods has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        function addMethods(schema, options, kind) {
            if (options[kind] && typeof options[kind] === 'object') {
                for (var name in options[kind]) {
                    if (options[kind].hasOwnProperty(name) && typeof options[kind][name] === 'function') {
                        schema[kind][name] = options[kind][name];
        Severity: Minor
        Found in lib/util.js - About 45 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