RocketChat/Rocket.Chat

View on GitHub

Showing 8,229 of 8,229 total issues

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

describe('context', () => {
    it('renders plain text', () => {
        const payload = [
            {
                type: 'context',
Severity: Major
Found in packages/ui-kit/src/surfaces/banner/UiKitParserBanner.spec.ts and 4 other locations - About 3 days to fix
packages/ui-kit/src/surfaces/attachment/UiKitParserAttachment.spec.ts on lines 1145..1318
packages/ui-kit/src/surfaces/contextualBar/UiKitParserContextualBar.spec.ts on lines 1203..1376
packages/ui-kit/src/surfaces/message/UiKitParserMessage.spec.ts on lines 1145..1318
packages/ui-kit/src/surfaces/modal/UiKitParserModal.spec.ts on lines 1203..1376

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 652.

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 5 locations. Consider refactoring.
Open

describe('context', () => {
    it('renders plain text', () => {
        const payload = [
            {
                type: 'context',
packages/ui-kit/src/surfaces/attachment/UiKitParserAttachment.spec.ts on lines 1145..1318
packages/ui-kit/src/surfaces/banner/UiKitParserBanner.spec.ts on lines 1202..1375
packages/ui-kit/src/surfaces/contextualBar/UiKitParserContextualBar.spec.ts on lines 1203..1376
packages/ui-kit/src/surfaces/modal/UiKitParserModal.spec.ts on lines 1203..1376

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 652.

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 5 locations. Consider refactoring.
Open

describe('context', () => {
    it('renders plain text', () => {
        const payload = [
            {
                type: 'context',
packages/ui-kit/src/surfaces/attachment/UiKitParserAttachment.spec.ts on lines 1145..1318
packages/ui-kit/src/surfaces/banner/UiKitParserBanner.spec.ts on lines 1202..1375
packages/ui-kit/src/surfaces/message/UiKitParserMessage.spec.ts on lines 1145..1318
packages/ui-kit/src/surfaces/modal/UiKitParserModal.spec.ts on lines 1203..1376

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 652.

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

Function createAccountSettings has 762 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    settingsRegistry.addGroup('Accounts', async function () {
        await this.section('Two Factor Authentication', async function () {
            const enable2FA = {
                _id: 'Accounts_TwoFactorAuthentication_Enabled',
                value: true,
Severity: Major
Found in apps/meteor/server/settings/accounts.ts - About 3 days to fix

    File UiKitParserMessage.spec.ts has 1388 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { BlockContext } from '../../rendering/BlockContext';
    import { UiKitParserMessage } from './UiKitParserMessage';
    import { uiKitMessage } from './uiKitMessage';
    
    class TestParser extends UiKitParserMessage<unknown> {
    Severity: Major
    Found in packages/ui-kit/src/surfaces/message/UiKitParserMessage.spec.ts - About 3 days to fix

      File UiKitParserAttachment.spec.ts has 1388 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { BlockContext } from '../../rendering/BlockContext';
      import { UiKitParserAttachment } from './UiKitParserAttachment';
      import { uiKitAttachment } from './uiKitAttachment';
      
      class TestParser extends UiKitParserAttachment<unknown> {
      Severity: Major
      Found in packages/ui-kit/src/surfaces/attachment/UiKitParserAttachment.spec.ts - About 3 days to fix

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

        describe('prerelease version', () => {
            it('should not suggest available version the highest version is a prerelease from a different tag', () => {
                const status = getVersionStatus('3.0.0', [
                    {
                        version: '3.0.0',
        apps/meteor/client/lib/VideoConfManager.ts on lines 581..586

        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 611.

        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

        File setup-wizard.ts has 1352 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { settingsRegistry } from '../../app/settings/server';
        
        export const createSetupWSettings = () =>
            settingsRegistry.addGroup('Setup_Wizard', async function () {
                await this.section('Organization_Info', async function () {
        Severity: Major
        Found in apps/meteor/server/settings/setup-wizard.ts - About 3 days to fix

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

          export const findWeeklyUsersRegisteredData = async ({
              start,
              end,
          }: {
              start: Date;
          Severity: Major
          Found in apps/meteor/ee/server/lib/engagementDashboard/users.ts and 1 other location - About 3 days to fix
          apps/meteor/ee/server/lib/engagementDashboard/messages.ts on lines 58..108

          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 572.

          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

          export const findWeeklyMessagesSentData = async ({
              start,
              end,
          }: {
              start: Date;
          Severity: Major
          Found in apps/meteor/ee/server/lib/engagementDashboard/messages.ts and 1 other location - About 3 days to fix
          apps/meteor/ee/server/lib/engagementDashboard/users.ts on lines 43..90

          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 572.

          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

          File channels.ts has 1207 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { Team, Room } from '@rocket.chat/core-services';
          import type { IRoom, ISubscription, IUser, RoomType, IUpload } from '@rocket.chat/core-typings';
          import { Integrations, Messages, Rooms, Subscriptions, Uploads, Users } from '@rocket.chat/models';
          import {
              isChannelsAddAllProps,
          Severity: Major
          Found in apps/meteor/app/api/server/v1/channels.ts - About 3 days to fix

            File rest.ts has 1071 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { AppStatus, AppStatusUtils } from '@rocket.chat/apps-engine/definition/AppStatus';
            import type { IAppInfo } from '@rocket.chat/apps-engine/definition/metadata';
            import type { AppManager } from '@rocket.chat/apps-engine/server/AppManager';
            import { AppInstallationSource } from '@rocket.chat/apps-engine/server/storage';
            import type { IUser, IMessage } from '@rocket.chat/core-typings';
            Severity: Major
            Found in apps/meteor/ee/server/apps/communication/rest.ts - About 2 days to fix

              File users.ts has 1060 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { MeteorError, Team, api } from '@rocket.chat/core-services';
              import type { IExportOperation, ILoginToken, IPersonalAccessToken, IUser, UserStatus } from '@rocket.chat/core-typings';
              import { Users, Subscriptions } from '@rocket.chat/models';
              import {
                  isUserCreateParamsPOST,
              Severity: Major
              Found in apps/meteor/app/api/server/v1/users.ts - About 2 days to fix

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

                    async Avg_reaction_time(from: moment.Moment, to: moment.Moment, departmentId?: string, extraQuery: Filter<IOmnichannelRoom> = {}) {
                        const agentAvgReactionTime = new Map(); // stores avg reaction time for each agent
                        const date = {
                            gte: from.toDate(),
                            lt: to.add(1, 'days').toDate(),
                apps/meteor/server/services/omnichannel-analytics/AgentData.ts on lines 219..267
                apps/meteor/server/services/omnichannel-analytics/AgentData.ts on lines 311..359

                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 463.

                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 Avg_response_time(from: moment.Moment, to: moment.Moment, departmentId?: string, extraQuery: Filter<IOmnichannelRoom> = {}) {
                        const agentAvgRespTime = new Map(); // stores avg response time for each agent
                        const date = {
                            gte: from.toDate(),
                            lt: to.add(1, 'days').toDate(),
                apps/meteor/server/services/omnichannel-analytics/AgentData.ts on lines 219..267
                apps/meteor/server/services/omnichannel-analytics/AgentData.ts on lines 361..409

                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 463.

                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 Avg_first_response_time(from: moment.Moment, to: moment.Moment, departmentId?: string, extraQuery: Filter<IOmnichannelRoom> = {}) {
                        const agentAvgRespTime = new Map(); // stores avg response time for each agent
                        const date = {
                            gte: from.toDate(),
                            lt: to.add(1, 'days').toDate(),
                apps/meteor/server/services/omnichannel-analytics/AgentData.ts on lines 311..359
                apps/meteor/server/services/omnichannel-analytics/AgentData.ts on lines 361..409

                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 463.

                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

                File groups.ts has 1047 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { Team, isMeteorError } from '@rocket.chat/core-services';
                import type { IIntegration, IUser, IRoom, RoomType } from '@rocket.chat/core-typings';
                import { Integrations, Messages, Rooms, Subscriptions, Uploads, Users } from '@rocket.chat/models';
                import { check, Match } from 'meteor/check';
                import { Meteor } from 'meteor/meteor';
                Severity: Major
                Found in apps/meteor/app/api/server/v1/groups.ts - About 2 days to fix

                  Function createEmailSettings has 527 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      settingsRegistry.addGroup('Email', async function () {
                          await this.section('Style', async function () {
                              await this.add('email_plain_text_only', false, {
                                  type: 'boolean',
                              });
                  Severity: Major
                  Found in apps/meteor/server/settings/email.ts - About 2 days to fix

                    RoomsRaw has 132 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    export class RoomsRaw extends BaseRaw<IRoom> implements IRoomsModel {
                        constructor(db: Db, trash?: Collection<RocketChatRecordDeleted<IRoom>>) {
                            super(db, 'room', trash);
                        }
                    
                    
                    Severity: Major
                    Found in apps/meteor/server/models/raw/Rooms.ts - About 2 days to fix

                      File SlackAdapter.js has 975 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import http from 'http';
                      import https from 'https';
                      import url from 'url';
                      
                      import { Message } from '@rocket.chat/core-services';
                      Severity: Major
                      Found in apps/meteor/app/slackbridge/server/SlackAdapter.js - About 2 days to fix
                        Severity
                        Category
                        Status
                        Source
                        Language