bemusic/bemuse

View on GitHub

Showing 508 of 508 total issues

Function previewStateReducer has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function previewStateReducer(
  state: PreviewState,
  action: PreviewAction
) {
  let nextState = state
Severity: Major
Found in bemuse/src/previewer/PreviewState.tsx - About 3 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            it('notifies of note hit', function () {
              setup(`
                #BPM 120
                #00111:0102
              `)
    Severity: Major
    Found in bemuse/src/game/state/player-state.spec.js and 1 other location - About 3 hrs to fix
    bemuse/src/game/state/player-state.spec.js on lines 272..280

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 101.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            it('should notify missed notes as break', function () {
              setup(`
                #BPM 120
                #00111:01
              `)
    Severity: Major
    Found in bemuse/src/game/state/player-state.spec.js and 1 other location - About 3 hrs to fix
    bemuse/src/game/state/player-state.spec.js on lines 263..271

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 101.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function onKeyDown has 82 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        const onKeyDown = (e: KeyboardEvent) => {
          if (isModalActive()) return
          console.log(e.key)
          if (e.key === '2') {
            props.dispatch({ speedUp: true })
    Severity: Major
    Found in bemuse/src/previewer/PreviewKeyHandler.tsx - About 3 hrs to fix

      Function PreviewFileDropHandler has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

      export const PreviewFileDropHandler: FC<PreviewFileDropHandler> = (props) => {
        useEffect(() => {
          const onDragOver = (e: DragEvent) => {
            e.preventDefault()
          }
      Severity: Minor
      Found in bemuse/src/previewer/PreviewFileDropHandler.tsx - 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 keysForBmson has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

      export function keysForBmson(bmson: Bmson) {
        const soundChannels = soundChannelsForBmson(bmson)
        let hasKeys = false
        let hasSecondPlayer = false
        let hasDeluxeKeys = false
      Severity: Minor
      Found in packages/bmson/src/index.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

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

      import * as Scintillator from './'
      
      const fixture = (file) => `/base/src/scintillator/test-fixtures/${file}`
      
      describe('Scintillator', function () {
      Severity: Minor
      Found in bemuse/src/scintillator/index.spec.js - About 3 hrs to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            it('sets judgment deviation (late)', function () {
              const info = { judgment: 2, delta: 0.03, combo: 123, column: 'SC' }
              update(12, 34, makeState({ notifications: { judgments: [info] } }))
              assert(data['judge_2'] === 12)
              assert(data['judge_deviation_late'] === 12)
        Severity: Major
        Found in bemuse/src/game/display/player-display.spec.js and 1 other location - About 3 hrs to fix
        bemuse/src/game/display/player-display.spec.js on lines 90..95

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 98.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            it('sets judgment time', function () {
              const info = { judgment: 1, delta: 0, combo: 123, column: 'SC' }
              update(12, 34, makeState({ notifications: { judgments: [info] } }))
              assert(data['judge_1'] === 12)
              assert(data['judge_deviation_none'] === 12)
        Severity: Major
        Found in bemuse/src/game/display/player-display.spec.js and 1 other location - About 3 hrs to fix
        bemuse/src/game/display/player-display.spec.js on lines 102..107

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 98.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function loadSongFromResources has 78 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function loadSongFromResources(
          resources: ICustomSongResources,
          options: LoadSongOptions = {}
        ) {
          const onMessage = options.onMessage || (() => {})
        Severity: Major
        Found in bemuse/src/custom-song-loader/index.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 launchGame has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

          async function launchGame(
            {
              server,
              song,
              chart,
          Severity: Minor
          Found in bemuse/src/app/game-launcher.tsx - 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 loadPreview has 77 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export async function loadPreview(loadOptions: LoadPreviewOptions) {
            const log =
              loadOptions.log ||
              ((message: string) => console.log(`[PreviewLoader] ${message}`))
          
          
          Severity: Major
          Found in bemuse/src/previewer/PreviewLoader.tsx - About 3 hrs to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                it('switches to keyboard mode if off', () => {
                  given(Options.initialState)
                    .when(update(actions.CHANGE_SCRATCH_POSITION({ position: 'off' })))
                    .then(Options.scratchPosition, shouldEqual('off'))
                    .and((state) => {
            Severity: Major
            Found in bemuse/src/app/entities/Options.spec.js and 1 other location - About 3 hrs to fix
            bemuse/src/app/entities/Options.spec.js on lines 96..103

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 96.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                it('switches to BMS mode if on', () => {
                  given(Options.initialState)
                    .when(update(actions.CHANGE_SCRATCH_POSITION({ position: 'right' })))
                    .then(Options.scratchPosition, shouldEqual('right'))
                    .and((state) => {
            Severity: Major
            Found in bemuse/src/app/entities/Options.spec.js and 1 other location - About 3 hrs to fix
            bemuse/src/app/entities/Options.spec.js on lines 88..95

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 96.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Function generateBaseConfig has 76 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function generateBaseConfig() {
              const config = {
                mode: Env.production() ? 'production' : 'development',
                context: path('src'),
                resolve: webpackResolve,
            Severity: Major
            Found in bemuse/config/webpack.js - About 3 hrs to fix

              Online has 26 functions (exceeds 20 allowed). Consider refactoring.
              Open

              export class Online {
                constructor(private readonly service: InternetRankingService) {}
              
                /** @deprecated */
                private user口 = new Subject<UserInfo | null>()
              Severity: Minor
              Found in bemuse/src/online/index.ts - About 3 hrs to fix

                Function main has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export async function main() {
                  // iOS
                  window.addEventListener('touchstart', function unmute() {
                    unmuteAudio(audioContext)
                    window.removeEventListener('touchstart', unmute)
                Severity: Major
                Found in bemuse/src/game/index.tsx - About 3 hrs to fix

                  Function ModeSelectScene has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const ModeSelectScene = () => {
                    const sceneManager = useContext(SceneManagerContext)
                    const dispatch = useDispatch()
                    const playDevice = useRef<PlayDevice>(null)
                  
                  
                  Severity: Major
                  Found in bemuse/src/app/ui/ModeSelectScene.tsx - About 3 hrs to fix

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                    export function useLeaderboardQuery(
                      chart: { md5: string },
                      playMode: MappingMode
                    ) {
                      const online = useContext(OnlineContext)
                    Severity: Major
                    Found in bemuse/src/online/hooks.ts and 1 other location - About 3 hrs to fix
                    bemuse/src/online/hooks.ts on lines 42..52

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 95.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Severity
                    Category
                    Status
                    Source
                    Language