How to make SonarQube accept tabs instead of spaces for indentation

I’m developing a Java application as a university assignment and I’m using SonarQube for automatic code quality assessment.

Sonar is quite rigorous in spotting errors in code, and this is often useful. But it becomes annoying when Sonar floods the list of problems with multiple messages about the use of tabs instead of spaces for code indentation. Eclipse by default indents code with tabs: I think that this is the right decision and I don’t want to change that setting, even if SonarQube doesn’t like it.

So, how to configure SonarQube to accept spaces?

  1. Start Sonar and go to http://localhost:9000. This is the main dashboard of SonarQube.
  2. Log in using the link in the upper right corner of the screen. Username and password are both “admin” by default.
  3. Click on “Quality profiles” in the upper toolbar. You should see only one profile, called “Sonar way”.SonarQube Quality Profiles
  4. Use the “Copy” link to make a duplicate of this profile. Name the new profile as you want, e.g. “Sonar way (tabs)”.
  5. When it’s done, click on the number relative to the new profile in the “Rules” column. Sonar should come up with a list of active rules.
  6. Use your browser search feature to find the rule named Tabulation characters should not be used”. Deactivate it using the button on the right.
    SonarQube Rules
  7. Using the upper toolbar, go to Dashboards -> Home, then click on your project. You should now be in the dashboard of your project.
  8. Choose Settings -> Quality Profiles.
    Quality profile for project in SonarQube
  9. Select the new quality profile and click “Update”.
  10. Now, in Eclipse, you should force a full analysis of your project. To do this, run the project as “sonar:sonar” profile using Maven.You can also type mvn sonar:sonar in a terminal window in the folder that contains your pom.xml file.
  11. Go again in the SonarQube dashboard. Now you should no longer see the warnings about spaces.

Autore: pietrodn

Sono nato nel 1993 e studio Ingegneria Informatica al Politecnico di Milano. Amo leggere, programmare, costruire cose. Nella mia vita sono stato un Wikipediano e ho fatto parte del Consiglio di Istituto della mia scuola che è il Liceo Scientifico "Albert Einstein" di Milano. I miei interessi spaziano dall'informatica nelle sue diverse espressioni fino alla politica universitaria e a tutte le cose che possono definirsi geek.


Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:


Stai commentando usando il tuo account Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...