jaumard/trailpack-passport

View on GitHub

Showing 11 of 15 total issues

Function init has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  init: (app) => {
    const passport = app.services.PassportService.passport
    app.config.web.middlewares.passportInit = passport.initialize()
    app.config.web.middlewares.passportSession = passport.session()

Severity: Major
Found in lib/passports.js - About 3 hrs to fix

    Function callback has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

      callback(req, res, next) {
        const provider = req.params.provider || 'local'
        const action = req.params.action
    
        if (provider === 'local') {
    Severity: Minor
    Found in api/services/PassportService.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 connect has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        passport.connect = function (req, query, profile, next) {
          const user = {}
    
          // Get the authentication provider from the query.
          query.provider = req.params.provider
    Severity: Major
    Found in lib/passports.js - About 2 hrs to fix

      Function callback has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        callback(req, res) {
          this.app.services.PassportService.callback(req, res, (err, user, challenges, statuses) => {
            if (err) {
              if (err.code === 'E_USER_NOT_FOUND') {
                req.err = err
      Severity: Minor
      Found in api/controllers/AuthController.js - About 1 hr to fix

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

          callback(req, res, next) {
            const provider = req.params.provider || 'local'
            const action = req.params.action
        
            if (provider === 'local') {
        Severity: Minor
        Found in api/services/PassportService.js - About 1 hr to fix

          Function loadStrategies has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            loadStrategies: (app) => {
              const passport = app.services.PassportService.passport
              _.each(app.config.passport.strategies, (strategiesOptions, name) => {
                  const Strategy = strategiesOptions.strategy
                  const options = _.extend({ passReqToCallback: true }, strategiesOptions.options || {})
          Severity: Minor
          Found in lib/passports.js - About 1 hr to fix

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

              init: (app) => {
                const passport = app.services.PassportService.passport
                app.config.web.middlewares.passportInit = passport.initialize()
                app.config.web.middlewares.passportSession = passport.session()
            
            
            Severity: Minor
            Found in lib/passports.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 validate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              validate() {
                if (!_.includes(_.keys(this.app.packs), 'express')) {
                  return Promise.reject(new Error('This Trailpack work only for express !'))
                }
            
            
            Severity: Minor
            Found in index.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

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

            module.exports = (bcrypt, passport, next) => {
              if (passport.password) {
                if (next) {
                  bcrypt.hash(passport.password, 10, (err, hash) => {
                    passport.password = hash
            Severity: Minor
            Found in api/models/hashPassword.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

            Avoid too many return statements within this function.
            Open

                return Promise.all([
                  lib.Validator.validatePassportsConfig(this.app.config.passport)
                ])
            Severity: Major
            Found in index.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return Promise.reject(new Error('You need to change the default token !'))
              Severity: Major
              Found in index.js - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language