spritejs/spritejs

View on GitHub
src/node/spritesvg.js

Summary

Maintainability
B
6 hrs
Test Coverage
F
5%

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;
Severity: Minor
Found in src/node/spritesvg.js - About 1 hr to fix

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;
Severity: Major
Found in src/node/spritesvg.js - About 1 hr to fix

    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;
    Severity: Major
    Found in src/node/spritesvg.js - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                  if(event.identifier === pointer.identifier) {
                    originalTouch = pointer;
                    break;
                  }
      Severity: Major
      Found in src/node/spritesvg.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    if(svgNode.attributes.flexible) {
                      svgNode.attributes.textureRect = null;
                    }
        Severity: Major
        Found in src/node/spritesvg.js - About 45 mins to fix

          There are no issues that match your filters.

          Category
          Status