Godzil/Crunchy

View on GitHub
src/batch.ts

Summary

Maintainability
B
6 hrs
Test Coverage

Function default has 131 lines of code (exceeds 25 allowed). Consider refactoring.
Invalid

export default function(args: string[], done: (err?: Error) => void)
{
  const config = Object.assign(cfg.load(), parse(args));
  let batchPath;

Severity: Major
Found in src/batch.ts - About 5 hrs to fix

    File batch.ts has 334 lines of code (exceeds 250 allowed). Consider refactoring.
    Wontfix

    'use strict';
    import commander = require('commander');
    import fs = require('fs');
    import path = require('path');
    import log = require('./log');
    Severity: Minor
    Found in src/batch.ts - About 4 hrs to fix

      Function get_min_filter has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      function get_min_filter(filter: string): IEpisodeNumber
      {
        if (filter !== undefined)
        {
          const tok = filter.split('-');
      Severity: Minor
      Found in src/batch.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 next has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Invalid

          (function next()
          {
            if (i >= tasksArr.length)
            {
              // Save configuration before leaving (should store info like session & other)
      Severity: Major
      Found in src/batch.ts - About 2 hrs to fix

        Function tasks has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Invalid

        function tasks(config: IConfigLine, batchPath: string, done: (err: Error, tasks?: IConfigTask[]) => void)
        {
          if (config.args.length)
          {
            return done(null, config.args.map((addressIn) =>
        Severity: Minor
        Found in src/batch.ts - About 1 hr to fix

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

          function get_min_filter(filter: string): IEpisodeNumber
          {
            if (filter !== undefined)
            {
              const tok = filter.split('-');
          Severity: Minor
          Found in src/batch.ts - About 1 hr to fix

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

            export default function(args: string[], done: (err?: Error) => void)
            {
              const config = Object.assign(cfg.load(), parse(args));
              let batchPath;
            
            
            Severity: Minor
            Found in src/batch.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 get_max_filter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Wontfix

            function get_max_filter(filter: string): IEpisodeNumber
            {
              if (filter !== undefined)
              {
                const tok = filter.split('-');
            Severity: Minor
            Found in src/batch.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

            Function split has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Invalid

            function split(value: string): string[]
            {
              let inQuote = false;
              let i: number;
              const pieces: string[] = [];
            Severity: Minor
            Found in src/batch.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

            Avoid too many return statements within this function.
            Open

              return false;
            Severity: Major
            Found in src/batch.ts - About 30 mins to fix

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

                  if (tok.length > 2)
                  {
                    log.error('Invalid episode filter \'' + filter + '\'');
                    process.exit(-1);
                  }
              Severity: Minor
              Found in src/batch.ts and 2 other locations - About 35 mins to fix
              src/batch.ts on lines 222..226
              src/batch.ts on lines 237..241

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

              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 3 locations. Consider refactoring.
              Open

                  if (tok.length > 2)
                  {
                    log.error('Invalid episode filter \'' + filter + '\'');
                    process.exit(-1);
                  }
              Severity: Minor
              Found in src/batch.ts and 2 other locations - About 35 mins to fix
              src/batch.ts on lines 237..241
              src/batch.ts on lines 270..274

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

              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 3 locations. Consider refactoring.
              Open

                      if (tok2.length > 2)
                      {
                        log.error('Invalid episode filter \'' + filter + '\'');
                        process.exit(-1);
                      }
              Severity: Minor
              Found in src/batch.ts and 2 other locations - About 35 mins to fix
              src/batch.ts on lines 222..226
              src/batch.ts on lines 270..274

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

              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