RocketChat/Rocket.Chat

View on GitHub
apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts

Summary

Maintainability
F
1 wk
Test Coverage

File saveRoomSettings.ts has 468 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Team } from '@rocket.chat/core-services';
import type { IRoom, IRoomWithRetentionPolicy, IUser, MessageTypesValues } from '@rocket.chat/core-typings';
import { TEAM_TYPE } from '@rocket.chat/core-typings';
import { Rooms, Users } from '@rocket.chat/models';
import type { ServerMethods } from '@rocket.chat/ui-contexts';
Severity: Minor
Found in apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts - About 7 hrs to fix

    Function saveRoomSettings has 74 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export async function saveRoomSettings(
        userId: IUser['_id'],
        rid: IRoom['_id'],
        settings: Partial<RoomSettings> | keyof RoomSettings,
        value?: RoomSettings[keyof RoomSettings],
    Severity: Major
    Found in apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts - About 2 hrs to fix

      settingSavers has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      const settingSavers: RoomSettingsSavers = {
          async roomName({ value, rid, user, room }) {
              if (!(await saveRoomName(rid, value, user))) {
                  return;
              }
      Severity: Minor
      Found in apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts - About 2 hrs to fix

        Function saveRoomSettings has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function saveRoomSettings(
            userId: IUser['_id'],
            rid: IRoom['_id'],
            settings: Partial<RoomSettings> | keyof RoomSettings,
            value?: RoomSettings[keyof RoomSettings],
        Severity: Minor
        Found in apps/meteor/app/channel-settings/server/methods/saveRoomSettings.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

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

            async retentionMaxAge({ userId, value, room, rid }) {
                if (!hasRetentionPolicy(room)) {
                    throw new Meteor.Error('error-action-not-allowed', 'Room does not have retention policy', {
                        method: 'saveRoomSettings',
                        action: 'Editing_room',
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 118..132
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 148..162
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 163..177
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 178..192

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

        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

            async retentionEnabled({ userId, value, room, rid }) {
                if (!hasRetentionPolicy(room)) {
                    throw new Meteor.Error('error-action-not-allowed', 'Room does not have retention policy', {
                        method: 'saveRoomSettings',
                        action: 'Editing_room',
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 133..147
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 148..162
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 163..177
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 178..192

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

        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

            async retentionExcludePinned({ userId, value, room, rid }) {
                if (!hasRetentionPolicy(room)) {
                    throw new Meteor.Error('error-action-not-allowed', 'Room does not have retention policy', {
                        method: 'saveRoomSettings',
                        action: 'Editing_room',
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 118..132
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 133..147
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 163..177
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 178..192

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

        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

            async retentionIgnoreThreads({ userId, value, room, rid }) {
                if (!hasRetentionPolicy(room)) {
                    throw new Meteor.Error('error-action-not-allowed', 'Room does not have retention policy', {
                        method: 'saveRoomSettings',
                        action: 'Editing_room',
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 118..132
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 133..147
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 148..162
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 163..177

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

        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

            async retentionFilesOnly({ userId, value, room, rid }) {
                if (!hasRetentionPolicy(room)) {
                    throw new Meteor.Error('error-action-not-allowed', 'Room does not have retention policy', {
                        method: 'saveRoomSettings',
                        action: 'Editing_room',
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 118..132
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 133..147
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 148..162
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 178..192

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

        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

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

            [TRoomSetting in keyof RoomSettings]?: (params: {
                userId: IUser['_id'];
                user: IUser & Required<Pick<IUser, 'username' | 'name'>>;
                value: RoomSettings[TRoomSetting];
                room: IRoom;
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 378..384

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

        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

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

            params: {
                userId: IUser['_id'];
                user: IUser & Required<Pick<IUser, 'username' | 'name'>>;
                value: RoomSettings[TRoomSetting];
                room: IRoom;
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 204..210

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

        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 roomTopic({ value, room, rid, user }) {
                if (!value && !room.topic) {
                    return;
                }
                if (value !== room.topic) {
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 235..242
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 248..255

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

        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 roomDescription({ value, room, rid, user }) {
                if (!value && !room.description) {
                    return;
                }
                if (value !== room.description) {
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 227..234
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 235..242

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

        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 roomAnnouncement({ value, room, rid, user }) {
                if (!value && !room.announcement) {
                    return;
                }
                if (value !== room.announcement) {
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 227..234
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 248..255

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

        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

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

            params: {
                userId: IUser['_id'];
                value: RoomSettings[TRoomSetting];
                room: IRoom;
                rid: IRoom['_id'];
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 54..59

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

        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

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

            [TRoomSetting in keyof RoomSettings]?: (params: {
                userId: IUser['_id'];
                value: RoomSettings[TRoomSetting];
                room: IRoom;
                rid: IRoom['_id'];
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 365..370

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

        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

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

        const hasRetentionPolicy = (room: IRoom & { retention?: any }): room is IRoomWithRetentionPolicy =>
            'retention' in room && room.retention !== undefined;
        apps/meteor/client/views/room/body/hooks/useRetentionPolicy.ts on lines 4..5

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

        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

            async reactWhenReadOnly({ value, room, rid, user }) {
                if (value !== room.reactWhenReadOnly) {
                    await saveReactWhenReadOnly(rid, value, user);
                }
            },
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 273..277

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

        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

            async readOnly({ value, room, rid, user }) {
                if (value !== room.ro) {
                    await saveRoomReadOnly(rid, value, user);
                }
            },
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 278..282

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

        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

            async featured({ userId }) {
                if (!(await hasPermissionAsync(userId, 'view-room-administration'))) {
                    throw new Meteor.Error('error-action-not-allowed', 'Viewing room administration is not allowed', {
                        method: 'saveRoomSettings',
                        action: 'Viewing_room_administration',
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 66..73

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

        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

            async default({ userId }) {
                if (!(await hasPermissionAsync(userId, 'view-room-administration'))) {
                    throw new Meteor.Error('error-action-not-allowed', 'Viewing room administration is not allowed', {
                        method: 'saveRoomSettings',
                        action: 'Viewing_room_administration',
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 74..81

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

        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

                if (value === 'p' && !(await hasPermissionAsync(userId, 'create-p'))) {
                    throw new Meteor.Error('error-action-not-allowed', 'Changing a public channel to a private room is not allowed', {
                        method: 'saveRoomSettings',
                        action: 'Change_Room_Type',
                    });
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 87..92

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

        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

                if (value === 'c' && !(await hasPermissionAsync(userId, 'create-c'))) {
                    throw new Meteor.Error('error-action-not-allowed', 'Changing a private group to a public channel is not allowed', {
                        method: 'saveRoomSettings',
                        action: 'Change_Room_Type',
                    });
        apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts on lines 94..99

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

        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