src/node/spritesvg.js
Function updateTexture
has a Cognitive Complexity of 35 (exceeds 25 allowed). Consider refactoring. Open
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
Open
dispatchPointerEvent(event) {
// 派发事件给 svg 元素,但是目前只支持派发给 svg 根元素,不支持派发给子元素
const ret = super.dispatchPointerEvent(event);
if(ret && this.attributes.passEvents && typeof MouseEvent === 'function') {
const {x, y} = event;
Function updateTexture
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
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;
Avoid deeply nested control flow statements. Open
Open
if(event.identifier === pointer.identifier) {
originalTouch = pointer;
break;
}
Avoid deeply nested control flow statements. Open
Open
if(svgNode.attributes.flexible) {
svgNode.attributes.textureRect = null;
}