sohailalam2/abu

View on GitHub

Showing 18 of 18 total issues

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

export class StringValidator extends Validator {
  public static isString(options?: ValidatorOptions) {
    return Validator.createClassDecorator<string, StringValidatorOptions>(StringValidator.validateIsString, options);
  }

Severity: Minor
Found in src/data-helpers/value-object/validators/StringValidator.ts - About 2 hrs to fix

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

    function updatePackageJsonExportsIfNeededAndStopIfUpdated(generatedEntryMap) {
      const packageExports = pkg.exports;
    
      let hasUpdates = false;
    
    
    Severity: Minor
    Found in vite.config.js - About 1 hr to fix

      Function deserialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      export function deserialize<T>(value: string): T {
        // --------- undefined
        if (value === 'undefined') {
          return undefined as T;
        }
      Severity: Minor
      Found in src/data-helpers/serialize.ts - About 1 hr to fix

      Cognitive Complexity

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

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

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

      Further reading

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

      export function deserialize<T>(value: string): T {
        // --------- undefined
        if (value === 'undefined') {
          return undefined as T;
        }
      Severity: Minor
      Found in src/data-helpers/serialize.ts - About 1 hr to fix

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

          private static validateCompareTo(value: number, options?: NumberValidatorOptions) {
            const ValidationExceptionClass = options?.exceptionType || NumberValidationFailedException;
        
            if (!options || options.compare === undefined || !options.operator) {
              throw new ValidationExceptionClass('Required options parameter is missing');
        Severity: Minor
        Found in src/data-helpers/value-object/validators/NumberValidator.ts - About 1 hr to fix

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

          function updatePackageJsonExportsIfNeededAndStopIfUpdated(generatedEntryMap) {
            const packageExports = pkg.exports;
          
            let hasUpdates = false;
          
          
          Severity: Minor
          Found in vite.config.js - About 1 hr to fix

          Cognitive Complexity

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

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

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

          Further reading

          Function doMath has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private doMath(duration: Duration, isAddition = true): DateTime {
              const operand = isAddition ? 1 : -1;
              let date = new Date(this.value);
          
              if (duration.years) {
          Severity: Minor
          Found in src/date-time/DateTime.ts - About 1 hr to fix

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

            function validateBases(input: string, inputBase: number, outputBase: number) {
              if (inputBase < 2 || outputBase < 2) {
                throw new InvalidNumberBaseException(`Input Base: ${inputBase} | Output Base: ${outputBase}`);
              }
              if (inputBase > 36 || outputBase > 36) {
            Severity: Minor
            Found in src/data-helpers/conversion/numbers.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

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

              public static from(datetime: string, format: string): DateTime {
                if (!datetime || !format) {
                  throw new InvalidDateTimeException('Date string or format must not be empty or null');
                }
            
            
            Severity: Minor
            Found in src/date-time/DateTime.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

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

              public validate() {
                const { name } = this.constructor;
            
                if (this.value === null || typeof this.value === 'undefined') {
                  throw new ValueObjectCanNotBeNullException(name);
            Severity: Minor
            Found in src/data-helpers/value-object/ValueObject.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

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

              private doMath(duration: Duration, isAddition = true): DateTime {
                const operand = isAddition ? 1 : -1;
                let date = new Date(this.value);
            
                if (duration.years) {
            Severity: Minor
            Found in src/date-time/DateTime.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

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

              public static with<T extends ValueObjectType>(
                type: MessageType,
                headersOrName: MessageHeaders | MessageName,
                payloadOrSource?: T | MessageSource,
                metadataOrPayload?: MessageMetadata | T,
            Severity: Minor
            Found in src/data-helpers/value-object-message/Message.ts - About 45 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

            Avoid too many return statements within this function.
            Open

                  return date as T;
            Severity: Major
            Found in src/data-helpers/serialize.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return parsedJson as T;
              Severity: Major
              Found in src/data-helpers/serialize.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                  return String(value) as T;
                Severity: Major
                Found in src/data-helpers/serialize.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return Number(value) as T;
                  Severity: Major
                  Found in src/data-helpers/serialize.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return Symbol(sym[1]) as T;
                    Severity: Major
                    Found in src/data-helpers/serialize.ts - About 30 mins to fix

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

                        private static validatePartial(value: string, options?: StringValidatorOptions) {
                          const ValidationExceptionClass = options?.exceptionType || StringValidationFailedException;
                      
                          if (!options?.partial && !options?.startsWith && !options?.endsWith) {
                            throw new ValidationExceptionClass('Missing required option "partial" or "startsWith" or "endsWith"');
                      Severity: Minor
                      Found in src/data-helpers/value-object/validators/StringValidator.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

                      Severity
                      Category
                      Status
                      Source
                      Language