Showing 31 of 31 total issues
Function exports
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(root) {
// root required
if (!root) throw new Error('ribs.middleware() root path required');
Function cropConstraintsHook
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
hooks.cropConstraintsHook = function(params, image) {
var dstWidth = params.width,
dstHeight = params.height,
anchor = params.anchor,
gravity = params.gravity,
- 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 use
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
Pipeline.prototype.use = function(name, params) {
// bypass on error
if (this.error) return this;
try {
- 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 exports
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(grunt) {
// load npm tasks
require('load-grunt-tasks')(grunt);
// load time grunt
require('time-grunt')(grunt);
Function parseArguments
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parseArguments() {
var src = args._[0],
dst = args._[1],
operations;
Function parseOperations
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parseOperations(req, next, callback) {
var url = req.url,
operations = [],
current;
Function to
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
function to(params, image, next) {
// arguments type
check('next', next, false, 'function');
try {
Function computeFormula
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
utils.computeFormula = function(formula, number) {
var f = parseFloat(formula),
i, o, v, len;
// early return for falsy values
- 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 cropConstraintsHook
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
hooks.cropConstraintsHook = function(params, image) {
var dstWidth = params.width,
dstHeight = params.height,
anchor = params.anchor,
gravity = params.gravity,
Function use
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Pipeline.prototype.use = function(name, params) {
// bypass on error
if (this.error) return this;
try {
Function crop
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function crop(params, image, next) {
var width, height;
// arguments type
check('next', next, false, 'function');
Function ribs
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
var ribs = function(src, dst, bulk, callback) {
var pipeline = new Pipeline();
/** `(bulk, callback)` */
- 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 exports
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function(root) {
// root required
if (!root) throw new Error('ribs.middleware() root path required');
- 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 resizeConstraintsHook
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
hooks.resizeConstraintsHook = function(params, image) {
var dstWidth = params.width,
dstHeight = params.height,
srcWidth = image.width,
srcHeight = image.height;
- 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 from
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function from(src, next) {
check('next', next, false, 'function');
try {
check('params', src, false, 'string', 'object', 'array');
Function resizeConstraintsHook
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
hooks.resizeConstraintsHook = function(params, image) {
var dstWidth = params.width,
dstHeight = params.height,
srcWidth = image.width,
srcHeight = image.height;
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (~anchor.indexOf('l')) coords.x = x;
else if (~anchor.indexOf('r')) coords.x = x - width;
else coords.x = x - Math.round(width / 2);
- Read upRead up
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 58.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (~anchor.indexOf('t')) coords.y = y;
else if (~anchor.indexOf('b')) coords.y = y - height;
else coords.y = y - Math.round(height / 2);
- Read upRead up
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 58.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function resize
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function resize(params, image, next) {
// arguments type
check('next', next, false, 'function');
try {
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (0 === dstHeight)
dstHeight = srcHeight;
else if (dstHeight < 0)
dstHeight = srcHeight + 2 * dstHeight;
else if (dstHeight > srcHeight)
- Read upRead up
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 57.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76