Showing 120 of 336 total issues

PlaybackService has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

class PlaybackService {
  public player!: Plyr
  private repeatModes: RepeatMode[] = ['NO_REPEAT', 'REPEAT_ALL', 'REPEAT_ONE']
  private initialized = false

Severity: Minor
Found in resources/assets/js/services/playbackService.ts - About 2 hrs to fix

    Function listenToMediaEvents has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      private listenToMediaEvents (media: HTMLMediaElement) {
        media.addEventListener('error', () => this.playNext(), true)
    
        media.addEventListener('ended', () => {
          if (commonStore.state.use_last_fm && userStore.current.preferences!.lastfm_session_key) {
    Severity: Minor
    Found in resources/assets/js/services/playbackService.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

    songStore has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export const songStore = {
      vault: new Map<string, UnwrapNestedRefs<Song>>(),
    
      state: reactive({
        songs: [] as Song[]
    Severity: Minor
    Found in resources/assets/js/stores/songStore.ts - About 2 hrs to fix

      Function test has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        protected test () {
          it.each([
            [0, '00:00'],
            [59, '00:59'],
            [60, '01:00'],
      Severity: Major
      Found in resources/assets/js/utils/formatters.spec.ts - About 2 hrs to fix

        File NoiseBlob.ts has 269 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import * as THREE from 'three'
        import { ThreeSharedRenderer } from './ThreeSharedRenderer'
        import { ThreePBR } from './ThreePBR'
        import { ThreePointLight } from './ThreePointLight'
        import { AudioAnalyzer } from './AudioAnalyzer'
        Severity: Minor
        Found in resources/assets/js/visualizers/asteroid/scripts/NoiseBlob.ts - About 2 hrs to fix

          Function useDroppable has 61 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const useDroppable = (acceptedTypes: DraggableType[]) => {
            const acceptsDrop = (event: DragEvent) => {
              const type = getDragType(event)
              return Boolean(type && acceptedTypes.includes(type))
            }
          Severity: Major
          Found in resources/assets/js/composables/useDragAndDrop.ts - About 2 hrs to fix

            queueStore has 22 functions (exceeds 20 allowed). Consider refactoring.
            Open

            export const queueStore = {
              state: reactive<{ songs: Song[] }>({
                songs: []
              }),
            
            
            Severity: Minor
            Found in resources/assets/js/stores/queueStore.ts - About 2 hrs to fix

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

              export const useFloatingUi = (
                reference: HTMLElement | Ref<HTMLElement | undefined>,
                floating: HTMLElement | Ref<HTMLElement | undefined>,
                config: Partial<Config> = {}
              ) => {
              Severity: Major
              Found in resources/assets/js/composables/useFloatingUi.ts - About 2 hrs to fix

                SongRepository has 21 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class SongRepository extends Repository
                {
                    use Searchable;
                
                    public const SORT_COLUMNS_NORMALIZE_MAP = [
                Severity: Minor
                Found in app/Repositories/SongRepository.php - About 2 hrs to fix

                  Function test has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    protected test () {
                      it('renders for album', () => {
                        expect(this.renderForAlbum().html()).toMatchSnapshot()
                      })
                  
                  
                  Severity: Major
                  Found in resources/assets/js/components/ui/AlbumArtistThumbnail.spec.ts - About 2 hrs to fix

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

                      protected test () {
                        it('has different behaviors for current user', () => {
                          const user = factory<User>('user')
                          this.actingAs(user).renderComponent(user)
                    
                    
                    Severity: Major
                    Found in resources/assets/js/components/user/UserCard.spec.ts - About 2 hrs to fix

                      File songStore.spec.ts has 251 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import { reactive } from 'vue'
                      import isMobile from 'ismobilejs'
                      import UnitTestCase from '@/__tests__/UnitTestCase'
                      import { expect, it } from 'vitest'
                      import factory from '@/__tests__/factory'
                      Severity: Minor
                      Found in resources/assets/js/stores/songStore.spec.ts - About 2 hrs to fix

                        Function test has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          protected test () {
                            it('initializes the store', () => {
                              const applyMock = this.mock(themeStore, 'applyThemeFromPreference')
                        
                              themeStore.init()
                        Severity: Minor
                        Found in resources/assets/js/stores/themeStore.spec.ts - About 2 hrs to fix

                          Function test has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            protected test () {
                              it('renders', async () => expect((await this.renderComponent()).html()).toMatchSnapshot())
                          
                              it('plays all', async () => {
                                const songs = factory<Song>('song', 10)
                          Severity: Minor
                          Found in resources/assets/js/components/album/AlbumContextMenu.spec.ts - About 2 hrs to fix

                            Function test has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              protected test () {
                                it('toggles one song', async () => {
                                  const addMock = this.mock(favoriteStore, 'add')
                                  const removeMock = this.mock(favoriteStore, 'remove')
                                  const postMock = this.mock(http, 'post')
                            Severity: Minor
                            Found in resources/assets/js/stores/favoriteStore.spec.ts - About 2 hrs to fix

                              Function test has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                protected test () {
                                  it('renders', async () => expect((await this.renderComponent()).html()).toMatchSnapshot())
                              
                                  it('plays all', async () => {
                                    const songs = factory<Song>('song', 10)
                              Severity: Minor
                              Found in resources/assets/js/components/artist/ArtistContextMenu.spec.ts - About 1 hr to fix

                                Function update has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  update () {
                                    this.analyzer.getByteFrequencyData(this.audioBuffer)
                                    let bass = 0., mid = 0., high = 0.
                                
                                    if (this.audioBuffer[0] === 0) {
                                Severity: Minor
                                Found in resources/assets/js/visualizers/asteroid/scripts/AudioAnalyzer.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 test has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  protected test () {
                                    it('renders', () => {
                                      playlistStore.state.playlists = [
                                        factory<Playlist>('playlist', { name: 'Foo' }),
                                        factory<Playlist>('playlist', { name: 'Bar' }),
                                Severity: Minor
                                Found in resources/assets/js/components/song/AddToMenu.spec.ts - About 1 hr to fix

                                  Method handle has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function handle(): int
                                      {
                                          $this->alert('KOEL INSTALLATION WIZARD');
                                          $this->info(
                                              'As a reminder, you can always install/upgrade manually following the guide at '
                                  Severity: Minor
                                  Found in app/Console/Commands/InitCommand.php - About 1 hr to fix

                                    Function test has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      protected test () {
                                        it('fetches the artist info', async () => {
                                          const artist = artistStore.syncWithVault(factory<Artist>('artist', { id: 42 }))[0]
                                          const artistInfo = factory<ArtistInfo>('artist-info')
                                          const getMock = this.mock(http, 'get').mockResolvedValue(artistInfo)
                                    Severity: Minor
                                    Found in resources/assets/js/services/mediaInfoService.spec.ts - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language