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()
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') {
- Read upRead up
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
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
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') {
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 || {})
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()
- Read upRead up
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
- Read upRead up
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 !'))
}
- Read upRead up
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.reject(new Error('You need to change the default token !'))
Avoid too many return
statements within this function. Open
return Promise.all([
lib.Validator.validatePassportsConfig(this.app.config.passport)
])