Showing 34 of 126 total issues
Function delegateEvents
has 94 lines of code (exceeds 50 allowed). Consider refactoring. Open
function delegateEvents(scene) {
const events = ['mousedown', 'mouseup', 'mousemove', 'mousewheel', 'wheel',
'touchstart', 'touchend', 'touchmove', 'touchcancel',
'click', 'dblclick', 'longpress', 'tap', 'contextmenu'];
File node.js
has 517 lines of code (exceeds 500 allowed). Consider refactoring. Open
import {mat2d} from 'gl-matrix';
import Attr from '../attribute/node';
import Animation from '../animation';
import ownerDocument from '../document';
import SpriteEvent from '../event/event';
Consider simplifying this complex logical expression. Open
if(key === 'anchorX' || key === 'anchorY' || key === 'boxSizing' || key === 'width' || key === 'height' || key === 'borderWidth'
|| key === 'paddingLeft' || key === 'paddingRight' || key === 'paddingTop' || key === 'paddingBottom'
|| /^border(TopLeft|TopRight|BottomRight|BottomLeft)Radius$/.test(key)) {
this.updateContours();
}
Consider simplifying this complex logical expression. Open
if(key === 'text' || key === 'fontSize' || key === 'fontFamily'
|| key === 'fontStyle' || key === 'fontVariant' || key === 'fontWeight'
|| key === 'fontStretch' || key === 'lineHeight'
|| key === 'strokeColor' || key === 'fillColor'
|| key === 'strokeWidth') {
Function transform
has a Cognitive Complexity of 36 (exceeds 25 allowed). Consider refactoring. Open
set transform(value) {
let _matrixValue = null;
if(Array.isArray(value)) {
_matrixValue = value;
value = `matrix(${value.map(toNumber).join()})`;
- 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 updateTexture
has a Cognitive Complexity of 35 (exceeds 25 allowed). Consider refactoring. Open
function updateTexture(svgNode, flexible = true) {
const root = svgNode[_root];
if(root && root.children[0]) {
const svg = svgNode.svg;
const displayRatio = svgNode.layer ? svgNode.layer.displayRatio : 1;
- 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 dispatchPointerEvent
has 72 lines of code (exceeds 50 allowed). Consider refactoring. Open
dispatchPointerEvent(event) {
// 派发事件给 svg 元素,但是目前只支持派发给 svg 根元素,不支持派发给子元素
const ret = super.dispatchPointerEvent(event);
if(ret && this.attributes.passEvents && typeof MouseEvent === 'function') {
const {x, y} = event;
Function dispatchPointerEvent
has 65 lines of code (exceeds 50 allowed). Consider refactoring. Open
dispatchPointerEvent(event) {
const type = event.type;
if(type === 'mousedown' || type === 'mouseup' || type === 'mousemove') {
const capturedTarget = this.__mouseCapturedTarget;
if(capturedTarget) {
Function tick
has a Cognitive Complexity of 33 (exceeds 25 allowed). Consider refactoring. Open
tick(handler = null, {duration = Infinity, ...timelineOptions} = {}) {
// this._prepareRenderFinished();
const t = this.timeline.fork(timelineOptions);
const layer = this;
- 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 sizeToPixel
has a Cognitive Complexity of 33 (exceeds 25 allowed). Consider refactoring. Open
export function sizeToPixel(value, defaultWidth) { // eslint-disable-line complexity
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]};
} else {
- 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
Consider simplifying this complex logical expression. Open
if(this[_mesh] && (key === 'strokeColor' || key === 'lineWidth' || key === 'lineCap' || key === 'lineJoin'
|| key === 'lineDash' || key === 'lineDashOffset' || key === 'roundSegments')) {
const {strokeColor, lineWidth} = this.attributes;
if(strokeColor && lineWidth > 0) {
const {lineCap, lineJoin, lineDash, lineDashOffset, miterLimit, roundSegments} = this.attributes;
Function render
has a Cognitive Complexity of 31 (exceeds 25 allowed). Consider refactoring. Open
render() {
const layers = this.orderedChildren;
let hostLayer = null;
const offscreens = [];
- 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 updateTexture
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
function updateTexture(svgNode, flexible = true) {
const root = svgNode[_root];
if(root && root.children[0]) {
const svg = svgNode.svg;
const displayRatio = svgNode.layer ? svgNode.layer.displayRatio : 1;
Function transition
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
transition(sec, easing = 'linear') {
const that = this,
_animation = Symbol('animation');
easing = easing || 'linear';
Function contentSize
has a Cognitive Complexity of 30 (exceeds 25 allowed). Consider refactoring. Open
get contentSize() {
let [w, h] = super.contentSize;
const {width, height} = this.attributes;
if(width == null || height == null) {
const img = this.textureImage;
- 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 draw
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
draw(meshes) {
super.draw(meshes);
const mesh = this.mesh;
if(mesh) {
const textImage = this[_textImage];
Consider simplifying this complex logical expression. Open
if(!texture
|| node[_textureContext] && node[_textureContext] !== renderer
|| texture.image !== textureImage
|| texture.options.repeat !== textureRepeat
|| !compareValue(texture.options.rect, textureRect)
Avoid deeply nested control flow statements. Open
if(unit === 'vmax') {
size *= Math.max(width, height) / 100;
} else {
size *= Math.min(width, height) / 100;
}
Avoid deeply nested control flow statements. Open
if(layer.prepareRender) layer.render();
Avoid deeply nested control flow statements. Open
if(svgNode.attributes.flexible) {
svgNode.attributes.textureRect = null;
}