bemusic/bemuse

View on GitHub
bemuse/src/game/state/player-state.ts

Summary

Maintainability
D
2 days
Test Coverage

File player-state.ts has 313 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import _ from 'lodash'

import PlayerStats from './player-stats'
import {
  MISSED,
Severity: Minor
Found in bemuse/src/game/state/player-state.ts - About 3 hrs to fix

    Function _judgeNote has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

      _judgeNote(note: GameNote) {
        let delta = this._gameTime - note.time
        let judgment = judgeTime(this._gameTime, note.time, this._judge)
        let result = this._noteResult.get(note)
        const isDown = !result || result.status === 'unjudged'
    Severity: Minor
    Found in bemuse/src/game/state/player-state.ts - About 3 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 _judgeColumn has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

      _judgeColumn(buffer: NoteBuffer, control: Control, column: string) {
        let judgedNote
        let judgment
        const notes = buffer.notes
        let autoPlayed = false
    Severity: Minor
    Found in bemuse/src/game/state/player-state.ts - 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 _judgeNote has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _judgeNote(note: GameNote) {
        let delta = this._gameTime - note.time
        let judgment = judgeTime(this._gameTime, note.time, this._judge)
        let result = this._noteResult.get(note)
        const isDown = !result || result.status === 'unjudged'
    Severity: Minor
    Found in bemuse/src/game/state/player-state.ts - About 1 hr to fix

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

        _shouldJudge(note: GameNote, control: Control, buffer: NoteBuffer) {
          const status = this.getNoteStatus(note)
          if (status === 'unjudged') {
            if (this._shouldAutoplay() && this._gameTime >= note.time) {
              this.tainted = true
      Severity: Minor
      Found in bemuse/src/game/state/player-state.ts - 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 _judgeColumn has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _judgeColumn(buffer: NoteBuffer, control: Control, column: string) {
          let judgedNote
          let judgment
          const notes = buffer.notes
          let autoPlayed = false
      Severity: Minor
      Found in bemuse/src/game/state/player-state.ts - About 1 hr to fix

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

          _shouldJudge(note: GameNote, control: Control, buffer: NoteBuffer) {
            const status = this.getNoteStatus(note)
            if (status === 'unjudged') {
              if (this._shouldAutoplay() && this._gameTime >= note.time) {
                this.tainted = true
        Severity: Minor
        Found in bemuse/src/game/state/player-state.ts - About 1 hr to fix

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

            _updateSpeed() {
              if (this.getPlayerInput('speedup').justPressed) {
                this._modifySpeed(+1)
              }
              if (this.getPlayerInput('speeddown').justPressed) {
          Severity: Minor
          Found in bemuse/src/game/state/player-state.ts - 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

          Avoid too many return statements within this function.
          Open

                return false
          Severity: Major
          Found in bemuse/src/game/state/player-state.ts - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status