PruvoNet/squiss-ts

View on GitHub
src/Squiss.ts

Summary

Maintainability
D
2 days
Test Coverage
A
100%

File Squiss.ts has 654 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {EventEmitter} from 'events';
import {Message} from './Message';
import {ITimeoutExtenderOptions, TimeoutExtender} from './TimeoutExtender';
import {createMessageAttributes, IMessageAttributes} from './attributeUtils';
import {isString} from 'ts-type-guards';
Severity: Major
Found in src/Squiss.ts - About 1 day to fix

    Squiss has 38 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class Squiss extends (EventEmitter as new() => SquissEmitter) {
    
        public get inFlight(): number {
            return this._inFlight;
        }
    Severity: Minor
    Found in src/Squiss.ts - About 5 hrs to fix

      Function getQueueUrl has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Wontfix

          public getQueueUrl(): Promise<string> {
              if (this._queueUrl) {
                  return Promise.resolve(this._queueUrl);
              }
              const params: GetQueueUrlCommandInput = {QueueName: this._opts.queueName!};
      Severity: Minor
      Found in src/Squiss.ts - About 1 hr to fix

        Function stop has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Wontfix

            public async stop(soft?: boolean, timeout?: number): Promise<boolean> {
                if (!soft && this._activeReq) {
                    this._activeReq.abort();
                }
                this._running = this._paused = false;
        Severity: Minor
        Found in src/Squiss.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 _getBatch has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Wontfix

            private _getBatch(queueUrl: string): void {
                if (this._activeReq || !this._running) {
                    return;
                }
                const maxMessagesToGet = this._getMaxMessagesToGet();
        Severity: Minor
        Found in src/Squiss.ts - About 1 hr to fix

          Function stop has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Wontfix

              public async stop(soft?: boolean, timeout?: number): Promise<boolean> {
                  if (!soft && this._activeReq) {
                      this._activeReq.abort();
                  }
                  this._running = this._paused = false;
          Severity: Minor
          Found in src/Squiss.ts - About 1 hr to fix

            Function _initS3 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Wontfix

                private _initS3() {
                    if (this._opts.S3) {
                        if (typeof this._opts.S3 === 'function') {
                            return new this._opts.S3(this._opts.awsConfig || {});
                        } else {
            Severity: Minor
            Found in src/Squiss.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 _initSqs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Wontfix

                private _initSqs() {
                    if (this._opts.SQS) {
                        if (typeof this._opts.SQS === 'function') {
                            return new this._opts.SQS(this._opts.awsConfig || {});
                        } else {
            Severity: Minor
            Found in src/Squiss.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

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

                public getQueueMaximumMessageSize(): Promise<number> {
                    if (this._queueMaximumMessageSize) {
                        return Promise.resolve(this._queueMaximumMessageSize);
                    }
                    return this.getQueueUrl().then((queueUrl) => {
            Severity: Major
            Found in src/Squiss.ts and 1 other location - About 7 hrs to fix
            src/Squiss.ts on lines 190..207

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

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

                public getQueueVisibilityTimeout(): Promise<number> {
                    if (this._queueVisibilityTimeout) {
                        return Promise.resolve(this._queueVisibilityTimeout);
                    }
                    return this.getQueueUrl().then((queueUrl) => {
            Severity: Major
            Found in src/Squiss.ts and 1 other location - About 7 hrs to fix
            src/Squiss.ts on lines 209..226

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

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

                    if (this._opts.SQS) {
                        if (typeof this._opts.SQS === 'function') {
                            return new this._opts.SQS(this._opts.awsConfig || {});
                        } else {
                            return this._opts.SQS;
            Severity: Major
            Found in src/Squiss.ts and 1 other location - About 1 hr to fix
            src/Squiss.ts on lines 362..371

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

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

                    if (this._opts.S3) {
                        if (typeof this._opts.S3 === 'function') {
                            return new this._opts.S3(this._opts.awsConfig || {});
                        } else {
                            return this._opts.S3;
            Severity: Major
            Found in src/Squiss.ts and 1 other location - About 1 hr to fix
            src/Squiss.ts on lines 602..610

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

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

                    return this.getQueueUrl()
                        .then((queueUrl) => {
                            return this.sqs.deleteQueue({QueueUrl: queueUrl});
                        })
                        .then(() => {
            Severity: Minor
            Found in src/Squiss.ts and 1 other location - About 40 mins to fix
            src/Squiss.ts on lines 255..264

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

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

                    return this.getQueueUrl()
                        .then((queueUrl) => {
                            return this.sqs.purgeQueue({QueueUrl: queueUrl});
                        })
                        .then(() => {
            Severity: Minor
            Found in src/Squiss.ts and 1 other location - About 40 mins to fix
            src/Squiss.ts on lines 140..146

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

            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