Function registerComplete
has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring. Open
authenticationController.registerComplete = async function (req, res) {
try {
// For the interstitials that respond, execute the callback with the form body
const data = await user.interstitials.get(req, req.session.registration);
const callbacks = data.interstitials.reduce((memo, cur) => {
- 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 localLogin
has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring. Open
authenticationController.localLogin = async function (req, username, password, next) {
if (!username) {
return next(new Error('[[error:invalid-username]]'));
}
- 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 register
has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring. Open
authenticationController.register = async function (req, res) {
const registrationType = meta.config.registrationType || 'normal';
if (registrationType === 'disabled') {
return res.sendStatus(403);
- 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 next(new Error('[[error:invalid-login-credentials]]'));
Avoid too many return
statements within this function. Open
return next(new Error('[[error:local-login-disabled]]'));
Function login
has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring. Open
authenticationController.login = async (req, res, next) => {
let { strategy } = await plugins.hooks.fire('filter:login.override', { req, strategy: 'local' });
if (!passport._strategy(strategy)) {
winston.error(`[auth/override] Requested login strategy "${strategy}" not found, reverting back to local login strategy.`);
strategy = '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"