From 616953088d75d2edf494bccdfb6c4d5ab628d297 Mon Sep 17 00:00:00 2001 From: Thach Nguyen Date: Wed, 27 Jul 2022 22:55:57 +0700 Subject: [PATCH] Analyze source code with SonarQube --- README.md | 20 ++++++++++++++++++++ dist/index.js | 2 +- src/installer.ts | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2d4e686..481b3de 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,23 @@ docker run --rm -it -v "%PWD%:/usr/src/app" -w /usr/src/app node:12-alpine /bin/ ``` **Note** that `%PWD%` is the project working directory in `Unix` format, such as: `/c/Users/source/repos/setup-maven` + +### Analyze source code with [SonarQube](https://www.sonarqube.org/) + +Download [SonarQube Docker image](https://hub.docker.com/_/sonarqube/) and start the server + +```batch +docker pull sonarqube:community +docker run --rm -d --name docker-sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube +``` + +Login to http://localhost:9000/ using `Administrator` account (admin/admin) and configure the project to analyze. +For more details, see: https://docs.sonarqube.org/latest/setup/get-started-2-minutes/ + +Run `SonarScanner` from [the Docker image](https://hub.docker.com/r/sonarsource/sonar-scanner-cli) to analyze the project + +```batch +docker run --rm -it --link docker-sonarqube -v "%PWD%:/usr/src/app" -w /usr/src/app ^ + -e "SONAR_HOST_URL=http://docker-sonarqube:9000" -e "SONAR_LOGIN=" sonarsource/sonar-scanner-cli ^ + -Dsonar.projectKey=setup-maven -Dsonar.language=js -Dsonar.sources=. "-Dsonar.exclusions=dist/**" +``` diff --git a/dist/index.js b/dist/index.js index 1851bb9..23aaca2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4758,7 +4758,7 @@ function downloadMaven(version) { const downloadPath = yield tc.downloadTool(downloadUrl); const extractedPath = yield tc.extractTar(downloadPath); const toolRoot = path.join(extractedPath, toolDirectoryName); - return yield tc.cacheDir(toolRoot, 'maven', version); + return tc.cacheDir(toolRoot, 'maven', version); }); } diff --git a/src/installer.ts b/src/installer.ts index b9bff9f..76bb96c 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -25,5 +25,5 @@ async function downloadMaven(version: string): Promise { const extractedPath = await tc.extractTar(downloadPath); const toolRoot = path.join(extractedPath, toolDirectoryName); - return await tc.cacheDir(toolRoot, 'maven', version); + return tc.cacheDir(toolRoot, 'maven', version); }