RocketChat/Rocket.Chat

View on GitHub
apps/meteor/ee/server/apps/communication/rest.ts

Summary

Maintainability
F
3 wks
Test Coverage

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

    addManagementRoutes() {
        const orchestrator = this._orch;
        const manager = this._manager;

        const handleError = (message: string, e: any) => {
Severity: Minor
Found in apps/meteor/ee/server/apps/communication/rest.ts - About 5 days to fix

Cognitive Complexity

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

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

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

Further reading

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

    addManagementRoutes() {
        const orchestrator = this._orch;
        const manager = this._manager;

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

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

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

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

                      async post() {
                          let buff;
                          let marketplaceInfo;
                          let permissionsGranted;
      
      
      Severity: Major
      Found in apps/meteor/ee/server/apps/communication/rest.ts - About 3 hrs to fix

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

                        async post() {
                            let buff;
                            let permissionsGranted;
                            let isPrivateAppUpload = false;
        
        
        Severity: Major
        Found in apps/meteor/ee/server/apps/communication/rest.ts - About 3 hrs to fix

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

                          async get() {
                              const baseUrl = orchestrator.getMarketplaceUrl();
          
                              // Gets the Apps from the marketplace
                              if ('marketplace' in this.queryParams && this.queryParams.marketplace) {
          Severity: Major
          Found in apps/meteor/ee/server/apps/communication/rest.ts - About 2 hrs to fix

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

                            async get() {
                                if (this.queryParams.marketplace && this.queryParams.version) {
                                    const baseUrl = orchestrator.getMarketplaceUrl();
            
                                    const headers: Record<string, any> = {}; // DO NOT ATTACH THE FRAMEWORK/ENGINE VERSION HERE.
            Severity: Minor
            Found in apps/meteor/ee/server/apps/communication/rest.ts - About 1 hr to fix

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

                              async get() {
                                  if (!this.queryParams.appId) {
                                      return API.v1.failure({ error: 'Invalid request. Please ensure an appId is attached to the request.' });
                                  }
              
              
              Severity: Minor
              Found in apps/meteor/ee/server/apps/communication/rest.ts - About 1 hr to fix

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

                                async post() {
                                    const { id: appId } = this.urlParams;
                                    const { status } = this.bodyParams;
                
                                    if (!status || typeof status !== 'string') {
                Severity: Minor
                Found in apps/meteor/ee/server/apps/communication/rest.ts - About 1 hr to fix

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

                                  async post() {
                                      const baseUrl = orchestrator.getMarketplaceUrl();
                  
                                      const headers = getDefaultHeaders();
                                      const token = await getWorkspaceAccessToken();
                  Severity: Minor
                  Found in apps/meteor/ee/server/apps/communication/rest.ts - About 1 hr to fix

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

                                    async get() {
                                        const baseUrl = orchestrator.getMarketplaceUrl();
                    
                                        // Gets the Apps from the marketplace
                                        const headers = getDefaultHeaders();
                    Severity: Minor
                    Found in apps/meteor/ee/server/apps/communication/rest.ts - About 1 hr to fix

                      Avoid too many return statements within this function.
                      Open

                                              return API.v1.failure(e.message);
                      Severity: Major
                      Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                                return API.v1.failure({ error: 'Failed to get a file to install for the App. ' });
                        Severity: Major
                        Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                                      return API.v1.failure({ error: 'Unauthorized' });
                          Severity: Major
                          Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                                    return API.v1.success({
                                                        url: `${baseUrl}/apps/${this.queryParams.appId}/${
                                                            this.queryParams.purchaseType === 'buy' ? this.queryParams.purchaseType : subscribeRoute
                                                        }?workspaceId=${workspaceId}&token=${token.token}&seats=${seats}`,
                                                    });
                            Severity: Major
                            Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                                      return API.v1.failure({
                                                          status: 'app_user_error',
                                                          messages: [(aff.getAppUserError() as Record<string, any>).message],
                                                          payload: { username: (aff.getAppUserError() as Record<string, any>).username },
                                                      });
                              Severity: Major
                              Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                                    return API.v1.success({
                                                        app: info,
                                                        implemented: aff.getImplementedInferfaces(),
                                                        licenseValidation: aff.getLicenseValidationResult(),
                                                    });
                                Severity: Major
                                Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                                              return API.v1.internalError();
                                  Severity: Major
                                  Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                        return API.v1.success({
                                                            app: info,
                                                            implemented: aff.getImplementedInferfaces(),
                                                            licenseValidation: aff.getLicenseValidationResult(),
                                                        });
                                    Severity: Major
                                    Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                              return API.v1.success(result);
                                      Severity: Major
                                      Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                                    return API.v1.failure({ error: 'Invalid purchase type' });
                                        Severity: Major
                                        Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                                  return API.v1.success({ app: result });
                                          Severity: Major
                                          Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                                    return API.v1.failure({
                                                                        status: 'app_user_error',
                                                                        messages: [(aff.getAppUserError() as Record<string, any>).message],
                                                                        payload: { username: (aff.getAppUserError() as Record<string, any>).username },
                                                                    });
                                            Severity: Major
                                            Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                                          return handleError('Unable to access Marketplace. Does the server has access to the internet?', e);
                                              Severity: Major
                                              Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                                    return API.v1.success({
                                                                        app: formatAppInstanceForRest(app),
                                                                    });
                                                Severity: Major
                                                Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                                      return API.v1.success({ apps });
                                                  Severity: Major
                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                                            return API.v1.notFound(`No App found by the id of: ${this.urlParams.id}`);
                                                    Severity: Major
                                                    Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                                              return API.v1.failure({ error: 'Failed to get a file to install for the App. ' });
                                                      Severity: Major
                                                      Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                                                return API.v1.internalError('private_app_install_disabled');
                                                        Severity: Major
                                                        Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                                                          Avoid too many return statements within this function.
                                                          Open

                                                                                  return API.v1.internalError('private_app_install_disabled');
                                                          Severity: Major
                                                          Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                                                            Avoid too many return statements within this function.
                                                            Open

                                                                                    return API.v1.failure({ status: 'storage_error', messages: [aff.getStorageError()] });
                                                            Severity: Major
                                                            Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                                                              Avoid too many return statements within this function.
                                                              Open

                                                                                  return API.v1.success({ status: result.getStatus() });
                                                              Severity: Major
                                                              Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

                                                                Avoid too many return statements within this function.
                                                                Open

                                                                                        return API.v1.failure({ status: 'storage_error', messages: [aff.getStorageError()] });
                                                                Severity: Major
                                                                Found in apps/meteor/ee/server/apps/communication/rest.ts - About 30 mins to fix

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

                                                                                          try {
                                                                                              const request = await fetch(`${baseUrl}/v1/apps/${this.urlParams.id}/latest?appVersion=${this.queryParams.appVersion}`, {
                                                                                                  headers,
                                                                                              });
                                                                                              if (request.status !== 200) {
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 5 hrs to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 627..636

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

                                                                  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

                                                                                          try {
                                                                                              const request = await fetch(`${baseUrl}/v1/apps/${this.urlParams.id}?appVersion=${this.queryParams.version}`, { headers });
                                                                                              if (request.status !== 200) {
                                                                                                  orchestrator.getRocketChatLogger().error('Error getting the App information from the Marketplace:', await request.json());
                                                                                                  return API.v1.failure();
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 5 hrs to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 651..662

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

                                                                  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

                                                                                      try {
                                                                                          const setting = manager.getSettingsManager().getAppSetting(this.urlParams.id, this.urlParams.settingId);
                                                                  
                                                                                          return API.v1.success({ setting });
                                                                                      } catch (e: any) {
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 4 hrs to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 1093..1105

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

                                                                  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

                                                                                      try {
                                                                                          await manager.getSettingsManager().updateAppSetting(this.urlParams.id, this.bodyParams.setting);
                                                                  
                                                                                          return API.v1.success();
                                                                                      } catch (e: any) {
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 4 hrs to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 1074..1086

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

                                                                  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

                                                                                          try {
                                                                                              const request = await fetch(`${baseUrl}/v1/apps`, { headers });
                                                                                              if (request.status !== 200) {
                                                                                                  orchestrator.getRocketChatLogger().error('Error getting the Apps:', await request.json());
                                                                                                  return API.v1.failure();
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 4 hrs to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 596..605

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

                                                                  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

                                                                                      try {
                                                                                          const request = await fetch(`${baseUrl}/v1/featured-apps`, { headers });
                                                                                          if (request.status !== 200) {
                                                                                              orchestrator.getRocketChatLogger().error('Error getting the Featured Apps from the Marketplace:', await request.json());
                                                                                              return API.v1.failure();
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 4 hrs to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 237..246

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

                                                                  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 (aff.hasAppUserError()) {
                                                                                          return API.v1.failure({
                                                                                              status: 'app_user_error',
                                                                                              messages: [(aff.getAppUserError() as Record<string, any>).message],
                                                                                              payload: { username: (aff.getAppUserError() as Record<string, any>).username },
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 3 hrs to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 758..764

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

                                                                  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 (aff.hasAppUserError()) {
                                                                                          return API.v1.failure({
                                                                                              status: 'app_user_error',
                                                                                              messages: [(aff.getAppUserError() as Record<string, any>).message],
                                                                                              payload: { username: (aff.getAppUserError() as Record<string, any>).username },
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 3 hrs to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 407..413

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

                                                                  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

                                                                                          return API.v1.success({
                                                                                              url: `${baseUrl}/apps/${this.queryParams.appId}/${
                                                                                                  this.queryParams.purchaseType === 'buy' ? this.queryParams.purchaseType : subscribeRoute
                                                                                              }?workspaceId=${workspaceId}&token=${token.token}&seats=${seats}`,
                                                                                          });
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 2 hrs to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 198..202

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

                                                                  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

                                                                                      return API.v1.success({
                                                                                          url: `${baseUrl}/apps/${this.queryParams.appId}/${
                                                                                              this.queryParams.purchaseType === 'buy' ? this.queryParams.purchaseType : subscribeRoute
                                                                                          }?workspaceId=${workspaceId}&token=${response.token}&seats=${seats}`,
                                                                                      });
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 2 hrs to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 297..301

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

                                                                  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

                                                                                          permissionsGranted = (() => {
                                                                                              try {
                                                                                                  const permissions = JSON.parse(formData?.permissions || '');
                                                                                                  return permissions.length ? permissions : undefined;
                                                                                              } catch {
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 1 hr to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 376..383

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

                                                                  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

                                                                                          permissionsGranted = (() => {
                                                                                              try {
                                                                                                  const permissions = JSON.parse(formData?.permissions || '');
                                                                                                  return permissions.length ? permissions : undefined;
                                                                                              } catch {
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 1 hr to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 733..740

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

                                                                  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 (!this.queryParams.purchaseType || !purchaseTypes.has(this.queryParams.purchaseType)) {
                                                                                              return API.v1.failure({ error: 'Invalid purchase type' });
                                                                                          }
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 1 hr to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 185..187

                                                                  Duplicated Code

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

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

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

                                                                  Tuning

                                                                  This issue has a mass of 60.

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

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

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

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

                                                                  Refactorings

                                                                  Further Reading

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

                                                                                      if (!this.queryParams.purchaseType || !purchaseTypes.has(this.queryParams.purchaseType)) {
                                                                                          return API.v1.failure({ error: 'Invalid purchase type' });
                                                                                      }
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 1 hr to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 284..286

                                                                  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

                                                                                              if (response.status !== 200 || response.headers.get('content-type') !== 'application/zip') {
                                                                                                  return API.v1.failure({
                                                                                                      error: 'Invalid url. It doesn\'t exist or is not "application/zip".',
                                                                                                  });
                                                                                              }
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 1 hr to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 683..687

                                                                  Duplicated Code

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

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

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

                                                                  Tuning

                                                                  This issue has a mass of 56.

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

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

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

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

                                                                  Refactorings

                                                                  Further Reading

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

                                                                                          if (response.status !== 200 || response.headers.get('content-type') !== 'application/zip') {
                                                                                              return API.v1.failure({
                                                                                                  error: 'Invalid url. It doesn\'t exist or is not "application/zip".',
                                                                                              });
                                                                                          }
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 1 hr to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 318..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 56.

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

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

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

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

                                                                  Refactorings

                                                                  Further Reading

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

                                                                                      try {
                                                                                          const request = await fetch(`${baseUrl}/v1/app-request/markAsSeen`, {
                                                                                              method: 'POST',
                                                                                              headers,
                                                                                              body: { ids: unseenRequests },
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 3 other locations - About 55 mins to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 961..971
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 1199..1213
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 1231..1242

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

                                                                  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

                                                                                      try {
                                                                                          const request = await fetch(`${baseUrl}/v1/apps/${appId}/screenshots`, { headers });
                                                                                          const data = await request.json();
                                                                  
                                                                                          return API.v1.success({
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 3 other locations - About 55 mins to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 1199..1213
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 1231..1242
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 1262..1279

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

                                                                  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

                                                                                      try {
                                                                                          const request = await fetch(`${baseUrl}/v1/app-request/stats`, { headers });
                                                                                          const result = await request.json();
                                                                                          if (!request.ok) {
                                                                                              throw new Error(result.error);
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 3 other locations - About 55 mins to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 961..971
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 1199..1213
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 1262..1279

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

                                                                  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

                                                                                      try {
                                                                                          const request = await fetch(`${baseUrl}/v1/app-request?appId=${appId}&q=${q}&sort=${sort}&limit=${limit}&offset=${offset}`, {
                                                                                              headers,
                                                                                          });
                                                                                          const result = await request.json();
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 3 other locations - About 55 mins to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 961..971
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 1231..1242
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 1262..1279

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

                                                                  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

                                                                                      try {
                                                                                          const request = await fetch(`${baseUrl}/v1/bundles/${this.urlParams.id}/apps`, { headers });
                                                                                          if (request.status !== 200) {
                                                                                              orchestrator.getRocketChatLogger().error("Error getting the Bundle's Apps from the Marketplace:", await request.json());
                                                                                              return API.v1.failure();
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 2 other locations - About 55 mins to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 315..328
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 696..719

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

                                                                  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

                                                                                          try {
                                                                                              const response = await fetch(this.bodyParams.url);
                                                                  
                                                                                              if (response.status !== 200 || response.headers.get('content-type') !== 'application/zip') {
                                                                                                  return API.v1.failure({
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 2 other locations - About 55 mins to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 565..575
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 696..719

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

                                                                  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

                                                                                          try {
                                                                                              const response = await fetch(
                                                                                                  `${baseUrl}/v2/apps/${this.bodyParams.appId}/download/${this.bodyParams.version}?token=${token}`,
                                                                                                  {
                                                                                                      headers,
                                                                  Severity: Major
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 2 other locations - About 55 mins to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 315..328
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 565..575

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

                                                                  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 (aff.hasStorageError()) {
                                                                                          return API.v1.failure({ status: 'storage_error', messages: [aff.getStorageError()] });
                                                                                      }
                                                                  Severity: Minor
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 40 mins to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 754..756

                                                                  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

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

                                                                                      if (aff.hasStorageError()) {
                                                                                          return API.v1.failure({ status: 'storage_error', messages: [aff.getStorageError()] });
                                                                                      }
                                                                  Severity: Minor
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 40 mins to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 403..405

                                                                  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

                                                                                              const response = await fetch(
                                                                                                  `${baseUrl}/v2/apps/${this.bodyParams.appId}/download/${this.bodyParams.version}?token=${token}`,
                                                                                                  {
                                                                                                      headers,
                                                                                                  },
                                                                  Severity: Minor
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 40 mins to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 344..346

                                                                  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

                                                                                                  fetch(`${baseUrl}/v2/apps/${this.bodyParams.appId}/download/${this.bodyParams.version}?token=${downloadToken}`, {
                                                                                                      headers,
                                                                                                  }),
                                                                  Severity: Minor
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 40 mins to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 697..702

                                                                  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

                                                                                          try {
                                                                                              const request = await fetch(`${baseUrl}/v1/categories`, { headers });
                                                                                              if (request.status !== 200) {
                                                                                                  orchestrator.getRocketChatLogger().error('Error getting the Apps:', await request.json());
                                                                                                  return API.v1.failure();
                                                                  Severity: Minor
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 30 mins to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 896..907

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

                                                                  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 request = await fetch(`${baseUrl}/v1/app-request/markAsSeen`, {
                                                                                              method: 'POST',
                                                                                              headers,
                                                                                              body: { ids: unseenRequests },
                                                                                          });
                                                                  Severity: Minor
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 30 mins to fix
                                                                  apps/meteor/app/cloud/server/functions/startRegisterWorkspace.ts on lines 25..31

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

                                                                  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

                                                                                      try {
                                                                                          const request = await fetch(`${baseUrl}/v1/workspaces/${workspaceIdSetting.value}/apps/${this.urlParams.id}`, { headers });
                                                                                          statusCode = request.status;
                                                                                          result = await request.json();
                                                                  
                                                                  
                                                                  Severity: Minor
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 30 mins to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 260..270

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

                                                                  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

                                                                                      return API.v1.success({
                                                                                          app: info,
                                                                                          implemented: aff.getImplementedInferfaces(),
                                                                                          licenseValidation: aff.getLicenseValidationResult(),
                                                                                      });
                                                                  Severity: Minor
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 30 mins to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 772..776

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

                                                                  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

                                                                                      return API.v1.success({
                                                                                          app: info,
                                                                                          implemented: aff.getImplementedInferfaces(),
                                                                                          licenseValidation: aff.getLicenseValidationResult(),
                                                                                      });
                                                                  Severity: Minor
                                                                  Found in apps/meteor/ee/server/apps/communication/rest.ts and 1 other location - About 30 mins to fix
                                                                  apps/meteor/ee/server/apps/communication/rest.ts on lines 426..430

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

                                                                  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