bemusic/bemuse

View on GitHub
bemuse/src/previewer/NotechartPreview.ts

Summary

Maintainability
D
2 days
Test Coverage

File NotechartPreview.ts has 400 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Notechart, {
  GameLandmine,
  GameNote,
  SoundedEvent,
} from 'bemuse-notechart'
Severity: Minor
Found in bemuse/src/previewer/NotechartPreview.ts - About 5 hrs to fix

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

      getViewport(currentTime: number, hiSpeed: number): PreviewViewport {
        const beat = this._secondsToBeat(currentTime)
        const position = this._notechart.beatToPosition(beat)
        const speed = this._notechart.spacingAtBeat(beat)
        const windowSize = 4 / speed / hiSpeed
    Severity: Minor
    Found in bemuse/src/previewer/NotechartPreview.ts - 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 getViewport has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      getViewport(currentTime: number, hiSpeed: number): PreviewViewport {
        const beat = this._secondsToBeat(currentTime)
        const position = this._notechart.beatToPosition(beat)
        const speed = this._notechart.spacingAtBeat(beat)
        const windowSize = 4 / speed / hiSpeed
    Severity: Major
    Found in bemuse/src/previewer/NotechartPreview.ts - About 2 hrs to fix

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

        private _advance() {
          const currentTime =
            this._samplingMaster.currentTime -
            this._startAudioTime +
            this._startSongTime
      Severity: Minor
      Found in bemuse/src/previewer/NotechartPreview.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 _advance has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private _advance() {
          const currentTime =
            this._samplingMaster.currentTime -
            this._startAudioTime +
            this._startSongTime
      Severity: Minor
      Found in bemuse/src/previewer/NotechartPreview.ts - About 1 hr to fix

        Function createNullNotechartPreview has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function createNullNotechartPreview(): NotechartPreview {
          const warning =
            location.hostname !== 'bemuse.ninja'
              ? ' [NOTE: Do not bookmark this URL because it is a preview and this URL will stop working in the future.]'
              : ''
        Severity: Minor
        Found in bemuse/src/previewer/NotechartPreview.ts - About 1 hr to fix

          Function createNotechartPreview has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            notechart: Notechart,
            filename: string,
            samplingMaster: SamplingMaster,
            soundGroup: SoundGroup,
            samples: PreviewSoundSample[]
          Severity: Minor
          Found in bemuse/src/previewer/NotechartPreview.ts - About 35 mins to fix

            Avoid too many return statements within this function.
            Open

                    return true
            Severity: Major
            Found in bemuse/src/previewer/NotechartPreview.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      if (gameNote.position < position - windowSize * 0.5) return false
              Severity: Major
              Found in bemuse/src/previewer/NotechartPreview.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        if (currentTime > gameNote.time) return false
                Severity: Major
                Found in bemuse/src/previewer/NotechartPreview.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          if (gameNote.position > position + windowSize * 1.5) return false
                  Severity: Major
                  Found in bemuse/src/previewer/NotechartPreview.ts - About 30 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status