Showing 66 of 301 total issues
Function login
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
login(user: UserDocument, req): Promise<IUser> {
return new Promise((resolve, reject) => {
// Calls the login function (which goes to passport)
req.login(user, (err) => {
if (err) {
Function auditCopy
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
UserSchema.methods.auditCopy = function (userIP?: string) {
const toReturn: Record<string, unknown> = {};
const asObject = this.toObject();
Function containsSearchPlugin
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function containsSearchPlugin<
EnforcedDocType,
TModelType,
TInstanceMethods
>(
Function requiresRoleHelper
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const requiresRoleHelper = (method, testFunction) => {
describe(method, () => {
it('user not found', async () => {
sandbox.stub(teamsService, 'meetsRoleRequirement').resolves();
Avoid deeply nested control flow statements. Open
if (implicitFilter) {
query.$or.push(implicitFilter);
}
Avoid deeply nested control flow statements. Open
if (isExternal) {
_.remove(query.$or, (filter) => filter[`roles.${role}`]);
}
Avoid deeply nested control flow statements. Open
if (implicitFilter) {
query.$or.push(implicitFilter);
}
Function welcomeWithAccessEmail
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
async welcomeWithAccessEmail(user: UserDocument, req) {
if (!config.get('coreEmails.welcomeWithAccess.enabled')) {
return;
}
- 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 defaultErrorHandler
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export const defaultErrorHandler: ErrorRequestHandler = (
err,
req,
res,
next
- 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 getHttpsOptions
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
getHttpsOptions() {
if (!this.options) {
this.options = {
host: this.config.hostname,
port: this.config.port,
- 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 payloadHandler
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
payloadHandler(topic: string, message: MessageType) {
// Gracefully handle empty messages by ignoring and logging
if (null == message) {
logger.warn(
`${this.constructor.name}: Ignoring empty message ${message}`
- 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 search
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export const search = async function (req, res) {
const search = req.body.s || null;
let query = req.body.q || {};
query = util.toMongoose(query);
- 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 rollbackMigrations
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const rollbackMigrations = async () => {
logger.silent = process.argv?.[3] !== '--logger';
logger.info('Started migration rollback...');
const db = await mongoose.connect();
- 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 null;
Avoid too many return
statements within this function. Open
return Promise.reject(
new Error(
`Error retrieving entry from the access checker provider: ${ex.message}`
)
);
Avoid too many return
statements within this function. Open
return done(null, primaryUser);
Avoid too many return
statements within this function. Open
return done(null, false, err);
Avoid too many return
statements within this function. Open
return done(
null,
false,
new UnauthorizedError(
'Could not authenticate request, please verify your credentials.'
Avoid too many return
statements within this function. Open
return parsed;
Function dateParse
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export const dateParse = function (
// eslint-disable-next-line @typescript-eslint/ban-types
date: string | number | Date | Array<unknown> | Function | Object
) {
// Handle nil values, arrays, and functions by simply returning null
- 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"