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');
- Read upRead up
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');
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;
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';
- Read upRead up
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;
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';
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
- Read upRead up
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';
- Read upRead up
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"