tom-weatherhead/thaw-image-processing.ts

View on GitHub

Showing 71 of 71 total issues

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

async function dispatchRotate90DegreesClockwise(
    argv: string[]
): Promise<void> {
    let srcFilePath = defaultSrcFilePath;
    let dstFilePath = `test/output-files/rotate90cw.${dstFileExtension}`;
Severity: Major
Found in src/cli.ts and 1 other location - About 1 day to fix
src/cli.ts on lines 341..376

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

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

async function dispatchRotate90DegreesCounterclockwise(
    argv: string[]
): Promise<void> {
    let srcFilePath = defaultSrcFilePath;
    let dstFilePath = `test/output-files/rotate90ccw.${dstFileExtension}`;
Severity: Major
Found in src/cli.ts and 1 other location - About 1 day to fix
src/cli.ts on lines 306..339

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

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

async function dispatchFlip(argv: string[]): Promise<void> {
    const srcFilePath = defaultSrcFilePath;
    const dstFilePath = `test/output-files/flip.${dstFileExtension}`;

    // for (let i = 0; i < argv.length; i++) {
Severity: Major
Found in src/cli.ts and 1 other location - About 4 hrs to fix
src/cli.ts on lines 180..202

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

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

async function dispatchMirror(argv: string[]): Promise<void> {
    const srcFilePath = defaultSrcFilePath;
    const dstFilePath = `test/output-files/mirror.${dstFileExtension}`;

    // for (let i = 0; i < argv.length; i++) {
Severity: Major
Found in src/cli.ts and 1 other location - About 4 hrs to fix
src/cli.ts on lines 114..136

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

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

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

                    switch (numBytesPerPixel) {
                        case 4:
                            dstBuffer[dstInitialOffset + 3] =
                                srcBuffer[srcPixelIndex + 3];
                        case 3:
        Severity: Major
        Found in src/processing/resample.ts and 1 other location - About 3 hrs to fix
        src/processing/resample.ts on lines 83..96

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

        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

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

                switch (numBytesPerPixel) {
                    case 4:
                        dstBuffer[dstInitialOffset + 3] =
                            srcBuffer[srcPixelIndex + 3];
                    case 3:
        Severity: Major
        Found in src/processing/resample.ts and 1 other location - About 3 hrs to fix
        src/processing/resample.ts on lines 126..139

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

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

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

              for (let i = 0; i < argv.length; i++) {
                  const arg = argv[i];
          
                  if (arg.substr(0, 1) !== '-') {
                      if (!srcFilePath) {
          Severity: Major
          Found in src/cli.ts and 1 other location - About 2 hrs to fix
          src/cli.ts on lines 94..104

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

          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

                  } else if (arg === '-sc') {
                      mode = engine.ResamplingMode.Bicubic;
                  } else if (i < argv.length - 1) {
                      const nextArg = argv[i + 1];
                      i++;
          Severity: Major
          Found in src/cli.ts and 1 other location - About 2 hrs to fix
          src/cli.ts on lines 214..233

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

          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

                  if (arg.substr(0, 1) !== '-') {
                      if (!srcFilePath) {
                          srcFilePath = arg;
                      } else if (!dstFilePath) {
                          dstFilePath = arg;
          Severity: Major
          Found in src/cli.ts and 1 other location - About 2 hrs to fix
          src/cli.ts on lines 267..282

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

          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

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

              for (let i = 0; i < argv.length; i++) {
                  const arg = argv[i];
          
                  if (arg.substr(0, 1) !== '-') {
                      if (!srcFilePath) {
          Severity: Major
          Found in src/cli.ts and 1 other location - About 2 hrs to fix
          src/cli.ts on lines 70..80

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

          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

          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

                Severity
                Category
                Status
                Source
                Language