ysugimoto/aws-lambda-image

View on GitHub

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

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

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