Showing 120 of 120 total issues
Consider simplifying this complex logical expression. Open
if('fontSize' in attrs
|| 'fontFamily' in attrs
|| 'fontStyle' in attrs
|| 'fontVariant' in attrs
|| 'fontWeight' in attrs) {
Function dispatchEvent
has 83 lines of code (exceeds 50 allowed). Consider refactoring. Open
dispatchEvent(type, evt, collisionState = false, swallow = false, useCapturePhase = null) { // eslint-disable-line complexity
const handlers = this.getEventHandlers(type);
if(swallow && handlers.length === 0) {
return;
}
Function dispatchEvent
has 82 lines of code (exceeds 50 allowed). Consider refactoring. Open
dispatchEvent(type, evt, collisionState = false, swallow = false, useCapturePhase = null) { // eslint-disable-line complexity
let handlers = this.getEventHandlers(type);
if(this.children && useCapturePhase === true) handlers = handlers.filter(handler => handler.useCapture);
if(this.children && useCapturePhase === false) handlers = handlers.filter(handler => !handler.useCapture);
evt.returnValue = true;
Function computeStyle
has 81 lines of code (exceeds 50 allowed). Consider refactoring. Open
computeStyle(el) {
if(!el.attributes) return {};
el.__styleNeedUpdate = false;
if(cssRules.length <= 0) return {};
const attrs = {};
File baseattr.js
has 356 lines of code (exceeds 350 allowed). Consider refactoring. Open
import SvgPath from 'svg-path-to-canvas';
import {Matrix} from 'sprite-math';
import NodeAttr from './attr';
import {parseColorString, oneOrTwoValues, fourValuesShortCut, eightValuesShortCut,
parseStringInt, parseStringFloat, parseStringTransform,
Function resolveStates
has 77 lines of code (exceeds 50 allowed). Consider refactoring. Open
resolveStates(states, before, after) {
let currentAnimation = null,
resolved = false;
const _states = [];
Function render
has 75 lines of code (exceeds 50 allowed). Consider refactoring. Open
render(t, drawingContext) {
super.render(t, drawingContext);
const textAlign = this.attr('textAlign'),
flexible = this.attr('flexible'),
Function draw
has 75 lines of code (exceeds 50 allowed). Consider refactoring. Open
draw(t, drawingContext = this.context) { // eslint-disable-line complexity
super.draw(t, drawingContext);
if(!this.isVisible()) {
return;
Function enter
has 74 lines of code (exceeds 50 allowed). Consider refactoring. Open
enter(toState) {
const states = this.attr('states');
let ret;
if(states && (states.beforeEnter || states.afterEnter)) {
const deferred = this.resolveStates(['beforeEnter', 'afterEnter'], (_states) => {
Function relayout
has 70 lines of code (exceeds 50 allowed). Consider refactoring. Open
export function relayout(containerSprite, itemsSprite) {
itemsSprite.sort((a, b) => {
const orderA = a.attributes.order | 0,
orderB = b.attributes.order | 0;
if(orderA !== orderB) {
Function draw
has a Cognitive Complexity of 34 (exceeds 25 allowed). Consider refactoring. Open
draw(t, drawingContext = this.context) { // eslint-disable-line complexity
super.draw(t, drawingContext);
if(!this.isVisible()) {
return;
- 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 drawDot9Image
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
function drawDot9Image(drawingContext, image, clip9, borderWidth, offsetWidth, offsetHeight, clientWidth, clientHeight) {
const w = image.width,
h = image.height;
const [top, right, bottom, left] = clip9 || [16, 16, 16, 16];
Function dispatchEvent
has a Cognitive Complexity of 33 (exceeds 25 allowed). Consider refactoring. Open
dispatchEvent(type, evt, collisionState = false, swallow = false, useCapturePhase = null) { // eslint-disable-line complexity
let handlers = this.getEventHandlers(type);
if(this.children && useCapturePhase === true) handlers = handlers.filter(handler => handler.useCapture);
if(this.children && useCapturePhase === false) handlers = handlers.filter(handler => !handler.useCapture);
evt.returnValue = true;
- 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 dispatchEvent
has 61 lines of code (exceeds 50 allowed). Consider refactoring. Open
dispatchEvent(type, evt, collisionState = false, swallow = false, useCapturePhase = null) {
const handlers = this.getEventHandlers(type);
if(swallow && handlers.length === 0) {
return;
}
Function render
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
render(t, drawingContext) {
super.render(t, drawingContext);
const d = this.attr('d'),
lineWidth = this.attr('lineWidth'),
lineCap = this.attr('lineCap'),
Function calculTextboxSize
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
function calculTextboxSize(node) {
if(!node.context) return '';
const text = node.text,
font = node.attr('font'),
lineHeight = node.attr('lineHeight'),
Function sizeToPixel
has a Cognitive Complexity of 31 (exceeds 25 allowed). Consider refactoring. Open
export function sizeToPixel(value, defaultWidth) { // eslint-disable-line complexity
if(typeof value === 'string') {
const matched = value.trim().match(/^([\d.]+)(px|pt|pc|in|cm|mm|em|ex|rem|q|vw|vh|vmax|vmin|%)$/);
if(matched) {
value = {size: parseFloat(matched[1]), unit: matched[2]};
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if(width === '') {
w = boxSize[0] | 0;
if(height !== '' && boxSize[1]) {
w *= height / boxSize[1];
}
- 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 60.
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 applyRative
has a Cognitive Complexity of 31 (exceeds 25 allowed). Consider refactoring. Open
function applyRative(elementDescriptor, type) {
const {descriptor} = elementDescriptor;
const setter = descriptor.set;
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if(height === '') {
h = boxSize[1] | 0;
if(width !== '' && boxSize[0]) {
h *= width / boxSize[0];
}
- 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 60.
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