l-hammer/YDTemplate

View on GitHub
src/vetar/index.js

Summary

Maintainability
C
1 day
Test Coverage

Function replace has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

  [replace](node) {
    const con = node.textContent;
    const reg = /\{\{(.*?)\}\}/;
    // 元素节点
    if (node.nodeType === 1) {
Severity: Minor
Found in src/vetar/index.js - About 3 hrs 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 observe has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  observe(data) {
    const dep = new Dep();
    for (const key in data) {
      if ({}.hasOwnProperty.call(data, key)) {
        let val = data[key];
Severity: Minor
Found in src/vetar/index.js - About 2 hrs 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 replace has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  [replace](node) {
    const con = node.textContent;
    const reg = /\{\{(.*?)\}\}/;
    // 元素节点
    if (node.nodeType === 1) {
Severity: Minor
Found in src/vetar/index.js - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

                if (eventType && fn) {
                  node.addEventListener(eventType, fn.bind(this), false);
                }
    Severity: Major
    Found in src/vetar/index.js - About 45 mins to fix

      Function defineComputed has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        [defineComputed](key, def) {
          if (typeof def === 'function') {
            sharedPropertyDefinition.get = def;
          } else {
            sharedPropertyDefinition.get = def.get ? def.get : {};
      Severity: Minor
      Found in src/vetar/index.js - About 25 mins 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

      There are no issues that match your filters.

      Category
      Status