RocketChat/Rocket.Chat

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

Summary

Maintainability
F
2 wks
Test Coverage

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

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

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

            async get() {
                const access = await hasPermissionAsync(this.userId, 'view-room-administration');
                const params = this.queryParams;
                let user = this.userId;
                let room;
    Severity: Major
    Found in apps/meteor/app/api/server/v1/groups.ts - About 2 hrs to fix

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

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

      Cognitive Complexity

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

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

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

      Further reading

      Function get has 41 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/groups.ts - About 1 hr to fix

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

                async post() {
                    if (!this.bodyParams.name) {
                        return API.v1.failure('Body param "name" is required');
                    }
        
        
        Severity: Minor
        Found in apps/meteor/app/api/server/v1/groups.ts - About 1 hr to fix

        Cognitive Complexity

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

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

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

        Further reading

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

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

          Function get has 37 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/groups.ts - About 1 hr to fix

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

                    async post() {
                        if (!this.bodyParams.name) {
                            return API.v1.failure('Body param "name" is required');
                        }
            
            
            Severity: Minor
            Found in apps/meteor/app/api/server/v1/groups.ts - About 1 hr to fix

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

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

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

                        async post() {
                            if (('roomId' in this.bodyParams && !this.bodyParams.roomId) || ('roomName' in this.bodyParams && !this.bodyParams.roomName)) {
                                return API.v1.failure('The parameter "roomId" or "roomName" is required');
                            }
                
                
                Severity: Minor
                Found in apps/meteor/app/api/server/v1/groups.ts - About 1 hr to fix

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

                  async function getRoomFromParams(params: { roomId?: string } | { roomName?: string }): Promise<IRoom> {
                      if (
                          (!('roomId' in params) && !('roomName' in params)) ||
                          ('roomId' in params && !(params as { roomId?: string }).roomId && 'roomName' in params && !(params as { roomName?: string }).roomName)
                      ) {
                  Severity: Minor
                  Found in apps/meteor/app/api/server/v1/groups.ts - About 1 hr to fix

                    Function getRoomFromParams has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                    async function getRoomFromParams(params: { roomId?: string } | { roomName?: string }): Promise<IRoom> {
                        if (
                            (!('roomId' in params) && !('roomName' in params)) ||
                            ('roomId' in params && !(params as { roomId?: string }).roomId && 'roomName' in params && !(params as { roomName?: string }).roomName)
                        ) {
                    Severity: Minor
                    Found in apps/meteor/app/api/server/v1/groups.ts - About 1 hr to fix

                    Cognitive Complexity

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

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

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

                    Further reading

                    Consider simplifying this complex logical expression.
                    Open

                        if (
                            (!('roomId' in params) && !('roomName' in params)) ||
                            ('roomId' in params && !(params as { roomId?: string }).roomId && 'roomName' in params && !(params as { roomName?: string }).roomName)
                        ) {
                            throw new Meteor.Error('error-room-param-not-provided', 'The parameter "roomId" or "roomName" is required');
                    Severity: Major
                    Found in apps/meteor/app/api/server/v1/groups.ts - About 40 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                      return API.v1.success({
                                          group: await composeRoomWithLastMessage(room, this.userId),
                                      });
                      Severity: Major
                      Found in apps/meteor/app/api/server/v1/groups.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                            return API.v1.unauthorized();
                        Severity: Major
                        Found in apps/meteor/app/api/server/v1/groups.ts - About 30 mins to fix

                          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/groups.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 post has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                                  async post() {
                                      if (('roomId' in this.bodyParams && !this.bodyParams.roomId) || ('roomName' in this.bodyParams && !this.bodyParams.roomName)) {
                                          return API.v1.failure('The parameter "roomId" or "roomName" is required');
                                      }
                          
                          
                          Severity: Minor
                          Found in apps/meteor/app/api/server/v1/groups.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 post has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                                  async post() {
                                      const roomId = 'roomId' in this.bodyParams ? this.bodyParams.roomId : '';
                                      const roomName = 'roomName' in this.bodyParams ? this.bodyParams.roomName : '';
                                      const idOrName = roomId || roomName;
                          
                          
                          Severity: Minor
                          Found in apps/meteor/app/api/server/v1/groups.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

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

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

                          API.v1.addRoute(
                              'groups.setDescription',
                              { authRequired: true },
                              {
                                  async post() {
                          Severity: Major
                          Found in apps/meteor/app/api/server/v1/groups.ts and 3 other locations - About 6 hrs to fix
                          apps/meteor/app/api/server/v1/groups.ts on lines 998..1019
                          apps/meteor/app/api/server/v1/groups.ts on lines 1054..1075
                          apps/meteor/app/api/server/v1/groups.ts on lines 1110..1131

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

                          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

                          API.v1.addRoute(
                              'groups.setAnnouncement',
                              { authRequired: true },
                              {
                                  async post() {
                          Severity: Major
                          Found in apps/meteor/app/api/server/v1/groups.ts and 3 other locations - About 6 hrs to fix
                          apps/meteor/app/api/server/v1/groups.ts on lines 975..996
                          apps/meteor/app/api/server/v1/groups.ts on lines 998..1019
                          apps/meteor/app/api/server/v1/groups.ts on lines 1054..1075

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

                          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

                          API.v1.addRoute(
                              'groups.setPurpose',
                              { authRequired: true },
                              {
                                  async post() {
                          Severity: Major
                          Found in apps/meteor/app/api/server/v1/groups.ts and 3 other locations - About 6 hrs to fix
                          apps/meteor/app/api/server/v1/groups.ts on lines 975..996
                          apps/meteor/app/api/server/v1/groups.ts on lines 1054..1075
                          apps/meteor/app/api/server/v1/groups.ts on lines 1110..1131

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

                          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

                          API.v1.addRoute(
                              'groups.setTopic',
                              { authRequired: true },
                              {
                                  async post() {
                          Severity: Major
                          Found in apps/meteor/app/api/server/v1/groups.ts and 3 other locations - About 6 hrs to fix
                          apps/meteor/app/api/server/v1/groups.ts on lines 975..996
                          apps/meteor/app/api/server/v1/groups.ts on lines 998..1019
                          apps/meteor/app/api/server/v1/groups.ts on lines 1110..1131

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

                          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

                          API.v1.addRoute(
                              'groups.addModerator',
                              { authRequired: true },
                              {
                                  async post() {
                          Severity: Major
                          Found in apps/meteor/app/api/server/v1/groups.ts and 4 other locations - About 4 hrs to fix
                          apps/meteor/app/api/server/v1/groups.ts on lines 161..178
                          apps/meteor/app/api/server/v1/groups.ts on lines 860..877
                          apps/meteor/app/api/server/v1/groups.ts on lines 879..896
                          apps/meteor/app/api/server/v1/groups.ts on lines 898..915

                          Duplicated Code

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

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

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

                          Tuning

                          This issue has a mass of 118.

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

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

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

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

                          Refactorings

                          Further Reading

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

                          API.v1.addRoute(
                              'groups.removeModerator',
                              { authRequired: true },
                              {
                                  async post() {
                          Severity: Major
                          Found in apps/meteor/app/api/server/v1/groups.ts and 4 other locations - About 4 hrs to fix
                          apps/meteor/app/api/server/v1/groups.ts on lines 142..159
                          apps/meteor/app/api/server/v1/groups.ts on lines 161..178
                          apps/meteor/app/api/server/v1/groups.ts on lines 879..896
                          apps/meteor/app/api/server/v1/groups.ts on lines 898..915

                          Duplicated Code

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

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

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

                          Tuning

                          This issue has a mass of 118.

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

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

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

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

                          Refactorings

                          Further Reading

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

                          API.v1.addRoute(
                              'groups.removeLeader',
                              { authRequired: true },
                              {
                                  async post() {
                          Severity: Major
                          Found in apps/meteor/app/api/server/v1/groups.ts and 4 other locations - About 4 hrs to fix
                          apps/meteor/app/api/server/v1/groups.ts on lines 142..159
                          apps/meteor/app/api/server/v1/groups.ts on lines 161..178
                          apps/meteor/app/api/server/v1/groups.ts on lines 860..877
                          apps/meteor/app/api/server/v1/groups.ts on lines 879..896

                          Duplicated Code

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

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

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

                          Tuning

                          This issue has a mass of 118.

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

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

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

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

                          Refactorings

                          Further Reading

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

                          API.v1.addRoute(
                              'groups.addOwner',
                              { authRequired: true },
                              {
                                  async post() {
                          Severity: Major
                          Found in apps/meteor/app/api/server/v1/groups.ts and 4 other locations - About 4 hrs to fix
                          apps/meteor/app/api/server/v1/groups.ts on lines 142..159
                          apps/meteor/app/api/server/v1/groups.ts on lines 860..877
                          apps/meteor/app/api/server/v1/groups.ts on lines 879..896
                          apps/meteor/app/api/server/v1/groups.ts on lines 898..915

                          Duplicated Code

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

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

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

                          Tuning

                          This issue has a mass of 118.

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

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

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

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

                          Refactorings

                          Further Reading

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

                          API.v1.addRoute(
                              'groups.removeOwner',
                              { authRequired: true },
                              {
                                  async post() {
                          Severity: Major
                          Found in apps/meteor/app/api/server/v1/groups.ts and 4 other locations - About 4 hrs to fix
                          apps/meteor/app/api/server/v1/groups.ts on lines 142..159
                          apps/meteor/app/api/server/v1/groups.ts on lines 161..178
                          apps/meteor/app/api/server/v1/groups.ts on lines 860..877
                          apps/meteor/app/api/server/v1/groups.ts on lines 898..915

                          Duplicated Code

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

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

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

                          Tuning

                          This issue has a mass of 118.

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

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

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

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

                          Refactorings

                          Further Reading

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

                                      const 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/groups.ts and 1 other location - About 3 hrs to fix
                          apps/meteor/app/api/server/v1/channels.ts on lines 1131..1143

                          Duplicated Code

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

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

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

                          Tuning

                          This issue has a mass of 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

                          API.v1.addRoute(
                              'groups.delete',
                              { authRequired: true },
                              {
                                  async post() {
                          Severity: Major
                          Found in apps/meteor/app/api/server/v1/groups.ts and 1 other location - About 3 hrs to fix
                          apps/meteor/app/api/server/v1/groups.ts on lines 1133..1149

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

                          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(
                              'groups.unarchive',
                              { authRequired: true },
                              {
                                  async post() {
                          Severity: Major
                          Found in apps/meteor/app/api/server/v1/groups.ts and 1 other location - About 3 hrs to fix
                          apps/meteor/app/api/server/v1/groups.ts on lines 360..376

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

                          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 (
                                  (!('roomId' in params) && !('roomName' in params)) ||
                                  ('roomId' in params && !(params as { roomId?: string }).roomId && 'roomName' in params && !(params as { roomName?: string }).roomName)
                              ) {
                                  throw new Meteor.Error('error-room-param-not-provided', 'The parameter "roomId" or "roomName" is required');
                          Severity: Major
                          Found in apps/meteor/app/api/server/v1/groups.ts and 1 other location - About 3 hrs to fix
                          apps/meteor/app/api/server/v1/rooms.ts on lines 56..61

                          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

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

                                      const { cursor, totalCount } = await findUsersOfRoom({
                                          rid: findResult.rid,
                                          ...(status && { status: { $in: status } }),
                                          skip,
                                          limit,
                          Severity: Major
                          Found in apps/meteor/app/api/server/v1/groups.ts and 1 other location - About 3 hrs to fix
                          apps/meteor/app/api/server/v1/channels.ts on lines 1083..1090

                          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

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

                          async function findPrivateGroupByIdOrName({
                              params,
                              checkedArchived = true,
                              userId,
                          }: {
                          Severity: Major
                          Found in apps/meteor/app/api/server/v1/groups.ts and 1 other location - About 1 hr to fix
                          apps/meteor/app/api/server/v1/channels.ts on lines 46..83

                          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/groups.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/channels.ts on lines 1437..1442
                          apps/meteor/app/api/server/v1/chat.ts on lines 536..541

                          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 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/groups.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/channels.ts on lines 999..1004
                          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 Rooms.findPaginated(ourQuery, {
                                          sort: sort || { name: 1 },
                                          skip: offset,
                                          limit: count,
                                          projection: fields,
                          Severity: Major
                          Found in apps/meteor/app/api/server/v1/groups.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/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/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/groups.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/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 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/groups.ts and 1 other location - About 1 hr to fix
                          apps/meteor/app/api/server/v1/channels.ts on lines 1127..1129

                          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/groups.ts and 1 other location - About 50 mins to fix
                          apps/meteor/app/api/server/v1/channels.ts on lines 1216..1218

                          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/groups.ts and 4 other locations - About 50 mins to fix
                          apps/meteor/app/api/server/v1/channels.ts on lines 308..313
                          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/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/groups.ts and 2 other locations - About 50 mins to fix
                          apps/meteor/app/api/server/v1/channels.ts on lines 631..639
                          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 2 locations. Consider refactoring.
                          Open

                                      if (this.bodyParams.extraData && !(typeof this.bodyParams.extraData === 'object')) {
                                          return API.v1.failure('Body param "extraData" must be an object if provided');
                                      }
                          Severity: Minor
                          Found in apps/meteor/app/api/server/v1/groups.ts and 1 other location - About 45 mins to fix
                          apps/meteor/app/api/server/v1/groups.ts on lines 322..324

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

                          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('Body param "customFields" must be an object if provided');
                                      }
                          Severity: Minor
                          Found in apps/meteor/app/api/server/v1/groups.ts and 1 other location - About 45 mins to fix
                          apps/meteor/app/api/server/v1/groups.ts on lines 325..327

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

                          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/groups.ts and 2 other locations - About 40 mins to fix
                          apps/meteor/app/api/server/v1/channels.ts on lines 1074..1080
                          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.rid))) {
                                          return API.v1.unauthorized();
                                      }
                          Severity: Minor
                          Found in apps/meteor/app/api/server/v1/groups.ts and 1 other location - About 35 mins to fix
                          apps/meteor/app/api/server/v1/channels.ts on lines 1067..1069

                          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 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/groups.ts and 2 other locations - About 35 mins to fix
                          apps/meteor/app/api/server/v1/channels.ts on lines 797..802
                          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