tom-weatherhead/thaw-image-processing.ts

View on GitHub
src/cli.ts

Summary

Maintainability
F
1 wk
Test Coverage

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 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 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 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 dispatchPixelate has 26 lines of code (exceeds 25 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

          Function dispatchGaussianBlur has 26 lines of code (exceeds 25 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

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

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

            async function dispatchRotate180Degrees(argv: string[]): Promise<void> {
                let srcFilePath = defaultSrcFilePath;
                let dstFilePath = `test/output-files/rotate180.${dstFileExtension}`;
            
                for (let i = 0; i < argv.length; i++) {
            Severity: Minor
            Found in src/cli.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 dispatchCompositeTest has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

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

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

            async function dispatchDesaturate(argv: string[]): Promise<void> {
                let srcFilePath = defaultSrcFilePath;
                let dstFilePath = `test/output-files/desaturate.${dstFileExtension}`;
            
                for (let i = 0; i < argv.length; i++) {
            Severity: Minor
            Found in src/cli.ts - About 35 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.
            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 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 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

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

            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

            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

            There are no issues that match your filters.

            Category
            Status