Showing 55 of 191 total issues
Function sendToWebhook
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function sendToWebhook(
webhookEndpoint: HttpsUrl,
message: NewMessageWithoutContent,
content: MessageContent,
senderMetadata: CreatedMessageEventSenderMetadata
Function handleMessage
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export async function handleMessage(
lProfileModel: ProfileModel,
lMessageModel: MessageModel,
lNotificationModel: NotificationModel,
lSenderServiceModel: SenderServiceModel,
- 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 updateExistingProfileFromPayload
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function updateExistingProfileFromPayload(
profileModel: ProfileModel,
existingProfile: RetrievedProfile,
profileModelPayload: ExtendedProfile
): Promise<
Function GetProfileHandler
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function GetProfileHandler(
profileModel: ProfileModel
): IGetProfileHandler {
return async (auth, _, userAttributes, fiscalCode) => {
const errorOrMaybeProfile = await profileModel.findOneProfileByFiscalCode(
Function index
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function index(context: Context): Promise<void | IOutputBindings> {
const logLevel = isProduction ? "info" : "debug";
configureAzureContextTransport(context, winston, logLevel);
try {
// iterate over the whole services collection and collect visible services
Function reduceServicesToVisibleServices
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function reduceServicesToVisibleServices(
visibleServicesObj: StrMap<VisibleService>,
service: RetrievedService
): StrMap<VisibleService> {
// we use an in-memory object (map)
Function handleMessage
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
lProfileModel: ProfileModel,
lMessageModel: MessageModel,
lNotificationModel: NotificationModel,
lSenderServiceModel: SenderServiceModel,
lBlobService: BlobService,
Function index
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export async function index(
context: ContextWithBindings,
event: IProfileCreatedEvent | IProfileUpdatedEvent
): Promise<void> {
const logLevel = isProduction ? "info" : "debug";
- 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 GetMessage
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
serviceModel: ServiceModel,
messageModel: MessageModel,
messageStatusModel: MessageStatusModel,
notificationModel: NotificationModel,
notificationStatusModel: NotificationStatusModel,
Function handleQueueProcessingFailure
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
queueService: QueueService,
queueMessageBindings: Context["bindings"],
queueName: string,
onTransientError: (error: RuntimeError) => Promise<Either<RuntimeError, {}>>,
onPermanentError: (error: RuntimeError) => Promise<Either<RuntimeError, {}>>,
Function GetMessageHandler
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
messageModel: MessageModel,
messageStatusModel: MessageStatusModel,
notificationModel: NotificationModel,
notificationStatusModel: NotificationStatusModel,
blobService: BlobService
Function handleNotification
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
lMailerTransporter: NodeMailer.Transporter,
lAppInsightsClient: TelemetryClient,
lNotificationModel: NotificationModel,
emailNotificationEvent: NotificationEvent,
notificationDefaultParams: INotificationDefaults
Function createNotification
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
lNotificationModel: NotificationModel,
senderMetadata: CreatedMessageEventSenderMetadata,
newMessageWithoutContent: NewMessageWithoutContent,
newMessageContent: MessageContent,
newNotification: NewNotification
Function sendWelcomeMessages
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
apiUrl: string,
apiKey: string,
messages: WelcomeMessages,
fiscalCode: FiscalCode,
profile: ExtendedProfile
Function getMessageNotificationStatuses
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
async function getMessageNotificationStatuses(
notificationModel: NotificationModel,
notificationStatusModel: NotificationStatusModel,
messageId: NonEmptyString
): Promise<Either<Error, Option<NotificationStatusHolder>>> {
- 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 left<RuntimeError, OutputBindings>(errorOrNotificationEvent.value);
Avoid too many return
statements within this function. Open
return right<RuntimeError, NotificationEvent>(webhookNotificationEvent);
Avoid too many return
statements within this function. Open
return ResponseSuccessRedirectToResource(
newMessageWithoutContent,
`/api/v1/messages/${fiscalCode}/${newMessageWithoutContent.id}`,
{ id: newMessageWithoutContent.id }
);
Avoid too many return
statements within this function. Open
return right<RuntimeError, OutputBindings>({});
Avoid too many return
statements within this function. Open
return left<RuntimeError, NotificationEvent>(
TransientError(
`Error while sending email|notification=${notificationId}|message=${
message.id
}|error=${error.message}`