Showing 105 of 105 total issues
Function contains
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
SvgObject.prototype.contains = function contains(svgObject, callback){
var self = this;
async.parallel({
ownBbox : function(c){
self.getBBox(function(bbox){
Function fromJson
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
module.exports.fromJson = function fromJson(json){
var rect = new Rect();
if(typeof json != 'undefined'){
SvgObject.fromJson(rect, json);
- 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 fromJson
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
module.exports.fromJson = function fromJson(json){
var image = new Img();
if (typeof json != 'undefined') {
SvgObject.fromJson(image, json);
- 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 _widestSegmentAtY
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Polygon.prototype._widestSegmentAtY = function _widestSegmentAtY(y) {
var segment = {
x : 0,
y : y,
width : 0
Function fromJson
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
module.exports.fromJson = function fromJson(json){
var text = new Text();
if(typeof json != 'undefined'){
SvgObject.fromJson(text, json);
- 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 calculateAllInnerBoxes
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Group.prototype.calculateAllInnerBoxes = function calculateAllInnerBoxes(callback) {
var group = new Group();
group.style = this.style;
group.classes = this.classes;
group.id = this.id;
Function toJSON
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
SvgObject.prototype.toJSON = function toJSON(matrix){
var json = {
type : this.type
};
- 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 fromNode
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
module.exports.fromNode = function fromNode(node){
var text = new Tspan();
if(typeof node != 'undefined'){
- 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 fromNode
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.fromNode = function fromNode(object, node){
if(typeof node != 'undefined' && typeof node.$ != 'undefined'){
if(typeof node.$['class'] != 'undefined'){
object.setClassesFromString(node.$['class']);
}
Function calculateAllInnerBoxes
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Svg.prototype.calculateAllInnerBoxes = function calculateAllInnerBoxes(callback) {
var svg = new Svg();
async.each(this.elements, function (child, done) {
switch (child.type) {
case 'rect' :
Function is
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
is : function(o, type) {
type = Str.prototype.toLowerCase.call(type);
if (type == "finite") {
return isFinite(o);
}
- 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 fromElement
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.fromElement = function(bbox, element){
if(typeof element.transform != 'undefined'){
var tstr = element.transform;
var res = [];
Function toXml
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
SvgObject.prototype.toXml = function toXml(matrix){
var xml = builder.create(this.type);
var style = "";
_.each(this.style, function(value, index){
Function parseJson
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Parser.parseJson = function parseJson(elements) {
var nodes = [];
_.each(elements, function (element) {
switch (element.type) {
Function fromJson
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.fromJson = function fromJson(object, json){
if(typeof json != 'undefined'){
if(typeof json.classes != 'undefined'){
object.classes = json.classes;
}
Function parseXmlNode
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Parser.parseXmlNode = function parseXmlNode(node) {
var nodes = [];
_.each(node, function (content, index) {
switch (index) {
Identical blocks of code found in 2 locations. Consider refactoring. Open
return "matrix(" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)].join() + ")";
- 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 56.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
return "m" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)];
- 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 56.
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 bbox
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
bbox : function(x, y, width, height) {
if (x == null) {
x = y = width = height = 0;
}
if (y == null) {
Function fromNode
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.fromNode = function fromNode(node) {
var image = new Img();
if (typeof node !== 'undefined' && typeof node.$ !== 'undefined') {
SvgObject.fromNode(image, node);