Showing 66 of 301 total issues
File teams.service.spec.ts
has 1442 lines of code (exceeds 250 allowed). Consider refactoring. Open
import _ from 'lodash';
import mongoose from 'mongoose';
import should from 'should';
import { assert, createSandbox } from 'sinon';
File teams.service.ts
has 648 lines of code (exceeds 250 allowed). Consider refactoring. Open
import _ from 'lodash';
import mongoose, { FilterQuery, PopulateOptions, Types } from 'mongoose';
import {
TeamRoleImplicit,
File user-authentication.controller.spec.ts
has 554 lines of code (exceeds 250 allowed). Consider refactoring. Open
import _ from 'lodash';
import { DateTime } from 'luxon';
import passport from 'passport';
import should from 'should';
import { assert, createSandbox } from 'sinon';
File util.service.spec.ts
has 534 lines of code (exceeds 250 allowed). Consider refactoring. Open
import should from 'should';
import { utilService } from '../../dependencies';
/**
Function updateMemberFilter
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
updateMemberFilter(query: FilterQuery<UserDocument>, team: TeamDocument) {
// Extract member types and roles for filtering
const types = query.$and?.find((filter) => filter.type)?.type.$in ?? [];
const roles: TeamRoles[] =
query.$and?.find((filter) => filter.role)?.role.$in ?? [];
- 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
File user.model.ts
has 334 lines of code (exceeds 250 allowed). Consider refactoring. Open
import crypto, { BinaryLike } from 'crypto';
import _ from 'lodash';
import mongoose, {
HydratedDocument,
TeamsService
has 32 functions (exceeds 20 allowed). Consider refactoring. Open
class TeamsService {
constructor(
private model: TeamModel,
private userModel: UserModel
) {}
File teams.controller.spec.ts
has 312 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { Request } from 'express';
import should from 'should';
import { assert, createSandbox, match, stub } from 'sinon';
import { Team, TeamDocument } from './team.model';
File default.js
has 287 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
const contactEmail = process.env.CONTACT_EMAIL || 'noreply@bluehalo.com';
module.exports = {
File user-authorization.service.spec.ts
has 282 lines of code (exceeds 250 allowed). Consider refactoring. Open
import mongoose from 'mongoose';
import should from 'should';
import { createSandbox } from 'sinon';
import userAuthorizationService from './user-authorization.service';
Function getImplicitTeamIds
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getImplicitTeamIds(
user: IUser,
...roles: TeamRoles[]
): Promise<Types.ObjectId[]> {
// Validate the user input
Function verify
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
async verify(req, [primaryUserDn, proxiedUserDn, masqueradeUserDn], done) {
// If there is no DN, we can't authenticate
if (!primaryUserDn) {
return done(null, false, new BadRequestError('Missing certificate'));
}
File user.model.spec.ts
has 269 lines of code (exceeds 250 allowed). Consider refactoring. Open
import * as assert from 'assert';
import { Types } from 'mongoose';
import should from 'should';
File user.controller.spec.ts
has 267 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { assert, createSandbox } from 'sinon';
import userAuthorizationService from './auth/user-authorization.service';
import * as userController from './user.controller';
import { User } from './user.model';
Function initSwaggerAPI
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initSwaggerAPI(app: Express) {
// apiDocs must be enabled explicitly in the config
if (config.get<boolean>('apiDocs.enabled') !== true) {
return;
}
Function updateMemberFilter
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
updateMemberFilter(query: FilterQuery<UserDocument>, team: TeamDocument) {
// Extract member types and roles for filtering
const types = query.$and?.find((filter) => filter.type)?.type.$in ?? [];
const roles: TeamRoles[] =
query.$and?.find((filter) => filter.role)?.role.$in ?? [];
Function updateUserFilter
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
updateUserFilter(query: FilterQuery<UserDocument>) {
if (this.provider) {
// Update role filters based on roleStrategy
const strategy = this.getRoleStrategy();
const isExternal = strategy === 'external';
- 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 16 (exceeds 5 allowed). Consider refactoring. Open
async verify(req, [primaryUserDn, proxiedUserDn, masqueradeUserDn], done) {
// If there is no DN, we can't authenticate
if (!primaryUserDn) {
return done(null, false, new BadRequestError('Missing certificate'));
}
- 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 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const connect = async () => {
// Set the mongoose debugging option based on the configuration, defaulting to false
const mongooseDebug = config.get('mongooseLogging');
logger.info(`Mongoose: Setting debug to ${mongooseDebug}`);
Function adminGetCSV
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const adminGetCSV = (req, res) => {
const exportConfig = req.exportConfig as IExportConfig;
const exportQuery = req.exportQuery as FilterQuery<UserDocument>;
const fileName = `${config.get('app.instanceName')}-${exportConfig.type}.csv`;