ynakajima/png2psd

View on GitHub

Showing 8 of 10 total issues

Function encode has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

exports.encode = function(data) {
  var result = [];

  if (data.length === 0) return new Error('buffer length is 0');
  
Severity: Minor
Found in lib/util/packbits.js - About 3 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 encode has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.encode = function(data) {
  var result = [];

  if (data.length === 0) return new Error('buffer length is 0');
  
Severity: Major
Found in lib/util/packbits.js - About 2 hrs to fix

    Function _createLayerBlockBuffer has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function _createLayerBlockBuffer(psd) {
      if (psd.layers.length === 0) {
        var nullLayer = new jDataView(4);
        nullLayer.writeUint32(0);
        return nullLayer;
    Severity: Minor
    Found in lib/psd/psd.js - About 1 hr to fix

      Function ImageData has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      function ImageData(width, height, colorSpace, pixcels) {
        // init params
        this.width = (typeof width === 'number') ? width : 0;
        this.height = (typeof height === 'number') ? height : 0;
        this.colorSpace = colorSpace.match(/^(gray|rgb)a?$/) ? colorSpace : 'rgba';
      Severity: Minor
      Found in lib/psd/image.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 toBinary has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Layer.prototype.toBinary = function() {
        var that = this;
      
        // Layer record
        var numChannel = this.channels.length;
      Severity: Minor
      Found in lib/psd/layer.js - About 1 hr to fix

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

        function ImageData(width, height, colorSpace, pixcels) {
          // init params
          this.width = (typeof width === 'number') ? width : 0;
          this.height = (typeof height === 'number') ? height : 0;
          this.colorSpace = colorSpace.match(/^(gray|rgb)a?$/) ? colorSpace : 'rgba';
        Severity: Minor
        Found in lib/psd/image.js - About 1 hr to fix

          Function convertPNG2PSD has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          function convertPNG2PSD (png, callback) {
            // create psd data
            var psd = new PSD(png.width, png.height, png.colorSpace);
          
            // append layer
          Severity: Minor
          Found in index.js - About 25 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 PSD has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          function PSD(width, height, colorSpace) {
            // init params
            this.width = (typeof width === 'number') ? width : 0;
            this.height = (typeof height === 'number') ? height : 0;
            this.colorSpace = colorSpace.match(/^(gray|rgb)a?$/) ? colorSpace : 'rgba';
          Severity: Minor
          Found in lib/psd/psd.js - About 25 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

          Severity
          Category
          Status
          Source
          Language