RocketChat/Rocket.Chat

View on GitHub
apps/meteor/server/models/raw/ModerationReports.ts

Summary

Maintainability
F
4 days
Test Coverage

File ModerationReports.ts has 391 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import type {
    IMessage,
    IModerationAudit,
    IModerationReport,
    RocketChatRecordDeleted,
Severity: Minor
Found in apps/meteor/server/models/raw/ModerationReports.ts - About 5 hrs to fix

    Function findMessageReportsGroupedByUser has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        findMessageReportsGroupedByUser(
            latest: Date,
            oldest: Date,
            selector: string,
            pagination: PaginationParams<IModerationReport>,
    Severity: Major
    Found in apps/meteor/server/models/raw/ModerationReports.ts - About 2 hrs to fix

      Function findUserReports has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          findUserReports(
              latest: Date,
              oldest: Date,
              selector: string,
              pagination: PaginationParams<IModerationReport>,
      Severity: Minor
      Found in apps/meteor/server/models/raw/ModerationReports.ts - About 1 hr to fix

        Function getSearchQueryForSelector has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private getSearchQueryForSelector(selector?: string): any {
                const messageExistsQuery = { message: { $exists: true } };
                if (!selector) {
                    return messageExistsQuery;
                }
        Severity: Minor
        Found in apps/meteor/server/models/raw/ModerationReports.ts - About 1 hr to fix

          Function findReportedMessagesByReportedUserId has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              findReportedMessagesByReportedUserId(
                  userId: string,
                  selector: string,
                  pagination: PaginationParams<IModerationReport>,
                  options: FindOptions<IModerationReport> = {},
          Severity: Minor
          Found in apps/meteor/server/models/raw/ModerationReports.ts - About 1 hr to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                findReportsByMessageId(
                    messageId: string,
                    selector: string,
                    pagination: PaginationParams<IModerationReport>,
                    options: FindOptions<IModerationReport> = {},
            Severity: Major
            Found in apps/meteor/server/models/raw/ModerationReports.ts and 1 other location - About 5 hrs to fix
            apps/meteor/server/models/raw/ModerationReports.ts on lines 267..300

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 143.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                findUserReportsByReportedUserId(
                    userId: string,
                    selector: string,
                    pagination: PaginationParams<IModerationReport>,
                    options: FindOptions<IModerationReport> = {},
            Severity: Major
            Found in apps/meteor/server/models/raw/ModerationReports.ts and 1 other location - About 5 hrs to fix
            apps/meteor/server/models/raw/ModerationReports.ts on lines 302..335

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 143.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                async hideMessageReportsByMessageId(messageId: string, userId: string, reason: string, action: string): Promise<UpdateResult | Document> {
                    const query = {
                        'message._id': messageId,
                    };
            
            
            Severity: Major
            Found in apps/meteor/server/models/raw/ModerationReports.ts and 2 other locations - About 4 hrs to fix
            apps/meteor/server/models/raw/ModerationReports.ts on lines 352..364
            apps/meteor/server/models/raw/ModerationReports.ts on lines 366..379

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 118.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                async hideUserReportsByUserId(userId: string, moderatorId: string, reason: string, action: string): Promise<UpdateResult | Document> {
                    const query = {
                        'reportedUser._id': userId,
                    };
            
            
            Severity: Major
            Found in apps/meteor/server/models/raw/ModerationReports.ts and 2 other locations - About 4 hrs to fix
            apps/meteor/server/models/raw/ModerationReports.ts on lines 337..350
            apps/meteor/server/models/raw/ModerationReports.ts on lines 352..364

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 118.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                async hideMessageReportsByUserId(userId: string, moderatorId: string, reason: string, action: string): Promise<UpdateResult | Document> {
                    const query = {
                        'message.u._id': userId,
                    };
            
            
            Severity: Major
            Found in apps/meteor/server/models/raw/ModerationReports.ts and 2 other locations - About 4 hrs to fix
            apps/meteor/server/models/raw/ModerationReports.ts on lines 337..350
            apps/meteor/server/models/raw/ModerationReports.ts on lines 366..379

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 118.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    const query = {
                        _hidden: {
                            $ne: true,
                        },
                        ts: {
            Severity: Minor
            Found in apps/meteor/server/models/raw/ModerationReports.ts and 1 other location - About 35 mins to fix
            apps/meteor/server/models/raw/ModerationReports.ts on lines 147..156

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 46.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    const query = {
                        _hidden: {
                            $ne: true,
                        },
                        ts: {
            Severity: Minor
            Found in apps/meteor/server/models/raw/ModerationReports.ts and 1 other location - About 35 mins to fix
            apps/meteor/server/models/raw/ModerationReports.ts on lines 73..82

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 46.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            There are no issues that match your filters.

            Category
            Status