bemuse/src/previewer/NotechartPreview.ts
File NotechartPreview.ts
has 400 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import Notechart, {
GameLandmine,
GameNote,
SoundedEvent,
} from 'bemuse-notechart'
Function getViewport
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
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
- Read upRead up
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
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
Function _advance
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
private _advance() {
const currentTime =
this._samplingMaster.currentTime -
this._startAudioTime +
this._startSongTime
- Read upRead up
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
Open
private _advance() {
const currentTime =
this._samplingMaster.currentTime -
this._startAudioTime +
this._startSongTime
Function createNullNotechartPreview
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
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.]'
: ''
Function createNotechartPreview
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
notechart: Notechart,
filename: string,
samplingMaster: SamplingMaster,
soundGroup: SoundGroup,
samples: PreviewSoundSample[]
Avoid too many return
statements within this function. Open
Open
return true
Avoid too many return
statements within this function. Open
Open
if (gameNote.position < position - windowSize * 0.5) return false
Avoid too many return
statements within this function. Open
Open
if (currentTime > gameNote.time) return false
Avoid too many return
statements within this function. Open
Open
if (gameNote.position > position + windowSize * 1.5) return false