GioCirque/DynamoDb-LevelDown

View on GitHub

Showing 15 of 29 total issues

Function createReadStream has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  private createReadStream(opts: IteratorOptions): Transform {
    let returnCount = 0;

    const isFinished = () => {
      return !!opts.limit && opts.limit > 0 && returnCount > opts.limit;
Severity: Minor
Found in src/lib/iterator.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 createRangeKeyCondition has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function createRangeKeyCondition(opts: IteratorOptions): DynamoDB.Types.Condition {
  const defaultStart = '\u0000';
  const defaultEnd = '\xff\xff\xff\xff\xff\xff\xff\xff';
  let result: DynamoDB.Types.Condition;

Severity: Minor
Found in src/lib/utils.ts - About 1 hr to fix

    Function createReadStream has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private createReadStream(opts: IteratorOptions): Transform {
        let returnCount = 0;
    
        const isFinished = () => {
          return !!opts.limit && opts.limit > 0 && returnCount > opts.limit;
    Severity: Minor
    Found in src/lib/iterator.ts - About 1 hr to fix

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

      export function createRangeKeyCondition(opts: IteratorOptions): DynamoDB.Types.Condition {
        const defaultStart = '\u0000';
        const defaultEnd = '\xff\xff\xff\xff\xff\xff\xff\xff';
        let result: DynamoDB.Types.Condition;
      
      
      Severity: Minor
      Found in src/lib/utils.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 _next has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async _next(cb: ErrorKeyValueCallback<any, any>) {
          const onEnd = () => {
            this.results.removeListener(EVENT_READABLE, onReadable);
            cb(undefined, undefined, undefined);
          };
      Severity: Minor
      Found in src/lib/iterator.ts - About 1 hr to fix

        Function _open has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          async _open(options: AbstractOpenOptions, cb: ErrorCallback) {
            const dynamoOptions = options.dynamoOptions || {};
        
            try {
              let { dynamoTableExists, s3BucketExists } = await Promise.all([
        Severity: Minor
        Found in src/lib/dynamoDbDown.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 extractAttachments has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function extractAttachments(key: any, value: any, definitions: AttachmentDefinition[]): AttachmentResult {
          if (!!value && isPlainObject(value) && definitions.length > 0) {
            const clone = cloneObject(value);
            const result: Attachment[] = [];
            const flattened: ExtractionItem[] = [{ key, keyPath: key, value: clone, parent: clone }];
        Severity: Minor
        Found in src/lib/utils.ts - About 1 hr to fix

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

            async _next(cb: ErrorKeyValueCallback<any, any>) {
              const onEnd = () => {
                this.results.removeListener(EVENT_READABLE, onReadable);
                cb(undefined, undefined, undefined);
              };
          Severity: Minor
          Found in src/lib/iterator.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 getDataRange has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            private async getDataRange(
              options: IteratorOptions,
              cb: (error: any, data?: DynamoDB.QueryOutput) => void
            ): Promise<void> {
              const opts = { ...options };
          Severity: Minor
          Found in src/lib/iterator.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 getDataRange has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private async getDataRange(
              options: IteratorOptions,
              cb: (error: any, data?: DynamoDB.QueryOutput) => void
            ): Promise<void> {
              const opts = { ...options };
          Severity: Minor
          Found in src/lib/iterator.ts - About 1 hr to fix

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

            export function castToBuffer(
              object: Buffer | Array<any> | string | boolean | number | null | undefined | object,
              encoding?: BufferEncoding
            ): Buffer {
              let result: Buffer;
            Severity: Minor
            Found in src/lib/utils.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 maybeSeek has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              private async maybeSeek() {
                if (!this.seekTarget) return;
                if (!this.isInRange(this.seekTarget)) return this.outOfRange();
            
                let nextKey, couldBeHere;
            Severity: Minor
            Found in src/lib/iterator.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 _open has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async _open(options: AbstractOpenOptions, cb: ErrorCallback) {
                const dynamoOptions = options.dynamoOptions || {};
            
                try {
                  let { dynamoTableExists, s3BucketExists } = await Promise.all([
            Severity: Minor
            Found in src/lib/dynamoDbDown.ts - About 1 hr to fix

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

                static factory(dynamoDb: DynamoDB, options?: DynamoDbDown.Types.Options) {
                  const func = function(location: string) {
                    globalStore[location] = globalStore[location] || new DynamoDbDown(dynamoDb, location, options);
                    return globalStore[location];
                  };
              Severity: Minor
              Found in src/lib/dynamoDbDown.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

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

                private isInRange(target: any) {
                  const { high, low, inclusiveLow, inclusiveHigh } = this.getOptionsRange();
                  const inRange =
                    (!low || (inclusiveLow && target >= low) || target > low) &&
                    (!high || (inclusiveHigh && target <= high) || target < high);
              Severity: Minor
              Found in src/lib/iterator.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