CS-Tao/GTD-Visualization

View on GitHub
src/renderer/utils/index.js

Summary

Maintainability
D
3 days
Test Coverage

Showing 14 of 14 total issues

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

/**
* Created by jiachenpan on 16/11/18.
*/
 
export function parseTime (time, cFormat) {
Severity: Minor
Found in src/renderer/utils/index.js - About 3 hrs to fix

    Function getDateByDaysInYear has 69 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function getDateByDaysInYear (daysInYear, year) {
    var month = 0
    var day = 0
    const FEB = isLeapYear(year) ? 29 : 28
    const monthArray = [
    Severity: Major
    Found in src/renderer/utils/index.js - About 2 hrs to fix

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

      export function deepClone (source) {
      if (!source && typeof source !== 'object') {
      throw new Error('error arguments', 'shallowClone')
      }
      const targetObj = source.constructor === Array ? [] : {}
      Severity: Minor
      Found in src/renderer/utils/index.js - About 1 hr to fix

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

      export function getDateByDaysInYear (daysInYear, year) {
      var month = 0
      var day = 0
      const FEB = isLeapYear(year) ? 29 : 28
      const monthArray = [
      Severity: Minor
      Found in src/renderer/utils/index.js - About 1 hr to fix

      Function parseTime has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      export function parseTime (time, cFormat) {
      if (arguments.length === 0) {
      return null
      }
      const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
      Severity: Minor
      Found in src/renderer/utils/index.js - About 1 hr to fix

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

      export function debounce (func, wait, immediate) {
      let timeout, args, context, timestamp, result
       
      const later = function () {
      // 据上一次触发时间间隔
      Severity: Minor
      Found in src/renderer/utils/index.js - About 1 hr to fix

      Function parseTime has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function parseTime (time, cFormat) {
      if (arguments.length === 0) {
      return null
      }
      const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
      Severity: Minor
      Found in src/renderer/utils/index.js - About 1 hr to fix

        Function objectMerge has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        export function objectMerge (target, source) {
        /* Merges two objects,
        giving the last one precedence */
         
        if (typeof target !== 'object') {
        Severity: Minor
        Found in src/renderer/utils/index.js - About 55 mins to fix

        Avoid too many return statements within this function.
        Open

        return parseTime(time, option)
        Severity: Major
        Found in src/renderer/utils/index.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

          return d.getMonth() + 1 + '月' + d.getDate() + '日' + d.getHours() + '时' + d.getMinutes() + '分'
          Severity: Major
          Found in src/renderer/utils/index.js - About 30 mins to fix

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

            export function formatTime (time, option) {
            time = +time * 1000
            const d = new Date(time)
            const now = Date.now()
             
             
            Severity: Minor
            Found in src/renderer/utils/index.js - About 25 mins to fix

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

            }, {
            text: '最近一个月',
            onClick (picker) {
            const end = new Date(new Date().toDateString())
            const start = new Date()
            Severity: Major
            Found in src/renderer/utils/index.js and 2 other locations - About 3 hrs to fix
            src/renderer/utils/index.js on lines 266..274
            src/renderer/utils/index.js on lines 282..290

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

            }, {
            text: '最近一周',
            onClick (picker) {
            const end = new Date(new Date().toDateString())
            const start = new Date()
            Severity: Major
            Found in src/renderer/utils/index.js and 2 other locations - About 3 hrs to fix
            src/renderer/utils/index.js on lines 274..282
            src/renderer/utils/index.js on lines 282..290

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

            }, {
            text: '最近三个月',
            onClick (picker) {
            const end = new Date(new Date().toDateString())
            const start = new Date()
            Severity: Major
            Found in src/renderer/utils/index.js and 2 other locations - About 3 hrs to fix
            src/renderer/utils/index.js on lines 266..274
            src/renderer/utils/index.js on lines 274..282
            Category
            Status