Skip to content

Commit

Permalink
Add SonarQube Gradle plugin for local code inspection 🔎
Browse files Browse the repository at this point in the history
https://plugins.gradle.org/plugin/org.sonarqube
https://github.com/SonarSource/sonar-scanner-gradle

Explain how to run local code inspection with official Docker image (https://hub.docker.com/_/sonarqube). 🐳

Tested with Podman 🦭 (https://podman.io/):

    $ podman machine info
    Host:
      Arch: amd64
      CurrentMachine: podman-machine-default
      DefaultMachine: ""
      EventsDir: /var/folders/vn/t_jql4vn7fzb9cr0qxcxdqlm0000gn/T/podman-run--1/podman
      MachineConfigDir: /Users/nicolas/.config/containers/podman/machine/qemu
      MachineImageDir: /Users/nicolas/.local/share/containers/podman/machine/qemu
      MachineState: Running
      NumberOfMachines: 1
      OS: darwin
      VMType: qemu
    Version:
      APIVersion: 4.7.2
      Built: 1698753557
      BuiltTime: Tue Oct 31 12:59:17 2023
      GitCommit: 750b4c3a7c31f6573350f0b3f1b787f26e0fe1e3
      GoVersion: go1.21.4
      Os: darwin
      OsArch: darwin/amd64
      Version: 4.7.2

    $ alias docker
    docker=podman
    $ docker run -d --name sonarqube -p 9000:9000 docker.io/sonarqube
    4d85d236e383622044eeb86198e618d22f79637debdac16378ddf3998d15ff15

    $ ./gradlew sonarqube --info -Dsonar.login=admin -Dsonar.password=admin
    ...
    > Task :sonarqube
    ...
    ANALYSIS SUCCESSFUL, you can find the results at: http://localhost:9000/dashboard?id=pullpitoK
    Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
    More about the report processing at http://localhost:9000/api/ce/task?id=AYuyNmLfK0whm78Dl0fp
    Analysis total time: 1:45.562 s
  • Loading branch information
nicokosi committed Nov 9, 2023
1 parent 3b6aae7 commit cfc243c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Code inspection is configured on the `main` branch. See the [sonarcloud.io's das
In order to inspect the code locally, run:

docker run -d --name sonarqube -p 9000:9000 sonarqube
./gradlew sonarqube --info
./gradlew sonarqube --info -Dsonar.login=admin -Dsonar.password=admin

### Upgrade the dependencies

Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
id("com.github.ben-manes.versions") version "0.48.0"
id("com.adarshr.test-logger") version "3.2.0"
id("com.diffplug.spotless") version "6.22.0"
id("org.sonarqube") version "4.4.1.3373"
application
}

Expand Down

0 comments on commit cfc243c

Please sign in to comment.