Skip to content

Instantly share code, notes, and snippets.

@brijesh-deb
Last active October 9, 2018 04:22
Show Gist options
  • Save brijesh-deb/38eb33231940189f766a6097a2140719 to your computer and use it in GitHub Desktop.
Save brijesh-deb/38eb33231940189f766a6097a2140719 to your computer and use it in GitHub Desktop.
#Sonar #Cheatsheet

SonarQube server setup

  • Down load and unzip SonarQube distribution
  • Add SonarQube bin folder (C:\software\sonarqube-5.6.6\bin\windows-x86-64) in PATH
  • Start the server

Stop server

  • Ctrl+C
  • Closing the window will not stop the server

Create a new project

  • Login as admin
  • Adminstration> Projects> Management
  • Create Project
    • Name: [Name]
    • Key: [key]

Add quality profile for a project

  • Login as admin
  • Adminstration> Projects> Management > Select the project
  • In project page > Administration > Quality profiles
  • Select profiles needed

Integrate SonarQube with Maven

  • Edit the settings.xml file, located in $MAVEN_HOME/conf or ~/.m2
    <pluginGroups>
        <pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
    </pluginGroups>
    <profile>
        <id>sonar</id>
        <activation>
             <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
             <sonar.host.url>http://localhost:9000</sonar.host.url>
        </properties>
    </profile>
  • In the directory where the pom.xml file sits
    • mvn clean install
    • mvn sonar:sonar
  • Report with details (bugs, vulnerabilities, code smells, coverage, duplications) will show up in SonarQube dashboard

Create group

  • Login as admin
  • Adminstration> Security> Groups > Create Group
  • Name: [Name]

Create user

  • Login as admin
  • Adminstration> Security> Users > Create User
    • Login: [Login]
    • Name: [Name]
    • Password: [Password]
  • Attach the user to group(s)
    • List of users > Groups > Select groups

Provide specific permission to groups for project

  • Login as admin
  • Adminstration> Projects> Management > Select the project
  • In project page > Administration > Permissions
  • Select groups for Browse/See Source Code/Administer issues/Administer/Execute Analysis

Take backup of rules

  • Go to Quality Profiles
  • On Right-top "Back up" button is there

Reinstall SonarQube

  • Delete unzipped SonarLint installation folder
  • Delete .sonarlint folder from C:\Users<user name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment