bemusic/bemuse

View on GitHub

Showing 274 of 508 total issues

Function _getScratch has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function _getScratch(input) {
    const objects = context.refs['p1_SC']
    if (!objects) return 0
    scratchY = null
    for (const p of input) {
Severity: Minor
Found in bemuse/src/game/input/touch-plugin.js - About 1 hr to fix

    Function removeFolders has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    async function removeFolders(
      state: CustomFolderState,
      handle: FileSystemDirectoryHandle,
      io: CustomFolderScanIO
    ): Promise<ScanIterationResult | undefined> {
    Severity: Minor
    Found in bemuse/src/custom-folder/index.ts - About 1 hr to fix

      Function BarDots has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const BarDots: FC<BarDots> = (props) => {
        const { measureInfo } = props
        if (!measureInfo.measureEndBeat) return null
        const measureSize = measureInfo.measureEndBeat - measureInfo.measureStartBeat
        if (!measureSize) return null
      Severity: Minor
      Found in bemuse/src/previewer/PreviewInfo.tsx - About 1 hr to fix

        Function MusicInfoTabs has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const MusicInfoTabs = (props: MusicInfoTabsProps) => {
          const [selectedTab, setSelectedTab] = useState(0)
          const onClick = (index: number) => () => setSelectedTab(index)
          return (
            <section className='MusicInfoTabs'>
        Severity: Minor
        Found in bemuse/src/app/ui/MusicInfoTabs.tsx - About 1 hr to fix

          Function simultaneous has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function simultaneous(target: Progress) {
            const queue: Progress[] = []
            let current: Progress | undefined
            let unsubscribe: (() => void) | null = null
            function update() {
          Severity: Minor
          Found in bemuse/src/progress/utils.ts - About 1 hr to fix

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

            function Cache(path) {
              const data = load()
              const stream = fs.createWriteStream(path, { encoding: 'utf-8', flags: 'a' })
            
              function load() {
            Severity: Minor
            Found in packages/bemuse-tools/src/indexer.js - About 1 hr to fix

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

              function _copyAndTrimNpmrcFile(logger, sourceNpmrcPath, targetNpmrcPath) {
                  logger.info(`Transforming ${sourceNpmrcPath}`); // Verbose
                  logger.info(`  --> "${targetNpmrcPath}"`);
                  let npmrcFileLines = fs.readFileSync(sourceNpmrcPath).toString().split('\n');
                  npmrcFileLines = npmrcFileLines.map((line) => (line || '').trim());
              Severity: Minor
              Found in common/scripts/install-run.js - About 1 hr to fix

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

                  static fromBMSChart(chart: BMSChart) {
                    void BMSChart
                    const segments: SpeedSegment[] = []
                    let x = 0
                    segments.push({
                Severity: Minor
                Found in packages/bms/src/positioning/index.ts - About 1 hr to fix

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

                    static fromBMSChart(chart: BMSChart) {
                      void BMSChart
                      const info: Partial<ISongInfoData> = {}
                      let title = chart.headers.get('title')
                      const artist = chart.headers.get('artist')
                  Severity: Minor
                  Found in packages/bms/src/song-info/index.ts - About 1 hr to fix

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

                      constructor(
                        base: string | URL | IResources,
                        options: {
                          metadataFilename?: string
                          fallback?: string | IResources
                    Severity: Minor
                    Found in bemuse/src/resources/bemuse-package.ts - About 1 hr to fix

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

                        static fromBMSChart(chart: BMSChart) {
                          void BMSChart
                          const segments: SpacingSegment[] = []
                          chart.objects.allSorted().forEach(function (object) {
                            if (object.channel === 'SP') {
                      Severity: Minor
                      Found in packages/bms/src/spacing/index.ts - About 1 hr to fix

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

                        const Content = () => {
                          const [state, setState] = useState<LoadState>({ type: 'loading' })
                          useEffect(
                            () =>
                              void (async () => {
                        Severity: Minor
                        Found in website/src/pages/music.tsx - About 1 hr to fix

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

                            constructor (options) {
                              this._context = options.context
                              this._object = options.object
                              this._children = options.children
                              this._bindings = []
                          Severity: Minor
                          Found in bemuse/src/scintillator/nodes/lib/instance.js - About 1 hr to fix

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

                            export function gameFinish(song, chart, gameState, gameMode) {
                              const player = gameState.game.players[0]
                              const notechart = player.notechart
                              const state = gameState.player(player)
                              const stats = state.stats
                            Severity: Minor
                            Found in bemuse/src/app/analytics.js - About 1 hr to fix

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

                                const play = () => {
                                  state口.next({ type: 'started' })
                                  const remote = music({
                                    a() {
                                      const latency = Math.max(0, getLatency(samples))
                              Severity: Minor
                              Found in bemuse/src/auto-synchro/index.tsx - 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 showResult has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  function showResult(
                                    player: Player,
                                    playerState: PlayerState,
                                    chart: Chart,
                                    sceneDisplayContext: SceneDisplayContext
                                  Severity: Minor
                                  Found in bemuse/src/app/game-launcher.tsx - About 1 hr to fix

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

                                        const song = await new Promise<Song>((resolve, reject) => {
                                          const worker = new Worker(
                                            // @ts-ignore
                                            new URL('./song-loader.worker.js', import.meta.url)
                                          )
                                    Severity: Minor
                                    Found in bemuse/src/custom-song-loader/index.ts - About 1 hr to fix

                                      Function hasScratch has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                      export function hasScratch(bmson: Bmson) {
                                        const soundChannels = soundChannelsForBmson(bmson)
                                        if (soundChannels) {
                                          for (const { notes } of soundChannels) {
                                            for (const { x } of notes) {
                                      Severity: Minor
                                      Found in packages/bmson/src/index.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 download has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                      export function download(
                                        url,
                                        { getRetryDelay = () => 1000 + Math.random() * 4000 } = {}
                                      ) {
                                        return {
                                      Severity: Minor
                                      Found in bemuse/src/utils/download.js - 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

                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language