Showing 66 of 301 total issues
Function audit
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
async audit(
message: string,
eventType: string,
eventAction: string,
requestOrEventActor: Request | Promise<Partial<IUser>> | Partial<IUser>,
Function paginatePlugin
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function paginatePlugin<EnforcedDocType, TModelType, TInstanceMethods>(
schema: Schema<EnforcedDocType, TModelType, TInstanceMethods>
) {
schema.query['paginate'] = async function <DocType>(
this: Query<HydratedDocument<DocType>[], DocType>,
Function updateCurrentUser
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const updateCurrentUser = async (req, res) => {
// Make sure the user is logged in
if (null == req.user) {
throw new BadRequestError('User is not logged in');
}
Function rollbackMigrations
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
const rollbackMigrations = async () => {
logger.silent = process.argv?.[3] !== '--logger';
logger.info('Started migration rollback...');
const db = await mongoose.connect();
Function search
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
async search(
queryParams = {},
query: FilterQuery<TeamDocument> = {},
search = '',
user: UserDocument
Function createLogger
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createLogger(loggerName: string) {
const loggerConfig = config.get<IConfig>('logger').get<IConfig>(loggerName);
const options = {
format: combine(timestamp(), errors({ stack: true }), splat(), json()),
Function buildExportStream
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
const buildExportStream = (
data: Readable | unknown,
getRead: (unknown) => () => void,
transforms: Transform[] = []
) => {
Function verifyUser
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
async verifyUser(dn: string, req, isProxy = false) {
const dnLower = dn.toLowerCase();
const localUser = await this.userModel
.findOne({
Function authenticateAndLogin
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
authenticateAndLogin(req, res, next): Promise<IUser> {
return new Promise((resolve, reject) => {
// Attempt to authenticate the user using passport
passport.authenticate(
config.get('auth.strategy'),
Function init
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
async init(server: http.Server, db: Mongoose) {
// Load configured Socket Provider implementation
await this.loadSocketProvider();
// Initialize modules sockets
Function getImplicitTeamIds
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async getImplicitTeamIds(
user: IUser,
...roles: TeamRoles[]
): Promise<Types.ObjectId[]> {
// Validate the user input
- 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 sendMail
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
sendMail(mailOptions: MailOptions): Promise<void> {
return new Promise((resolve, reject) => {
const postData = this.transformMailOptions(mailOptions);
const options = this.getHttpsOptions();
options.path = this.config.paths.within;
Function generateMailOptions
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
async generateMailOptions(
user,
req,
emailTemplateConfig,
emailContentData = {},
Function requestNewTeam
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
async requestNewTeam(
org: string,
aoi: string,
description: string,
requester: UserDocument,
Function welcomeWithAccessEmail
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
async welcomeWithAccessEmail(user: UserDocument, req) {
if (!config.get('coreEmails.welcomeWithAccess.enabled')) {
return;
}
Function streamToCsv
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
streamToCsv(columns: ExportColumnDef[]): Transform {
// Create a stream to turn Mongo records into CSV rows
const stream = through2.obj((chunk, enc, callback) => {
const row = [];
Function updateRoles
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
updateRoles(user) {
if (this.provider) {
const strategy = this.getRoleStrategy();
const isHybrid = strategy === 'hybrid';
- 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 verify
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export const verify = (role) => {
return function (req, res, next) {
// Grab the Authentication header
const authentication = req.headers.authentication;
if (null == authentication) {
- 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 initMiddleware
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initMiddleware(app: Express) {
// Showing stack errors
app.set('showStackError', true);
// Should be placed before express.static
Function updateTeams
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
async updateTeams(user: IUser) {
const strategy = config.get('teams.implicitMembers.strategy');
const nestedTeamsEnabled = config.get<boolean>('teams.nestedTeams');
if (strategy === 'disabled' && !nestedTeamsEnabled) {