RubyLouvre/avalon

View on GitHub
src/component/index.js

Summary

Maintainability
D
1 day
Test Coverage

Function init has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

    init: function() {
        //cached属性必须定义在组件容器里面,不是template中
        var vdom = this.node
        this.cacheVm = !!vdom.props.cached
        if (vdom.dom && vdom.nodeName === '#comment') {
Severity: Minor
Found in src/component/index.js - About 5 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 init has 108 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    init: function() {
        //cached属性必须定义在组件容器里面,不是template中
        var vdom = this.node
        this.cacheVm = !!vdom.props.cached
        if (vdom.dom && vdom.nodeName === '#comment') {
Severity: Major
Found in src/component/index.js - About 4 hrs to fix

    File index.js has 302 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { avalon, isObject, platform } from '../seed/core'
    import { cssDiff } from '../directives/css'
    import { dumpTree, groupTree, getRange } from '../renders/share'
    var legalTags = { wbr: 1, xmp: 1, template: 1 }
    var events = 'onInit,onReady,onViewChange,onDispose,onEnter,onLeave'
    Severity: Minor
    Found in src/component/index.js - About 3 hrs to fix

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

          update: function(vdom, value) {
              //this.oldValue = value //★★防止递归
      
              switch (this.readyState) {
                  case 0:
      Severity: Minor
      Found in src/component/index.js - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                                    if (Array.isArray(objectSlot[name])) {
                                        objectSlot[name].push(el)
                                    } else {
                                        objectSlot[name] = [el]
                                    }
        Severity: Major
        Found in src/component/index.js - About 45 mins to fix

          Function collectHooks has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          function collectHooks(a, list) {
              for (var i in a) {
                  if (componentEvents[i]) {
                      if (typeof a[i] === 'function' &&
                          i.indexOf('on') === 0) {
          Severity: Minor
          Found in src/component/index.js - About 35 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

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

          import { avalon, isObject, platform } from '../seed/core'
          Severity: Minor
          Found in src/component/index.js by eslint

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

          There are no issues that match your filters.

          Category
          Status