RubyLouvre/avalon

View on GitHub

Showing 347 of 347 total issues

Function each has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

avalon.each = function(obj, fn) {
    if (obj) { //排除null, undefined
        var i = 0
        if (isArrayLike(obj)) {
            for (var n = obj.length; i < n; i++) {
Severity: Minor
Found in src/seed/lang.modern.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 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 validate has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        validate: function(field, isValidateAll, event) {
    
            var promises = []
            var value = field.value
            var elem = field.dom
    Severity: Major
    Found in src/directives/validate.js - About 2 hrs to fix

      Function resetDeps has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      function resetDeps(action) {
          var prev = action.observers,
              curr = [],
              checked = {},
              ids = []
      Severity: Minor
      Found in src/vmodel/transaction.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 get has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          get() {
              if (avalon.trackingAction) {
                  this.collect() //被收集
                  var childOb = this.value
                  if (childOb && childOb.$events) {
      Severity: Minor
      Found in src/vmodel/Mutation.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 parseInterpolate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      export function parseInterpolate(dir) {
          var rlineSp = /\n\r?/g
          var str = dir.nodeValue.trim().replace(rlineSp, '')
          var tokens = []
          do {//aaa{{@bbb}}ccc
      Severity: Minor
      Found in src/parser/interpolate.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 toDOM has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          toDOM() {
              if (this.dom)
                  return this.dom
              var dom, tagName = this.nodeName
              if (avalon.modern && svgTags[tagName]) {
      Severity: Major
      Found in src/vdom/VElement.js - About 2 hrs to fix

        Function parseAttributes has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function parseAttributes(dirs, tuple ) {
            var node = tuple[0], uniq = {}, bindings = []
            var hasIf = false
            for (var name in dirs) {
                var value = dirs[name]
        Severity: Major
        Found in src/parser/attributes.js - About 2 hrs to fix

          Function toDOM has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              toDOM() {
                  if (this.dom)
                      return this.dom
                  var dom, tagName = this.nodeName
                  if (avalon.modern && svgTags[tagName]) {
          Severity: Minor
          Found in src/vdom/VElement.modern.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 updateAttrs has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          export function updateAttrs(node, attrs) {
              for (var attrName in attrs) {
                  var val = attrs[attrName]
                  /* istanbul ignore if*/
                  if (attrName.indexOf('data-') === 0 || rsvg.test(node)) {
          Severity: Minor
          Found in src/dom/attr/modern.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 css has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          avalon.css = function (node, name, value, fn) {
              //读写删除元素节点的样式
              if (node instanceof avalon) {
                  node = node[0]
              }
          Severity: Minor
          Found in src/dom/css/share.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 updateDataEvents has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          export function updateDataEvents(dom, data) {
              var events = {}
              //添加需要监听的事件
              switch (data.dtype) {
                  case 'radio':
          Severity: Minor
          Found in src/directives/duplex/updateDataEvents.modern.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 diff has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              diff: function(newVal, oldVal) {
                  if (Object(newVal) === newVal) {
                      newVal = platform.toJson(newVal) //安全的遍历VBscript
                      if (Array.isArray(newVal)) { //转换成对象
                          var b = {}
          Severity: Minor
          Found in src/directives/css.js - About 1 hr to fix

            Function readString has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            function readString(str, i, ret) {
                var end = false,
                    s = 0,
                    i = i || 0
                ret = ret || [];
            Severity: Minor
            Found in src/vtree/clearString.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 iOSversion has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            function iOSversion() {
                //https://developer.apple.com/library/prerelease/mac/releasenotes/General/WhatsNewInSafari/Articles/Safari_9.html
                //http://mp.weixin.qq.com/s?__biz=MzA3MDQ4MzQzMg==&mid=256900619&idx=1&sn=b29f84cff0b8d7b9742e5d8b3cd8f218&scene=1&srcid=1009F9l4gh9nZ7rcQJEhmf7Q#rd
                if (/iPad|iPhone|iPod/i.test(ua) && !window.MSStream) {
                    if ("backdropFilter" in document.documentElement.style) {
            Severity: Minor
            Found in src/gesture/recognizer.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 select:get has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                'select:get': function (node, value) {
                    var option, options = node.options,
                        index = node.selectedIndex,
                        getter = valHooks['option:get'],
                        one = node.type === 'select-one' || index < 0,
            Severity: Minor
            Found in src/dom/val/compact.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 'collectTemplate' has a complexity of 8.
            Open

            function collectTemplate(vdoms, obj) {
            Severity: Minor
            Found in src/renders/serverRender.js by eslint

            Limit Cyclomatic Complexity (complexity)

            Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

            function a(x) {
                if (true) {
                    return x; // 1st path
                } else if (false) {
                    return x+1; // 2nd path
                } else {
                    return 4; // 3rd path
                }
            }

            Rule Details

            This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

            Examples of incorrect code for a maximum of 2:

            /*eslint complexity: ["error", 2]*/
            
            function a(x) {
                if (true) {
                    return x;
                } else if (false) {
                    return x+1;
                } else {
                    return 4; // 3rd path
                }
            }

            Examples of correct code for a maximum of 2:

            /*eslint complexity: ["error", 2]*/
            
            function a(x) {
                if (true) {
                    return x;
                } else {
                    return 4;
                }
            }

            Options

            Optionally, you may specify a max object property:

            "complexity": ["error", 2]

            is equivalent to

            "complexity": ["error", { "max": 2 }]

            Deprecated: the object property maximum is deprecated. Please use the property max instead.

            When Not To Use It

            If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

            Further Reading

            Related Rules

            • [max-depth](max-depth.md)
            • [max-len](max-len.md)
            • [max-nested-callbacks](max-nested-callbacks.md)
            • [max-params](max-params.md)
            • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

            Function getPlainObject has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

            function getPlainObject(v) {
                if (v && typeof v === 'object') {
                    if (v && v.$events) {
                        return v.$model
                    } else if (Array.isArray(v)) {
            Severity: Minor
            Found in src/vmodel/Action.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 classNames has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

            function classNames() {
                var classes = []
                for (var i = 0; i < arguments.length; i++) {
                    var arg = arguments[i]
                    var argType = typeof arg
            Severity: Minor
            Found in src/directives/class.hover.active.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 validate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                validate: function(field, isValidateAll, event) {
            
                    var promises = []
                    var value = field.value
                    var elem = field.dom
            Severity: Minor
            Found in src/directives/validate.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

            Severity
            Category
            Status
            Source
            Language