RubyLouvre/avalon

View on GitHub
src/seed/lang.compact.js

Summary

Maintainability
D
1 day
Test Coverage

Function innerExtend has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

function innerExtend(isDeep, array) {
    var target = array[0],
        copyIsArray, clone, name
    for (var i = 1, length = array.length; i < length; i++) {
        //只处理非空参数
Severity: Minor
Found in src/seed/lang.compact.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 each has a Cognitive Complexity of 19 (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.compact.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 innerExtend has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function innerExtend(isDeep, array) {
    var target = array[0],
        copyIsArray, clone, name
    for (var i = 1, length = array.length; i < length; i++) {
        //只处理非空参数
Severity: Minor
Found in src/seed/lang.compact.js - About 1 hr to fix

    Function isArrayLike has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    export function isArrayLike(obj) {
        if (!obj)
            return false
        var n = obj.length
        if (n === (n >>> 0)) { //检测length属性是否为非负整数
    Severity: Minor
    Found in src/seed/lang.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 isPlainObjectCompact has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    export function isPlainObjectCompact(obj, key) {
        if (!obj || avalon.type(obj) !== 'object' || obj.nodeType || avalon.isWindow(obj)) {
            return false
        }
        try { //IE内置对象没有constructor
    Severity: Minor
    Found in src/seed/lang.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 compaceQuote has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export var compaceQuote = (function() {
        //https://github.com/bestiejs/json3/blob/master/lib/json3.js
        var Escapes = {
            92: "\\\\",
            34: '\\"',
    Severity: Minor
    Found in src/seed/lang.compact.js - About 1 hr to fix

      Avoid too many return statements within this function.
      Open

                  return !obj.window //IE6-8 window
      Severity: Major
      Found in src/seed/lang.compact.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return true
        Severity: Major
        Found in src/seed/lang.compact.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return false
          Severity: Major
          Found in src/seed/lang.compact.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return key === undefined || ohasOwn.call(obj, key)
            Severity: Major
            Found in src/seed/lang.compact.js - About 30 mins to fix

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

              import './lang.fix'
              Severity: Minor
              Found in src/seed/lang.compact.js by eslint

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

              There are no issues that match your filters.

              Category
              Status