diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 0000000..0c1cb01 --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,14 @@ +version = 1 + +[[analyzers]] +name = "javascript" + + [analyzers.meta] + plugins = ["react"] + +[[analyzers]] +name = "docker" + +[[analyzers]] +name = "test-coverage" +enabled = true \ No newline at end of file diff --git a/.github/workflows/deepsource-tests.yml b/.github/workflows/deepsource-tests.yml new file mode 100644 index 0000000..7b8b523 --- /dev/null +++ b/.github/workflows/deepsource-tests.yml @@ -0,0 +1,58 @@ +name: Deepsource report test coverage +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +on: + push: + branches: [dev,master] + paths-ignore: + - '.github/**' + - 'images/' + - '*.md' + pull_request: + branches: + - master + - dev + + workflow_dispatch: + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + +jobs: + report-test-coverage: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - name: Setup + uses: actions/setup-node@v3 + - name: Checkout + uses: actions/checkout@v3 + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn config get cacheFolder)" + - uses: actions/cache@v3 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - run: yarn install --immutable + - run: yarn test:cov + - run: curl https://deepsource.io/cli | sh + - name: Report test-coverage to DeepSource + run: | + # Install the CLI + curl https://deepsource.io/cli | sh + + # Send the report to DeepSource + ./bin/deepsource report --analyzer test-coverage --key javascript --value-file ./coverage/lcov.info + env: + DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }} \ No newline at end of file diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml deleted file mode 100644 index efaed3a..0000000 --- a/.github/workflows/sonarcloud.yml +++ /dev/null @@ -1,85 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -# This workflow helps you trigger a SonarCloud analysis of your code and populates -# GitHub Code Scanning alerts with the vulnerabilities found. -# Free for open source project. - -# 1. Login to SonarCloud.io using your GitHub account - -# 2. Import your project on SonarCloud -# * Add your GitHub organization first, then add your repository as a new project. -# * Please note that many languages are eligible for automatic analysis, -# which means that the analysis will start automatically without the need to set up GitHub Actions. -# * This behavior can be changed in Administration > Analysis Method. -# -# 3. Follow the SonarCloud in-product tutorial -# * a. Copy/paste the Project Key and the Organization Key into the args parameter below -# (You'll find this information in SonarCloud. Click on "Information" at the bottom left) -# -# * b. Generate a new token and add it to your Github repository's secrets using the name SONAR_TOKEN -# (On SonarCloud, click on your avatar on top-right > My account > Security -# or go directly to https://sonarcloud.io/account/security/) - -# Feel free to take a look at our documentation (https://docs.sonarcloud.io/getting-started/github/) -# or reach out to our community forum if you need some help (https://community.sonarsource.com/c/help/sc/9) - -name: SonarCloud analysis - -on: - push: - branches: [ "master", "dev" ] - pull_request: - branches: [ "master", "dev" ] - workflow_dispatch: - -permissions: - pull-requests: read # allows SonarCloud to decorate PRs with analysis results - -jobs: - Analysis: - runs-on: ubuntu-latest - - steps: - - name: Setup - uses: actions/setup-node@v3 - - name: Checkout - uses: actions/checkout@v3 - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn config get cacheFolder)" - - uses: actions/cache@v3 - id: yarn-cache - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - run: yarn install --immutable - - run: yarn test:cov - - name: Analyze with SonarCloud - - # You can pin the exact commit or the version. - # uses: SonarSource/sonarcloud-github-action@de2e56b42aa84d0b1c5b622644ac17e505c9a049 - uses: SonarSource/sonarcloud-github-action@de2e56b42aa84d0b1c5b622644ac17e505c9a049 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret) - with: - # Additional arguments for the sonarcloud scanner - args: - # Unique keys of your project and organization. You can find them in SonarCloud > Information (bottom-left menu) - # mandatory - -Dsonar.projectKey=manuel-rw_jellyfin-discord-music-bot - -Dsonar.organization=manuel-rw - -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info - # Comma-separated paths to directories containing main source files. - #-Dsonar.sources= # optional, default is project base directory - # When you need the analysis to take place in a directory other than the one from which it was launched - #-Dsonar.projectBaseDir= # optional, default is . - # Comma-separated paths to directories containing test source files. - #-Dsonar.tests= # optional. For more info about Code Coverage, please refer to https://docs.sonarcloud.io/enriching/test-coverage/overview/ - # Adds more detail to both client and server-side analysis logs, activating DEBUG mode for the scanner, and adding client-side environment variables and system properties to the server-side log of analysis report processing. - #-Dsonar.verbose= # optional, default is false diff --git a/README.md b/README.md index a6316aa..2a04b8b 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@

+


diff --git a/src/clients/discord/discord.voice.service.ts b/src/clients/discord/discord.voice.service.ts index 5b59abc..35fe65e 100644 --- a/src/clients/discord/discord.voice.service.ts +++ b/src/clients/discord/discord.voice.service.ts @@ -105,7 +105,9 @@ export class DiscordVoiceService { changeVolume(volume: number) { if (!this.audioResource || !this.audioResource.volume) { - this.logger.error(`AudioResource or volume was undefined`); + this.logger.error( + `Failed to change audio volume, AudioResource or volume was undefined`, + ); return; } this.audioResource.volume.setVolume(volume); diff --git a/src/clients/jellyfin/jellyfin.service.ts b/src/clients/jellyfin/jellyfin.service.ts index 83d173d..b049f79 100644 --- a/src/clients/jellyfin/jellyfin.service.ts +++ b/src/clients/jellyfin/jellyfin.service.ts @@ -46,10 +46,7 @@ export class JellyfinService { process.env.JELLYFIN_AUTHENTICATION_PASSWORD, ) .then(async (response) => { - if ( - response.data.SessionInfo === undefined || - response.data.SessionInfo.UserId === undefined - ) { + if (response.data.SessionInfo?.UserId === undefined) { this.logger.error( `Failed to authenticate with response code ${response.status}: '${response.data}'`, ); diff --git a/src/commands/play/play.comands.ts b/src/commands/play/play.comands.ts index a82ab47..ec86926 100644 --- a/src/commands/play/play.comands.ts +++ b/src/commands/play/play.comands.ts @@ -104,9 +104,9 @@ export class PlayItemCommand { ); this.playbackService.getPlaylistOrDefault().enqueueTracks(tracks); - const remoteImage: RemoteImageInfo | undefined = tracks - .flatMap((track) => track.getRemoteImages()) - .find(() => true); + const remoteImages = tracks.flatMap((track) => track.getRemoteImages()); + const remoteImage: RemoteImageInfo | undefined = + remoteImages.length > 0 ? remoteImages[0] : undefined; await interaction.followUp({ embeds: [ @@ -117,10 +117,10 @@ export class PlayItemCommand { reducedDuration, )})`, mixin(embedBuilder) { - if (!remoteImage) { + if (!remoteImage?.Url) { return embedBuilder; } - return embedBuilder.setThumbnail(remoteImage.Url ?? ''); + return embedBuilder.setThumbnail(remoteImage.Url); }, }), ],