tom-weatherhead/thaw-image-processing.ts

View on GitHub

Showing 49 of 71 total issues

Function pixelateImage has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

export function pixelateImage(
    srcImage: IThAWImage,
    pixelWidth: number,
    pixelHeight?: number
): IThAWImage {
Severity: Minor
Found in src/processing/pixelate.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

File resample.ts has 309 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// thaw-image-processing.ts/src/resample.ts

// See http://entropymine.com/imageworsener/bicubic/ :

// Cubic resampling
Severity: Minor
Found in src/processing/resample.ts - About 3 hrs to fix

    Function resample1DBicubic has 84 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function resample1DBicubic(
        dstBuffer: ThAWImageBufferType,
        dstInitialOffset: number,
        numDstPixels: number,
        dstPixelStride: number,
    Severity: Major
    Found in src/processing/resample.ts - About 3 hrs to fix

      Function convolve1D has 84 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function convolve1D(
          dstBuffer: ThAWImageBufferType,
          dstInitialOffset: number,
          numDstPixels: number,
          dstPixelStride: number,
      Severity: Major
      Found in src/util/convolve.ts - About 3 hrs to fix

        Function pixelateImage has 74 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function pixelateImage(
            srcImage: IThAWImage,
            pixelWidth: number,
            pixelHeight?: number
        ): IThAWImage {
        Severity: Major
        Found in src/processing/pixelate.ts - About 2 hrs to fix

          File cli.ts has 276 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          // thaw-image-processing.ts/src/cli.ts
          
          // E.g. : npm start -- -sc -w 235 -h 763 in.jpg out.jpg -q 34
          
          import * as fs from 'fs';
          Severity: Minor
          Found in src/cli.ts - About 2 hrs to fix

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

            async function dispatchResample(argv: string[]): Promise<void> {
                let srcFilePath = defaultSrcFilePath;
                let dstFilePath = `test/output-files/resample.${dstFileExtension}`;
                let dstWidth = 0;
                let dstHeight = 0;
            Severity: Minor
            Found in src/cli.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 resample1DBilinear has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function resample1DBilinear(
                dstBuffer: ThAWImageBufferType,
                dstInitialOffset: number,
                numDstPixels: number,
                dstPixelStride: number,
            Severity: Major
            Found in src/processing/resample.ts - About 2 hrs to fix

              Function doAffineTransformation has 49 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function doAffineTransformation(
                  dstImage: IThAWImage,
                  srcImage: IThAWImage,
                  matrix: IAffineTransformationMatrix,
                  dstLeft?: number,
              Severity: Minor
              Found in src/processing/affine.ts - About 1 hr to fix

                Function resample1DBicubic has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                function resample1DBicubic(
                    dstBuffer: ThAWImageBufferType,
                    dstInitialOffset: number,
                    numDstPixels: number,
                    dstPixelStride: number,
                Severity: Minor
                Found in src/processing/resample.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 convolve1D has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                function convolve1D(
                    dstBuffer: ThAWImageBufferType,
                    dstInitialOffset: number,
                    numDstPixels: number,
                    dstPixelStride: number,
                Severity: Minor
                Found in src/util/convolve.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 compositeImageFromBuffers has 15 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    dstBuffer: ThAWImageBufferType,
                    dstWidth: number,
                    dstHeight: number,
                    dstInitialRowOffset: number,
                    dstRowStride: number,
                Severity: Major
                Found in src/util/composite.ts - About 1 hr to fix

                  Function dispatchResample has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  async function dispatchResample(argv: string[]): Promise<void> {
                      let srcFilePath = defaultSrcFilePath;
                      let dstFilePath = `test/output-files/resample.${dstFileExtension}`;
                      let dstWidth = 0;
                      let dstHeight = 0;
                  Severity: Minor
                  Found in src/cli.ts - About 1 hr to fix

                    Function compositeImageFromBuffers has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function compositeImageFromBuffers(
                        dstBuffer: ThAWImageBufferType,
                        dstWidth: number,
                        dstHeight: number,
                        dstInitialRowOffset: number,
                    Severity: Minor
                    Found in src/util/composite.ts - About 1 hr to fix

                      Function generateKernel has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export function generateKernel(sigma: number, kernelSize: number): number[] {
                          // sigma must be a positive number.
                          // kernelSize must be an odd positive integer smaller than 999.
                          const sampleCount = 1000.0;
                      
                      
                      Severity: Minor
                      Found in src/processing/gaussian-blur.ts - About 1 hr to fix

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

                        export function convolveImageFromBuffer(
                            srcImage: IThAWImage,
                            kernel: number[]
                            // sigma: number,
                            // kernelSize: number /*, fnCreateImage */
                        Severity: Minor
                        Found in src/util/convolve.ts - About 1 hr to fix

                          Function dispatch has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          async function dispatch(argv: string[]): Promise<void> {
                              const command = argv.shift();
                          
                              switch (command) {
                                  case 'c':
                          Severity: Minor
                          Found in src/cli.ts - About 1 hr to fix

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

                            async function dispatchPixelate(argv: string[]): Promise<void> {
                                let srcFilePath = defaultSrcFilePath;
                                let dstFilePath = `test/output-files/pixelate.${dstFileExtension}`;
                                let pixelWidth = 8;
                                let pixelHeight = 8;
                            Severity: Minor
                            Found in src/cli.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 doAffineTransformation has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export function doAffineTransformation(
                                dstImage: IThAWImage,
                                srcImage: IThAWImage,
                                matrix: IAffineTransformationMatrix,
                                dstLeft?: number,
                            Severity: Minor
                            Found in src/processing/affine.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 dispatchGaussianBlur has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                            async function dispatchGaussianBlur(argv: string[]): Promise<void> {
                                let srcFilePath = defaultSrcFilePath;
                                let dstFilePath = `test/output-files/gaussian-blur.${dstFileExtension}`;
                                // let sigma = 1.0;
                                let sigma = 4.0;
                            Severity: Minor
                            Found in src/cli.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

                            Severity
                            Category
                            Status
                            Source
                            Language