newraina/mePlayer

View on GitHub
src/js/main.js

Summary

Maintainability
D
3 days
Test Coverage

Function mePlayer has 240 lines of code (exceeds 25 allowed). Consider refactoring.
Open

root.mePlayer = function(options) {
  // 检查必填选项
  if (!(options.music && options.music.src)) {
    console.error('必须指定音乐地址哦~')
    return
Severity: Major
Found in src/js/main.js - About 1 day to fix

    Function mePlayer has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
    Open

    root.mePlayer = function(options) {
      // 检查必填选项
      if (!(options.music && options.music.src)) {
        console.error('必须指定音乐地址哦~')
        return
    Severity: Minor
    Found in src/js/main.js - About 1 day 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 main.js has 254 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { THEME_DEFAULT, THEME_MINI } from './constants'
    import * as lyric from './lyric'
    import * as utils from './utils'
    import * as spectrum from './spectrum'
    import * as selector from './selector'
    Severity: Minor
    Found in src/js/main.js - About 2 hrs to fix

      Function handlePlayClick has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function handlePlayClick() {
          var _handleMouseWheel
      
          if (audio.paused) {
            audio.play()
      Severity: Minor
      Found in src/js/main.js - About 1 hr to fix

        Function handleTimeUpdate has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function handleTimeUpdate() {
            var curTime = audio.currentTime
            var curTimeForLrc = audio.currentTime.toFixed(3)
            var playPercent = 100 * (curTime / duration)
        
        
        Severity: Minor
        Found in src/js/main.js - About 1 hr to fix

          Function handleMouseWheel has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  (function handleMouseWheel() {
                    var timer = null
                    var step = 0.05
                    _handleMouseWheel = function(event) {
                      if (timer) {
          Severity: Minor
          Found in src/js/main.js - About 1 hr to fix

            There are no issues that match your filters.

            Category
            Status