tom-weatherhead/thaw-image-processing.ts

View on GitHub

Showing 71 of 71 total issues

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

              Function resampleImage has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function resampleImage(
                  srcImage: IThAWImage,
                  dstWidth: number,
                  dstHeight: number,
                  mode: number
              Severity: Minor
              Found in src/processing/resample.ts - About 1 hr to fix

                Function mapImageByCoordinatesFromBuffer has 11 arguments (exceeds 4 allowed). Consider refactoring.
                Open

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

                  Function convolve1D has 11 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      dstBuffer: ThAWImageBufferType,
                      dstInitialOffset: number,
                      numDstPixels: number,
                      dstPixelStride: number,
                      srcBuffer: ThAWImageBufferType,
                  Severity: Major
                  Found in src/util/convolve.ts - About 1 hr to fix

                    Function compositeTest has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function compositeTest(srcImage: IThAWImage): IThAWImage {
                        // const dstImage = generateTestImage_RedGreenGradient(srcImage.width, srcImage.height, fnCreateImage);
                    
                        const red = 255;
                        const green = 0;
                    Severity: Minor
                    Found in src/util/composite.ts - About 1 hr to fix

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

                          public fill(
                              dstRow: number,
                              dstColumn: number,
                              width: number,
                              height: number,
                      Severity: Minor
                      Found in src/util/image.ts - About 1 hr to fix

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

                            public fill(
                                dstRow: number,
                                dstColumn: number,
                                width: number,
                                height: number,
                        Severity: Minor
                        Found in src/util/image.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

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

                        export function desaturateImage(srcImage: IThAWImage): IThAWImage {
                            if (srcImage.colourModel !== ColourModel.RGBA32) {
                                throw new Error('desaturateImage: Unsupported colour model');
                            }
                            return mapColoursInImageFromBuffer(srcImage, desaturateRGBA);
                        Severity: Major
                        Found in src/processing/desaturate.ts and 1 other location - About 1 hr to fix
                        src/processing/desaturate.ts on lines 43..52

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

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

                        export function rotateColourChannelsInImage(
                            srcImage: IThAWImage
                        ): IThAWImage {
                            if (srcImage.colourModel !== ColourModel.RGBA32) {
                                throw new Error(
                        Severity: Major
                        Found in src/processing/desaturate.ts and 1 other location - About 1 hr to fix
                        src/processing/desaturate.ts on lines 23..28

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

                        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

                        Function resample1DNearestNeighbour has 9 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            dstBuffer: ThAWImageBufferType,
                            dstInitialOffset: number,
                            numDstPixels: number,
                            dstPixelStride: number,
                            srcBuffer: ThAWImageBufferType,
                        Severity: Major
                        Found in src/processing/resample.ts - About 1 hr to fix

                          Function resample1DBicubic has 9 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              dstBuffer: ThAWImageBufferType,
                              dstInitialOffset: number,
                              numDstPixels: number,
                              dstPixelStride: number,
                              srcBuffer: ThAWImageBufferType,
                          Severity: Major
                          Found in src/processing/resample.ts - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language