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('actions', () => {
    it('renders all selects', () => {
        const payload = [
            {
                type: 'actions',
packages/ui-kit/src/surfaces/attachment/UiKitParserAttachment.spec.ts on lines 795..1143
packages/ui-kit/src/surfaces/banner/UiKitParserBanner.spec.ts on lines 852..1200
packages/ui-kit/src/surfaces/contextualBar/UiKitParserContextualBar.spec.ts on lines 853..1201
packages/ui-kit/src/surfaces/message/UiKitParserMessage.spec.ts on lines 795..1143

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

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 Users.js has 2523 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { ILivechatAgentStatus } from '@rocket.chat/core-typings';
import { Subscriptions } from '@rocket.chat/models';
import { escapeRegExp } from '@rocket.chat/string-helpers';

import { BaseRaw } from './BaseRaw';
Severity: Major
Found in apps/meteor/server/models/raw/Users.js - About 1 wk to fix

    File LivechatRooms.ts has 2492 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import type {
        IOmnichannelRoom,
        RocketChatRecordDeleted,
        IOmnichannelRoomClosingInfo,
        DeepWritable,
    Severity: Major
    Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 6 days to fix

      Function createSetupWSettings has 1348 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          settingsRegistry.addGroup('Setup_Wizard', async function () {
              await this.section('Organization_Info', async function () {
                  await this.add('Organization_Type', '', {
                      type: 'select',
                      values: [
      Severity: Major
      Found in apps/meteor/server/settings/setup-wizard.ts - About 6 days to fix

        Function addManagementRoutes has a Cognitive Complexity of 274 (exceeds 5 allowed). Consider refactoring.
        Open

            addManagementRoutes() {
                const orchestrator = this._orch;
                const manager = this._manager;
        
                const handleError = (message: string, e: any) => {
        Severity: Minor
        Found in apps/meteor/ee/server/apps/communication/rest.ts - About 5 days 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

        File emojiPicker.ts has 1943 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /*
         * This file is automatically generated from generateEmojiIndex.mjs
         * Last generated Tue Apr 09 2019 15:27:21 GMT-0300 (-03)
         *
         * Mapping category hashes into human readable and translated names
        Severity: Major
        Found in apps/meteor/app/emoji-emojione/lib/emojiPicker.ts - About 5 days to fix

          Function addManagementRoutes has 1017 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              addManagementRoutes() {
                  const orchestrator = this._orch;
                  const manager = this._manager;
          
                  const handleError = (message: string, e: any) => {
          Severity: Major
          Found in apps/meteor/ee/server/apps/communication/rest.ts - About 5 days to fix

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

            import type { OverflowElement } from '../../blocks/elements/OverflowElement';
            import type { PlainText } from '../../blocks/text/PlainText';
            import { BlockContext } from '../../rendering/BlockContext';
            import { UiKitParserModal } from './UiKitParserModal';
            import { uiKitModal } from './uiKitModal';
            Severity: Major
            Found in packages/ui-kit/src/surfaces/modal/UiKitParserModal.spec.ts - About 5 days to fix

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

              import type { OverflowElement } from '../../blocks/elements/OverflowElement';
              import type { PlainText } from '../../blocks/text/PlainText';
              import { BlockContext } from '../../rendering/BlockContext';
              import { UiKitParserContextualBar } from './UiKitParserContextualBar';
              import { uiKitContextualBar } from './uiKitContextualBar';

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

                import type { PlainText } from '../../blocks/text/PlainText';
                import { BlockContext } from '../../rendering/BlockContext';
                import { UiKitParserBanner } from './UiKitParserBanner';
                import { uiKitBanner } from './uiKitBanner';
                
                
                Severity: Major
                Found in packages/ui-kit/src/surfaces/banner/UiKitParserBanner.spec.ts - About 5 days to fix

                  File Rooms.ts has 1675 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import type {
                      IDirectMessageRoom,
                      IMessage,
                      IOmnichannelGenericRoom,
                      IRoom,
                  Severity: Major
                  Found in apps/meteor/server/models/raw/Rooms.ts - About 4 days to fix

                    File wordList.ts has 1635 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    export default [
                        'acrobat',
                        'africa',
                        'alaska',
                        'albert',
                    Severity: Major
                    Found in apps/meteor/app/e2e/client/wordList.ts - About 4 days to fix

                      UsersRaw has 215 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      export class UsersRaw extends BaseRaw {
                          constructor(db, trash) {
                              super(db, 'users', trash, {
                                  collectionNameResolver(name) {
                                      return name;
                      Severity: Major
                      Found in apps/meteor/server/models/raw/Users.js - About 4 days to fix

                        File Messages.ts has 1533 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import type {
                            ILivechatDepartment,
                            IMessage,
                            IRoom,
                            IUser,
                        Severity: Major
                        Found in apps/meteor/server/models/raw/Messages.ts - About 4 days to fix

                          File Sessions.ts has 1508 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import type {
                              ISession,
                              UserSessionAggregation,
                              DeviceSessionAggregation,
                              OSSessionAggregation,
                          Severity: Major
                          Found in apps/meteor/server/models/raw/Sessions.ts - About 4 days to fix

                            File Subscriptions.ts has 1466 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import type {
                                AtLeast,
                                IRole,
                                IRoom,
                                ISubscription,
                            Severity: Major
                            Found in apps/meteor/server/models/raw/Subscriptions.ts - About 3 days to fix

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

                              const ChannelDeletionTable = ({ rooms, onChangeRoomSelection, selectedRooms, onToggleAllRooms }: ChannelDeletationTable) => {
                                  const t = useTranslation();
                                  const { sortBy, sortDirection, setSort } = useSort<'name' | 'usersCount'>('name');
                              
                                  const selectedRoomsLength = Object.values(selectedRooms).filter(Boolean).length;
                              apps/meteor/client/views/teams/contextualBar/info/Delete/ChannelDeletionTable.tsx on lines 17..76

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

                              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 ChannelDeletionTable = ({ rooms, onChangeRoomSelection, selectedRooms, onToggleAllRooms }: ChannelDeletationTable) => {
                                  const t = useTranslation();
                                  const { sortBy, sortDirection, setSort } = useSort<'name' | 'usersCount'>('name');
                              
                                  const selectedRoomsLength = Object.values(selectedRooms).filter(Boolean).length;
                              apps/meteor/client/views/teams/contextualBar/info/DeleteTeam/ChannelDeletionTable/ChannelDeletionTable.tsx on lines 17..76

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

                              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/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/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',
                              Severity: Major
                              Found in packages/ui-kit/src/surfaces/modal/UiKitParserModal.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/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/message/UiKitParserMessage.spec.ts on lines 1145..1318

                              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

                              Severity
                              Category
                              Status
                              Source
                              Language