bemusic/bemuse

View on GitHub

Showing 274 of 508 total issues

Function _copyAndTrimNpmrcFile has a Cognitive Complexity of 18 (exceeds 5 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 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 ComboBox has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function ComboBox<T extends ComboBoxItem>(props: {
  items: T[]
  onSelect: (item: T) => void
}) {
  const [inputItems, setInputItems] = useState(props.items)
Severity: Major
Found in bemuse/src/ui-dialogs/ComboBox.tsx - About 2 hrs to fix

    File index.ts has 266 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import _ from 'lodash'
    import * as BMS from 'bms'
    import invariant from 'invariant'
    import {
      NotechartInput,
    Severity: Minor
    Found in packages/bemuse-notechart/src/index.ts - About 2 hrs to fix

      Function updateFolders has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

        File MusicTable.tsx has 264 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import _ from 'lodash'
        import MusicSelectPreviewer from 'bemuse/music-previewer/MusicSelectPreviewer'
        import getPlayableCharts from 'bemuse/music-collection/getPlayableCharts'
        import getPreviewResourceUrl from 'bemuse/music-collection/getPreviewResourceUrl'
        import groupSongsIntoCategories from 'bemuse/music-collection/groupSongsIntoCategories'
        Severity: Minor
        Found in bemuse/src/music-collection-viewer/MusicTable.tsx - About 2 hrs to fix

          Consider simplifying this complex logical expression.
          Open

            if (!original || score > original.score) {
              return Object.assign({}, original || {}, {
                id: original?.id || ObjectID.generate(),
                score: score,
                playCount: nextPlayCount,
          Severity: Critical
          Found in bemuse/src/online/scoreboard-system/createFakeScoreboardClient.ts - About 2 hrs to fix

            Function getSongInfo has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            async function getSongInfo(
              files: IndexingInputFile[],
              options?: {
                cache?: {
                  get(md5: string): OutputFileInfo
            Severity: Major
            Found in packages/bemuse-indexer/src/index.ts - About 2 hrs to fix

              File index.js has 262 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              const yargs = require('yargs')
              const execa = require('execa')
              const vfs = require('vinyl-fs')
              const fs = require('fs')
              const merge = require('merge-stream')
              Severity: Minor
              Found in build-scripts/index.js - About 2 hrs to fix

                Function updateChangelog has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function updateChangelog(existingChangelog, entries, version = 'UNRELEASED') {
                  const userListRegExp = /((?:\[@\w+\]: https.+\n)+)/
                  const userList = existingChangelog.match(userListRegExp)
                  if (!userList) {
                    throw new Error('Cannot find user list in changelog')
                Severity: Major
                Found in build-scripts/lib/changelog.js - About 2 hrs to fix

                  Function slicesForNotesAndTiming has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function slicesForNotesAndTiming(
                    notes: Note[],
                    timing: BMS.Timing,
                    options: { beatForPulse: (pulse: number) => number }
                  ) {
                  Severity: Minor
                  Found in packages/bmson/src/utils.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

                  File Options.ts has 259 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import { PayloadAction, createSlice } from '@reduxjs/toolkit'
                  
                  import { Draft } from 'immer'
                  import { MappingMode } from '../../rules/mapping-mode'
                  import { StoredOptions } from '../types'
                  Severity: Minor
                  Found in bemuse/src/app/entities/Options.ts - About 2 hrs to fix

                    Function ChildManager has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function ChildManager(expr, child, poolSize) {
                      return {
                        instantiate(context, subject) {
                          const instances = new Map()
                          const pool = []
                    Severity: Major
                    Found in bemuse/src/scintillator/nodes/object.js - About 2 hrs to fix

                      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 getName has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function getName(key: string) {
                          if (+key) {
                            return _.capitalize(keycode(+key))
                          }
                          {
                        Severity: Major
                        Found in bemuse/src/omni-input/index.ts - About 2 hrs to fix

                          Function music has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function music(master: SamplingMaster, samples: Samples) {
                            return function play(callbacks: { a: () => void }) {
                              master.unmute()
                          
                              const BPM = 148
                          Severity: Major
                          Found in bemuse/src/auto-synchro/music/index.ts - About 2 hrs to fix

                            Function createFader has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function createFader(audio, initialVolume, onTargetReached) {
                              let targetVolume = 0
                              let currentSpeed = 0
                              let requested = false
                              let volumeChanged
                            Severity: Minor
                            Found in bemuse/src/music-previewer/index.js - 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 findVideoUrl has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                            Open

                            async function findVideoUrl(song: Song, assets: LoadSpec['assets']) {
                              if (song.video_url) {
                                return song.video_url
                              }
                              if (song.video_file) {
                            Severity: Minor
                            Found in bemuse/src/app/game-launcher.tsx - 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 constructor has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              constructor(initialBPM: number, actions: TimingAction[]) {
                                const state = { bpm: initialBPM, beat: 0, seconds: 0 }
                                const segments: TimingSegment[] = []
                                segments.push({
                                  t: 0,
                            Severity: Major
                            Found in packages/bms/src/timing/index.ts - About 2 hrs to fix

                              Function _setupInteractivity has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                _setupInteractivity() {
                                  let mouse = null
                                  let touches = []
                                  const onMouse = (e) => {
                                    mouse = e
                              Severity: Major
                              Found in bemuse/src/scintillator/context.js - About 2 hrs to fix

                                Function exports has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                module.exports = function (config) {
                                  config.set({
                                    // Make Karma work with pnpm.
                                    // See: https://github.com/pnpm/pnpm/issues/720#issuecomment-954120387
                                    plugins: Object.keys(require('./package').devDependencies).flatMap(
                                Severity: Major
                                Found in bemuse/karma.conf.js - About 2 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language