RocketChat/Rocket.Chat

View on GitHub
apps/meteor/client/lib/minimongo/bson.ts

Summary

Maintainability
D
2 days
Test Coverage

Function compareBSONValues has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

export const compareBSONValues = (a: unknown, b: unknown): number => {
    if (a === undefined) {
        return b === undefined ? 0 : -1;
    }

Severity: Minor
Found in apps/meteor/client/lib/minimongo/bson.ts - About 5 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 compareBSONValues has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const compareBSONValues = (a: unknown, b: unknown): number => {
    if (a === undefined) {
        return b === undefined ? 0 : -1;
    }

Severity: Major
Found in apps/meteor/client/lib/minimongo/bson.ts - About 2 hrs to fix

    Function getBSONTypeOrder has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const getBSONTypeOrder = (type: BSONType): number => {
        switch (type) {
            case BSONType.Null:
                return 0;
    
    
    Severity: Minor
    Found in apps/meteor/client/lib/minimongo/bson.ts - About 1 hr to fix

      Function getBSONType has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const getBSONType = <T>(v: T): BSONType => {
          if (typeof v === 'number') {
              return BSONType.Double;
          }
      
      
      Severity: Minor
      Found in apps/meteor/client/lib/minimongo/bson.ts - About 1 hr to fix

        Function getBSONType has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        export const getBSONType = <T>(v: T): BSONType => {
            if (typeof v === 'number') {
                return BSONType.Double;
            }
        
        
        Severity: Minor
        Found in apps/meteor/client/lib/minimongo/bson.ts - About 55 mins to fix

        Cognitive Complexity

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

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

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

        Further reading

        Avoid too many return statements within this function.
        Open

                return BSONType.Null;
        Severity: Major
        Found in apps/meteor/client/lib/minimongo/bson.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                          return (a as Uint8Array).length - (b as Uint8Array).length;
          Severity: Major
          Found in apps/meteor/client/lib/minimongo/bson.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                                return s;
            Severity: Major
            Found in apps/meteor/client/lib/minimongo/bson.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return BSONType.JavaScript;
              Severity: Major
              Found in apps/meteor/client/lib/minimongo/bson.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return BSONType.BinData;
                Severity: Major
                Found in apps/meteor/client/lib/minimongo/bson.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return BSONType.Date;
                  Severity: Major
                  Found in apps/meteor/client/lib/minimongo/bson.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                        return 1;
                    Severity: Major
                    Found in apps/meteor/client/lib/minimongo/bson.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                      return (a as Uint8Array)[i] < (b as Uint8Array)[i] ? -1 : 1;
                      Severity: Major
                      Found in apps/meteor/client/lib/minimongo/bson.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return BSONType.Regex;
                        Severity: Major
                        Found in apps/meteor/client/lib/minimongo/bson.ts - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return 0;
                          Severity: Major
                          Found in apps/meteor/client/lib/minimongo/bson.ts - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                return BSONType.Object;
                            Severity: Major
                            Found in apps/meteor/client/lib/minimongo/bson.ts - About 30 mins to fix

                              There are no issues that match your filters.

                              Category
                              Status