ysugimoto/aws-lambda-image

View on GitHub

Showing 12 of 12 total issues

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

    exec(image) {
        const acl = this.options.acl;

        return new Promise((resolve, reject) => {
            console.log("Resizing to: " + (this.options.directory || "in-place"));
Severity: Minor
Found in lib/ImageResizer.js - About 1 hr to fix

    Function processImage has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        processImage(imageData, config) {
            const acl = config.get("acl");
            const cacheControl = config.get("cacheControl");
            const bucket = config.get("bucket");
            const jpegOptimizer = config.get("jpegOptimizer", "mozjpeg");
    Severity: Minor
    Found in lib/ImageProcessor.js - About 1 hr to fix

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

                  promise = promise
                    .then(() => this.execReduceImage(reduce, imageData))
                    .then((image) => this.fileSystem.putObject(image, reduce))
                    .then(() => Promise.resolve(++processedImages));
      Severity: Major
      Found in lib/ImageProcessor.js and 1 other location - About 1 hr to fix
      lib/ImageProcessor.js on lines 101..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 73.

      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

                  promise = promise
                    .then(() => this.execResizeImage(resize, imageData))
                    .then((image) => this.fileSystem.putObject(image, resize))
                    .then(() => Promise.resolve(++processedImages));
      Severity: Major
      Found in lib/ImageProcessor.js and 1 other location - About 1 hr to fix
      lib/ImageProcessor.js on lines 84..87

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

      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 combineWithDirectory has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          combineWithDirectory(output) {
              const prefix = output.prefix || "";
              const suffix = output.suffix || "";
              const fileName = path.parse(this.baseName).name;
              const extension = ( output.keepExtension )
      Severity: Minor
      Found in lib/ImageData.js - 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 process has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function process(s3Object, callback) {
          const configPath = path.resolve(__dirname, "config.json");
          const fileSystem = new S3FileSystem();
          const processor  = new ImageProcessor(fileSystem, s3Object);
          const config     = new Config(
      Severity: Minor
      Found in index.js - About 1 hr to fix

        Function combineWithDirectory has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            combineWithDirectory(output) {
                const prefix = output.prefix || "";
                const suffix = output.suffix || "";
                const fileName = path.parse(this.baseName).name;
                const extension = ( output.keepExtension )
        Severity: Minor
        Found in lib/ImageData.js - About 1 hr to fix

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

                          image.combineWithDirectory({
                              directory:     option.directory,
                              template:      option.template,
                              prefix:        option.prefix,
                              suffix:        option.suffix,
          Severity: Major
          Found in lib/ImageReducer.js and 1 other location - About 1 hr to fix
          lib/ImageArchiver.js on lines 33..39

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

          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

                              image.combineWithDirectory({
                                  directory:     option.directory,
                                  template:      option.template,
                                  prefix:        option.prefix,
                                  suffix:        option.suffix,
          Severity: Major
          Found in lib/ImageArchiver.js and 1 other location - About 1 hr to fix
          lib/ImageReducer.js on lines 41..47

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

          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 parseEvent has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports = function parseEvent(event) {
          
              const eventRecord = event && event.Records && event.Records[0];
              if ( eventRecord ) {
                  if ( eventRecord.eventSource === "aws:s3" && eventRecord.s3 ) {
          Severity: Minor
          Found in lib/EventParser.js - About 55 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 processImage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              processImage(imageData, config) {
                  const acl = config.get("acl");
                  const cacheControl = config.get("cacheControl");
                  const bucket = config.get("bucket");
                  const jpegOptimizer = config.get("jpegOptimizer", "mozjpeg");
          Severity: Minor
          Found in lib/ImageProcessor.js - 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

          Consider simplifying this complex logical expression.
          Open

                  if ( config.exists("reduce") ) {
                      const reduce = config.get("reduce");
          
                      reduce.acl              = reduce.acl || acl;
                      reduce.cacheControl     = ( reduce.cacheControl !== undefined ) ? reduce.cacheControl : cacheControl;
          Severity: Major
          Found in lib/ImageProcessor.js - About 40 mins to fix
            Severity
            Category
            Status
            Source
            Language