RocketChat/Rocket.Chat

View on GitHub
apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts

Summary

Maintainability
F
3 days
Test Coverage

Function getUserDataMapping has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
Open

    public static getUserDataMapping(): IUserDataMap {
        const { userDataFieldMap, immutableProperty } = globalSettings;

        let map: Record<string, any>;

Severity: Minor
Found in apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts - About 7 hrs to fix

Cognitive Complexity

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

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

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

Further reading

File Utils.ts has 389 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { EventEmitter } from 'events';
import zlib from 'zlib';

import type { Logger } from '@rocket.chat/logger';

Severity: Minor
Found in apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts - About 5 hrs to fix

    Function getProfileValue has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        public static getProfileValue(profile: Record<string, any>, mapping: IAttributeMapping, forceString = false): any {
            const values: Record<string, string> = {
                regex: '',
            };
            const fieldNames = ensureArray<string>(mapping.fieldName);
    Severity: Minor
    Found in apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts - About 4 hrs 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 getUserDataMapping has 91 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static getUserDataMapping(): IUserDataMap {
            const { userDataFieldMap, immutableProperty } = globalSettings;
    
            let map: Record<string, any>;
    
    
    Severity: Major
    Found in apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts - About 3 hrs to fix

      SAMLUtils has 24 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export class SAMLUtils {
          public static events: EventEmitter;
      
          public static get isDebugging(): boolean {
              return debug;
      Severity: Minor
      Found in apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts - About 2 hrs to fix

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

            public static getProfileValue(profile: Record<string, any>, mapping: IAttributeMapping, forceString = false): any {
                const values: Record<string, string> = {
                    regex: '',
                };
                const fieldNames = ensureArray<string>(mapping.fieldName);
        Severity: Major
        Found in apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts - About 2 hrs to fix

          Function mapProfileToUserObject has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              public static mapProfileToUserObject(profile: Record<string, any>): ISAMLUser {
                  const userDataMap = this.getUserDataMapping();
                  SAMLUtils.log('parsed userDataMap', userDataMap);
          
                  if (userDataMap.identifier.type === 'custom') {
          Severity: Minor
          Found in apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts - About 2 hrs 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 mapProfileToUserObject has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static mapProfileToUserObject(profile: Record<string, any>): ISAMLUser {
                  const userDataMap = this.getUserDataMapping();
                  SAMLUtils.log('parsed userDataMap', userDataMap);
          
                  if (userDataMap.identifier.type === 'custom') {
          Severity: Major
          Found in apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts - About 2 hrs to fix

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

                public static validateStatus(doc: Document): {
                    success: boolean;
                    message: string;
                    statusCode: string;
                } {
            Severity: Minor
            Found in apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts - About 25 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

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

                public static updateGlobalSettings(samlConfigs: Record<string, any>): void {
                    debug = Boolean(samlConfigs.debug);
            
                    globalSettings.generateUsername = Boolean(samlConfigs.generateUsername);
                    globalSettings.nameOverwrite = Boolean(samlConfigs.nameOverwrite);
            Severity: Minor
            Found in apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts - About 25 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

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

                public static fillTemplateData(template: string, data: Record<string, string>): string {
                    let newTemplate = template;
            
                    for (const variable in data) {
                        if (variable in data) {
            Severity: Minor
            Found in apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts - About 25 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

            There are no issues that match your filters.

            Category
            Status