teamdigitale/digital-citizenship-functions

View on GitHub

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
Severity: Minor
Found in lib/webhook_queue_handler.ts - About 1 hr to fix

    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,
    Severity: Minor
    Found in lib/created_message_queue_handler.ts - About 1 hr to fix

    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<
    Severity: Minor
    Found in lib/controllers/profiles.ts - About 1 hr to fix

      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(
      Severity: Minor
      Found in lib/controllers/profiles.ts - About 1 hr to fix

        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
        Severity: Minor
        Found in lib/compute_visible_services.ts - About 1 hr to fix

          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)
          Severity: Minor
          Found in lib/compute_visible_services.ts - About 1 hr to fix

            Function handleMessage has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              lProfileModel: ProfileModel,
              lMessageModel: MessageModel,
              lNotificationModel: NotificationModel,
              lSenderServiceModel: SenderServiceModel,
              lBlobService: BlobService,
            Severity: Major
            Found in lib/created_message_queue_handler.ts - About 50 mins to fix

              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";
              Severity: Minor
              Found in lib/profile_events_queue_handler.ts - About 45 mins to fix

              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,
              Severity: Minor
              Found in lib/controllers/messages.ts - About 45 mins to fix

                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, {}>>,
                Severity: Minor
                Found in lib/utils/azure_queues.ts - About 45 mins to fix

                  Function GetMessageHandler has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    messageModel: MessageModel,
                    messageStatusModel: MessageStatusModel,
                    notificationModel: NotificationModel,
                    notificationStatusModel: NotificationStatusModel,
                    blobService: BlobService
                  Severity: Minor
                  Found in lib/controllers/messages.ts - About 35 mins to fix

                    Function handleNotification has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      lMailerTransporter: NodeMailer.Transporter,
                      lAppInsightsClient: TelemetryClient,
                      lNotificationModel: NotificationModel,
                      emailNotificationEvent: NotificationEvent,
                      notificationDefaultParams: INotificationDefaults
                    Severity: Minor
                    Found in lib/emailnotifications_queue_handler.ts - About 35 mins to fix

                      Function createNotification has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        lNotificationModel: NotificationModel,
                        senderMetadata: CreatedMessageEventSenderMetadata,
                        newMessageWithoutContent: NewMessageWithoutContent,
                        newMessageContent: MessageContent,
                        newNotification: NewNotification
                      Severity: Minor
                      Found in lib/created_message_queue_handler.ts - About 35 mins to fix

                        Function sendWelcomeMessages has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                          apiUrl: string,
                          apiKey: string,
                          messages: WelcomeMessages,
                          fiscalCode: FiscalCode,
                          profile: ExtendedProfile
                        Severity: Minor
                        Found in lib/profile_events_queue_handler.ts - About 35 mins to fix

                          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>>> {
                          Severity: Minor
                          Found in lib/controllers/messages.ts - About 35 mins to fix

                          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);
                          Severity: Major
                          Found in lib/created_message_queue_handler.ts - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                              return right<RuntimeError, NotificationEvent>(webhookNotificationEvent);
                            Severity: Major
                            Found in lib/webhook_queue_handler.ts - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                  return ResponseSuccessRedirectToResource(
                                    newMessageWithoutContent,
                                    `/api/v1/messages/${fiscalCode}/${newMessageWithoutContent.id}`,
                                    { id: newMessageWithoutContent.id }
                                  );
                              Severity: Major
                              Found in lib/controllers/messages.ts - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                    return right<RuntimeError, OutputBindings>({});
                                Severity: Major
                                Found in lib/created_message_queue_handler.ts - About 30 mins to fix

                                  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}`
                                  Severity: Major
                                  Found in lib/emailnotifications_queue_handler.ts - About 30 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language