RocketChat/Rocket.Chat

View on GitHub
apps/meteor/app/api/server/v1/channels.ts

Summary

Maintainability
F
2 wks
Test Coverage

File channels.ts has 1214 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

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

            async get() {
                const { offset, count } = await getPaginationItems(this.queryParams);
                const { sort, fields, query } = await this.parseJsonQuery();
                const hasPermissionToSeeAllPublicChannels = await hasPermissionAsync(this.userId, 'view-c-room');
    
    
    Severity: Minor
    Found in apps/meteor/app/api/server/v1/channels.ts - About 1 hr to fix

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

              async post() {
                  const { userId, bodyParams } = this;
      
                  let error;
      
      
      Severity: Minor
      Found in apps/meteor/app/api/server/v1/channels.ts - About 1 hr to fix

        Function get has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                async get() {
                    if (
                        !(await hasAtLeastOnePermissionAsync(this.userId, [
                            'manage-outgoing-integrations',
                            'manage-own-outgoing-integrations',
        Severity: Minor
        Found in apps/meteor/app/api/server/v1/channels.ts - About 1 hr to fix

          Function get has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  async get() {
                      const access = await hasPermissionAsync(this.userId, 'view-room-administration');
                      const { userId } = this.queryParams;
                      let user = this.userId;
                      let unreads = null;
          Severity: Minor
          Found in apps/meteor/app/api/server/v1/channels.ts - About 1 hr to fix

            Function post has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    async post() {
                        if (!(await hasPermissionAsync(this.userId, 'create-team'))) {
                            return API.v1.unauthorized();
                        }
            
            
            Severity: Minor
            Found in apps/meteor/app/api/server/v1/channels.ts - About 1 hr to fix

              Function get has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      async get() {
                          const findResult = await findChannelByIdOrName({
                              params: this.queryParams,
                              checkedArchived: false,
                          });
              Severity: Minor
              Found in apps/meteor/app/api/server/v1/channels.ts - About 1 hr to fix

                Function get has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        async get() {
                            const { query } = await this.parseJsonQuery();
                            if (!query || Object.keys(query).length === 0) {
                                return API.v1.failure('Invalid query');
                            }
                Severity: Minor
                Found in apps/meteor/app/api/server/v1/channels.ts - About 1 hr to fix

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

                          async get() {
                              const { roomId } = this.queryParams;
                              const findResult = await findChannelByIdOrName({
                                  params: { roomId },
                                  checkedArchived: false,
                  Severity: Minor
                  Found in apps/meteor/app/api/server/v1/channels.ts - About 1 hr to fix

                    Function findChannelByIdOrName has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    async function findChannelByIdOrName({
                        params,
                        checkedArchived = true,
                        userId,
                    }: {
                    Severity: Minor
                    Found in apps/meteor/app/api/server/v1/channels.ts - About 45 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Function post has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                            async post() {
                                if (!(await hasPermissionAsync(this.userId, 'create-team'))) {
                                    return API.v1.unauthorized();
                                }
                    
                    
                    Severity: Minor
                    Found in apps/meteor/app/api/server/v1/channels.ts - About 45 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Function post has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                            async post() {
                                const { userId, bodyParams } = this;
                    
                                let error;
                    
                    
                    Severity: Minor
                    Found in apps/meteor/app/api/server/v1/channels.ts - About 45 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Function get has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                            async get() {
                                const access = await hasPermissionAsync(this.userId, 'view-room-administration');
                                const { userId } = this.queryParams;
                                let user = this.userId;
                                let unreads = null;
                    Severity: Minor
                    Found in apps/meteor/app/api/server/v1/channels.ts - About 35 mins 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

                    Avoid too many return statements within this function.
                    Open

                                return API.v1.success({ team });
                    Severity: Major
                    Found in apps/meteor/app/api/server/v1/channels.ts - About 30 mins to fix

                      Function createChannelValidator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      async function createChannelValidator(params: {
                          user: { value: string };
                          name?: { key: string; value?: string };
                          members?: { key: string; value?: string[] };
                          customFields?: { key: string; value?: string };
                      Severity: Minor
                      Found in apps/meteor/app/api/server/v1/channels.ts - About 25 mins to fix

                      Cognitive Complexity

                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                      A method's cognitive complexity is based on a few simple rules:

                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                      • Code is considered more complex for each "break in the linear flow of the code"
                      • Code is considered more complex when "flow breaking structures are nested"

                      Further reading

                      Function get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                              async get() {
                                  const { query } = await this.parseJsonQuery();
                                  if (!query || Object.keys(query).length === 0) {
                                      return API.v1.failure('Invalid query');
                                  }
                      Severity: Minor
                      Found in apps/meteor/app/api/server/v1/channels.ts - About 25 mins 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 2 locations. Consider refactoring.
                      Open

                          {
                              async get() {
                                  const room = await Rooms.findOneById<Pick<IRoom, '_id' | 't' | 'teamId' | 'prid'>>(this.queryParams.roomId, {
                                      projection: { t: 1, teamId: 1, prid: 1 },
                                  });
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 1 other location - About 2 days to fix
                      apps/meteor/app/api/server/v1/rooms.ts on lines 527..563

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

                      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

                      API.v1.addRoute(
                          'channels.list.joined',
                          { authRequired: true },
                          {
                              async get() {
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 1 other location - About 2 days to fix
                      apps/meteor/app/api/server/v1/groups.ts on lines 632..669

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

                      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

                      API.v1.addRoute(
                          'channels.setPurpose',
                          { authRequired: true },
                          {
                              async post() {
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 2 other locations - About 7 hrs to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 1263..1285
                      apps/meteor/app/api/server/v1/channels.ts on lines 1311..1333

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

                      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

                      API.v1.addRoute(
                          'channels.setDescription',
                          { authRequired: true },
                          {
                              async post() {
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 2 other locations - About 7 hrs to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 1287..1309
                      apps/meteor/app/api/server/v1/channels.ts on lines 1311..1333

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

                      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

                      API.v1.addRoute(
                          'channels.setTopic',
                          { authRequired: true },
                          {
                              async post() {
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 2 other locations - About 7 hrs to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 1263..1285
                      apps/meteor/app/api/server/v1/channels.ts on lines 1287..1309

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

                      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

                      async function createChannelValidator(params: {
                          user: { value: string };
                          name?: { key: string; value?: string };
                          members?: { key: string; value?: string[] };
                          customFields?: { key: string; value?: string };
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 1 other location - About 3 hrs to fix
                      apps/meteor/app/api/server/api.ts on lines 1018..1024

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

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

                      API.v1.addRoute(
                          'channels.removeModerator',
                          { authRequired: true },
                          {
                              async post() {
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 5 other locations - About 3 hrs to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 531..545
                      apps/meteor/app/api/server/v1/channels.ts on lines 547..561
                      apps/meteor/app/api/server/v1/channels.ts on lines 1168..1182
                      apps/meteor/app/api/server/v1/channels.ts on lines 1365..1379
                      apps/meteor/app/api/server/v1/channels.ts on lines 1381..1395

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

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

                      API.v1.addRoute(
                          'channels.removeLeader',
                          { authRequired: true },
                          {
                              async post() {
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 5 other locations - About 3 hrs to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 531..545
                      apps/meteor/app/api/server/v1/channels.ts on lines 547..561
                      apps/meteor/app/api/server/v1/channels.ts on lines 1152..1166
                      apps/meteor/app/api/server/v1/channels.ts on lines 1168..1182
                      apps/meteor/app/api/server/v1/channels.ts on lines 1365..1379

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

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

                      API.v1.addRoute(
                          'channels.addOwner',
                          { authRequired: true },
                          {
                              async post() {
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 5 other locations - About 3 hrs to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 531..545
                      apps/meteor/app/api/server/v1/channels.ts on lines 1152..1166
                      apps/meteor/app/api/server/v1/channels.ts on lines 1168..1182
                      apps/meteor/app/api/server/v1/channels.ts on lines 1365..1379
                      apps/meteor/app/api/server/v1/channels.ts on lines 1381..1395

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

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

                      API.v1.addRoute(
                          'channels.addLeader',
                          { authRequired: true },
                          {
                              async post() {
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 5 other locations - About 3 hrs to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 531..545
                      apps/meteor/app/api/server/v1/channels.ts on lines 547..561
                      apps/meteor/app/api/server/v1/channels.ts on lines 1152..1166
                      apps/meteor/app/api/server/v1/channels.ts on lines 1168..1182
                      apps/meteor/app/api/server/v1/channels.ts on lines 1381..1395

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

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

                      API.v1.addRoute(
                          'channels.removeOwner',
                          { authRequired: true },
                          {
                              async post() {
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 5 other locations - About 3 hrs to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 531..545
                      apps/meteor/app/api/server/v1/channels.ts on lines 547..561
                      apps/meteor/app/api/server/v1/channels.ts on lines 1152..1166
                      apps/meteor/app/api/server/v1/channels.ts on lines 1365..1379
                      apps/meteor/app/api/server/v1/channels.ts on lines 1381..1395

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

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

                      API.v1.addRoute(
                          'channels.addModerator',
                          { authRequired: true },
                          {
                              async post() {
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 5 other locations - About 3 hrs to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 547..561
                      apps/meteor/app/api/server/v1/channels.ts on lines 1152..1166
                      apps/meteor/app/api/server/v1/channels.ts on lines 1168..1182
                      apps/meteor/app/api/server/v1/channels.ts on lines 1365..1379
                      apps/meteor/app/api/server/v1/channels.ts on lines 1381..1395

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

                      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 onlineInRoom = await Promise.all(
                                      online.map(async (user) => {
                                          const subscription = await Subscriptions.findOneByRoomIdAndUserId(room._id, user._id, {
                                              projection: { _id: 1, username: 1 },
                                          });
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 1 other location - About 3 hrs to fix
                      apps/meteor/app/api/server/v1/groups.ts on lines 817..829

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

                      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 { cursor, totalCount } = await findUsersOfRoom({
                                      rid: findResult._id,
                                      ...(status && { status: { $in: status } }),
                                      skip,
                                      limit,
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 1 other location - About 3 hrs to fix
                      apps/meteor/app/api/server/v1/groups.ts on lines 729..736

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

                      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

                          if ('roomId' in params) {
                              room = await Rooms.findOneById(params.roomId || '', { projection });
                          } else if ('roomName' in params) {
                              room = await Rooms.findOneByName(params.roomName || '', { projection });
                          }
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 1 other location - About 2 hrs to fix
                      apps/meteor/app/api/server/v1/rooms.ts on lines 66..70

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

                      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 result = await Meteor.callAsync('getChannelHistory', {
                                      rid: findResult._id,
                                      latest: latest ? new Date(latest) : new Date(),
                                      oldest: oldest && new Date(oldest),
                                      inclusive: inclusive === 'true',
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 1 other location - About 2 hrs to fix
                      apps/meteor/app/api/server/v1/im.ts on lines 276..285

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

                      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 function findChannelByIdOrName({
                          params,
                          checkedArchived = true,
                          userId,
                      }: {
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 1 other location - About 1 hr to fix
                      apps/meteor/app/api/server/v1/groups.ts on lines 67..114

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

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

                                  const { cursor, totalCount } = await Messages.findPaginated(ourQuery, {
                                      sort: sort || { ts: -1 },
                                      skip: offset,
                                      limit: count,
                                      projection: fields,
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 3 other locations - About 1 hr to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 299..304
                      apps/meteor/app/api/server/v1/chat.ts on lines 536..541
                      apps/meteor/app/api/server/v1/groups.ts on lines 764..769

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

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

                                  const { cursor, totalCount } = await Messages.findPaginated(ourQuery, {
                                      sort: sort || { ts: -1 },
                                      skip: offset,
                                      limit: count,
                                      projection: fields,
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 3 other locations - About 1 hr to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 1437..1442
                      apps/meteor/app/api/server/v1/chat.ts on lines 536..541
                      apps/meteor/app/api/server/v1/groups.ts on lines 764..769

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

                      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 (params.members?.value && !Array.isArray(params.members.value)) {
                              throw new Error(`Param "${params.members.key}" must be an array if provided`);
                          }
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 1 other location - About 1 hr to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 667..669

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

                      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 (params.teams?.value && !Array.isArray(params.teams.value)) {
                              throw new Error(`Param ${params.teams.key} must be an array`);
                          }
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 1 other location - About 1 hr to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 659..661

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

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

                                  const { cursor, totalCount } = await Rooms.findPaginated(ourQuery, {
                                      sort: sort || { name: 1 },
                                      skip: offset,
                                      limit: count,
                                      projection: fields,
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 6 other locations - About 1 hr to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 788..793
                      apps/meteor/app/api/server/v1/channels.ts on lines 898..903
                      apps/meteor/app/api/server/v1/groups.ts on lines 394..399
                      apps/meteor/app/api/server/v1/groups.ts on lines 451..456
                      apps/meteor/app/api/server/v1/groups.ts on lines 683..688
                      apps/meteor/app/api/server/v1/rooms.ts on lines 505..510

                      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

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

                                  const { cursor, totalCount } = await Integrations.findPaginated(ourQuery, {
                                      sort: sort || { _createdAt: 1 },
                                      skip: offset,
                                      limit: count,
                                      projection,
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 6 other locations - About 1 hr to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 788..793
                      apps/meteor/app/api/server/v1/channels.ts on lines 999..1004
                      apps/meteor/app/api/server/v1/groups.ts on lines 394..399
                      apps/meteor/app/api/server/v1/groups.ts on lines 451..456
                      apps/meteor/app/api/server/v1/groups.ts on lines 683..688
                      apps/meteor/app/api/server/v1/rooms.ts on lines 505..510

                      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

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

                                  const { cursor, totalCount } = await Uploads.findPaginatedWithoutThumbs(ourQuery, {
                                      sort: sort || { name: 1 },
                                      skip: offset,
                                      limit: count,
                                      projection: fields,
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 6 other locations - About 1 hr to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 898..903
                      apps/meteor/app/api/server/v1/channels.ts on lines 999..1004
                      apps/meteor/app/api/server/v1/groups.ts on lines 394..399
                      apps/meteor/app/api/server/v1/groups.ts on lines 451..456
                      apps/meteor/app/api/server/v1/groups.ts on lines 683..688
                      apps/meteor/app/api/server/v1/rooms.ts on lines 505..510

                      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

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

                                  const online: Pick<IUser, '_id' | 'username'>[] = await Users.findUsersNotOffline({
                                      projection: { username: 1 },
                                  }).toArray();
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 1 other location - About 1 hr to fix
                      apps/meteor/app/api/server/v1/groups.ts on lines 811..815

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

                      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 (!this.bodyParams.customFields || !(typeof this.bodyParams.customFields === 'object')) {
                                      return API.v1.failure('The bodyParam "customFields" is required with a type like object.');
                                  }
                      Severity: Minor
                      Found in apps/meteor/app/api/server/v1/channels.ts and 1 other location - About 50 mins to fix
                      apps/meteor/app/api/server/v1/groups.ts on lines 951..953

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

                      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

                                  return API.v1.success({
                                      messages: await normalizeMessagesForUser(messages, this.userId),
                                      count: messages.length,
                                      offset,
                                      total,
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 4 other locations - About 50 mins to fix
                      apps/meteor/app/api/server/v1/chat.ts on lines 495..500
                      apps/meteor/app/api/server/v1/chat.ts on lines 545..550
                      apps/meteor/app/api/server/v1/groups.ts on lines 773..778
                      apps/meteor/app/api/server/v1/im.ts on lines 386..391

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

                      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

                                  return API.v1.success({
                                      joined,
                                      members,
                                      unreads,
                                      unreadsFrom,
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 2 other locations - About 50 mins to fix
                      apps/meteor/app/api/server/v1/groups.ts on lines 295..303
                      apps/meteor/app/api/server/v1/im.ts on lines 211..219

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

                      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

                                  check(
                                      this.queryParams,
                                      Match.ObjectIncluding({
                                          status: Match.Maybe([String]),
                                          filter: Match.Maybe(String),
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 2 other locations - About 40 mins to fix
                      apps/meteor/app/api/server/v1/groups.ts on lines 719..725
                      apps/meteor/app/api/server/v1/im.ts on lines 316..322

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

                      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 (findResult.broadcast && !(await hasPermissionAsync(this.userId, 'view-broadcast-member-list', findResult._id))) {
                                      return API.v1.unauthorized();
                                  }
                      Severity: Minor
                      Found in apps/meteor/app/api/server/v1/channels.ts and 1 other location - About 35 mins to fix
                      apps/meteor/app/api/server/v1/groups.ts on lines 712..714

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

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

                                  return API.v1.success({
                                      channel: await findChannelByIdOrName({ params: this.bodyParams, userId: this.userId }),
                                  });
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 5 other locations - About 35 mins to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 948..950
                      apps/meteor/app/api/server/v1/channels.ts on lines 1201..1206
                      apps/meteor/app/api/server/v1/channels.ts on lines 1224..1226
                      apps/meteor/app/api/server/v1/channels.ts on lines 1256..1258
                      apps/meteor/app/api/server/v1/channels.ts on lines 1410..1412

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

                                  return API.v1.success({
                                      channel: await findChannelByIdOrName({ params: this.bodyParams, userId: this.userId }),
                                  });
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 5 other locations - About 35 mins to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 366..368
                      apps/meteor/app/api/server/v1/channels.ts on lines 1201..1206
                      apps/meteor/app/api/server/v1/channels.ts on lines 1224..1226
                      apps/meteor/app/api/server/v1/channels.ts on lines 1256..1258
                      apps/meteor/app/api/server/v1/channels.ts on lines 1410..1412

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

                                  return API.v1.success({
                                      channel: await findChannelByIdOrName({ params: this.bodyParams, userId: this.userId }),
                                  });
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 5 other locations - About 35 mins to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 366..368
                      apps/meteor/app/api/server/v1/channels.ts on lines 948..950
                      apps/meteor/app/api/server/v1/channels.ts on lines 1201..1206
                      apps/meteor/app/api/server/v1/channels.ts on lines 1224..1226
                      apps/meteor/app/api/server/v1/channels.ts on lines 1410..1412

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

                                  return API.v1.success({
                                      channel: await findChannelByIdOrName({
                                          params: this.bodyParams,
                                          userId: this.userId,
                                      }),
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 5 other locations - About 35 mins to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 366..368
                      apps/meteor/app/api/server/v1/channels.ts on lines 948..950
                      apps/meteor/app/api/server/v1/channels.ts on lines 1224..1226
                      apps/meteor/app/api/server/v1/channels.ts on lines 1256..1258
                      apps/meteor/app/api/server/v1/channels.ts on lines 1410..1412

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

                                  return API.v1.success({
                                      channel: await findChannelByIdOrName({ params: this.bodyParams, userId: this.userId }),
                                  });
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 5 other locations - About 35 mins to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 366..368
                      apps/meteor/app/api/server/v1/channels.ts on lines 948..950
                      apps/meteor/app/api/server/v1/channels.ts on lines 1201..1206
                      apps/meteor/app/api/server/v1/channels.ts on lines 1224..1226
                      apps/meteor/app/api/server/v1/channels.ts on lines 1256..1258

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

                                  return API.v1.success({
                                      channel: await findChannelByIdOrName({ params: this.bodyParams, userId: this.userId }),
                                  });
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/channels.ts and 5 other locations - About 35 mins to fix
                      apps/meteor/app/api/server/v1/channels.ts on lines 366..368
                      apps/meteor/app/api/server/v1/channels.ts on lines 948..950
                      apps/meteor/app/api/server/v1/channels.ts on lines 1201..1206
                      apps/meteor/app/api/server/v1/channels.ts on lines 1256..1258
                      apps/meteor/app/api/server/v1/channels.ts on lines 1410..1412

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

                                  return API.v1.success({
                                      files: await addUserToFileObj(files),
                                      count: files.length,
                                      offset,
                                      total,
                      Severity: Minor
                      Found in apps/meteor/app/api/server/v1/channels.ts and 2 other locations - About 35 mins to fix
                      apps/meteor/app/api/server/v1/groups.ts on lines 403..408
                      apps/meteor/app/api/server/v1/im.ts on lines 253..258

                      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