RocketChat/Rocket.Chat

View on GitHub
apps/meteor/client/lib/chats/flows/uploadFiles.ts

Summary

Maintainability
D
2 days
Test Coverage

Function uploadFiles has 155 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const uploadFiles = async (chat: ChatAPI, files: readonly File[], resetFileInput?: () => void): Promise<void> => {
    const replies = chat.composer?.quotedMessages.get() ?? [];

    const msg = await prependReplies('', replies);

Severity: Major
Found in apps/meteor/client/lib/chats/flows/uploadFiles.ts - About 6 hrs to fix

    Function uploadNextFile has 128 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        const uploadNextFile = (): void => {
            const file = queue.pop();
            if (!file) {
                chat.composer?.dismissAllQuotedMessages();
                return;
    Severity: Major
    Found in apps/meteor/client/lib/chats/flows/uploadFiles.ts - About 5 hrs to fix

      Function onSubmit has 107 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                      onSubmit: async (fileName: string, description?: string): Promise<void> => {
                          Object.defineProperty(file, 'name', {
                              writable: true,
                              value: fileName,
                          });
      Severity: Major
      Found in apps/meteor/client/lib/chats/flows/uploadFiles.ts - About 4 hrs to fix

        Function uploadFiles has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

        export const uploadFiles = async (chat: ChatAPI, files: readonly File[], resetFileInput?: () => void): Promise<void> => {
            const replies = chat.composer?.quotedMessages.get() ?? [];
        
            const msg = await prependReplies('', replies);
        
        
        Severity: Minor
        Found in apps/meteor/client/lib/chats/flows/uploadFiles.ts - About 3 hrs 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 getContent has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                                const getContent = async (_id: string, fileUrl: string): Promise<IE2EEMessage['content']> => {
                                    const attachments = [];
        
                                    const attachment: FileAttachmentProps = {
                                        title: file.name,
        Severity: Major
        Found in apps/meteor/client/lib/chats/flows/uploadFiles.ts - About 2 hrs to fix

          There are no issues that match your filters.

          Category
          Status