RubyLouvre/avalon

View on GitHub
src/vtree/fromString.js

Summary

Maintainability
F
4 days
Test Coverage

Function lexer has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
Open

function lexer(string, getOne) {
    var tokens = []
    var breakIndex = 9990
    var stack = []
    var origString = string
Severity: Minor
Found in src/vtree/fromString.js - About 7 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 getAttrs has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

function getAttrs(string) {
    var state = 'AttrName',
        attrName = '',
        attrValue = '',
        quote,
Severity: Minor
Found in src/vtree/fromString.js - About 6 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

File fromString.js has 356 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * ------------------------------------------------------------
 * avalon2.2.6的新式lexer
 * 将字符串变成一个虚拟DOM树,方便以后进一步变成模板函数
 * 此阶段只会生成VElement,VText,VComment
Severity: Minor
Found in src/vtree/fromString.js - About 4 hrs to fix

    Function getOpenTag has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

    function getOpenTag(string) {
        if (string.indexOf("<") === 0) {
            var i = string.indexOf('<!--') //处理注释节点
            if (i === 0) {
                var l = string.indexOf('-->')
    Severity: Minor
    Found in src/vtree/fromString.js - About 4 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 lexer has 93 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function lexer(string, getOne) {
        var tokens = []
        var breakIndex = 9990
        var stack = []
        var origString = string
    Severity: Major
    Found in src/vtree/fromString.js - About 3 hrs to fix

      Function parseTextDir has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      function parseTextDir(string) {
          var closeTag = config.closeTag
          var openTag = config.openTag
          var closeTagFirst = closeTag.charAt(0)
          var closeTagLength = closeTag.length
      Severity: Minor
      Found in src/vtree/fromString.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 getAttrs has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function getAttrs(string) {
          var state = 'AttrName',
              attrName = '',
              attrValue = '',
              quote,
      Severity: Major
      Found in src/vtree/fromString.js - About 2 hrs to fix

        Function getOpenTag has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function getOpenTag(string) {
            if (string.indexOf("<") === 0) {
                var i = string.indexOf('<!--') //处理注释节点
                if (i === 0) {
                    var l = string.indexOf('-->')
        Severity: Major
        Found in src/vtree/fromString.js - About 2 hrs to fix

          Function insertTbody has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          function insertTbody(nodes) {
              var tbody = false
              for (var i = 0, n = nodes.length; i < n; i++) {
                  var node = nodes[i]
                  if (rtbody.test(node.nodeName)) {
          Severity: Minor
          Found in src/vtree/fromString.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 parseTextDir has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function parseTextDir(string) {
              var closeTag = config.closeTag
              var openTag = config.openTag
              var closeTagFirst = closeTag.charAt(0)
              var closeTagLength = closeTag.length
          Severity: Minor
          Found in src/vtree/fromString.js - About 1 hr to fix

            Function insertTbody has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function insertTbody(nodes) {
                var tbody = false
                for (var i = 0, n = nodes.length; i < n; i++) {
                    var node = nodes[i]
                    if (rtbody.test(node.nodeName)) {
            Severity: Minor
            Found in src/vtree/fromString.js - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                                  if (!attrName) {
                                      throw '必须指定属性名'
                                  }
              Severity: Major
              Found in src/vtree/fromString.js - About 45 mins to fix

                Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
                Open

                import { avalon, Cache, config } from '../seed/core'
                Severity: Minor
                Found in src/vtree/fromString.js by eslint

                For more information visit Source: http://eslint.org/docs/rules/

                There are no issues that match your filters.

                Category
                Status