0

From the Job log it looks like Travis enable all Sonar way that is available

...
INFO: Quality profile for css: Sonar way
INFO: Quality profile for java: Sonar way
INFO: Quality profile for js: Sonar way
INFO: Quality profile for ruby: Sonar way
INFO: Quality profile for web: Sonar way
...

Is there a way to choose which quality profiles Travis will enable?

My repo is Ruby and I want to enable Ruby quality profile only.

  • Sonar way is the default Quality profile. You can create your own profile using the SonarQube UI, see the documentation. Regarding the other one's: do you need all installed plugins? – Jeroen Heier Jun 21 '19 at 05:08
  • Fyi, I am using SonarCloud not (hosted) SonarQube. I will try your suggestion. I don't need other installed plugins. – William Notowidagdo Jun 25 '19 at 09:31

1 Answers1

0

You can define empty quality profiles with no rules for the languages you're not interested in, and then activate those empty profiles in your project.

  1. Go to your organization's page, and then the Quality Profiles tab

  2. Click Create, enter a name (for example "empty"), select the language

    • You will need to repeat this for each language
  3. Go to your project's page, and then Administration / Quality Profiles, and select the newly created "empty" quality profile for each language

If that sounds tedious, you could script it, with the help of the web API:

token=your-sonarcloud-token
org=your-sonarcloud-organization-key
project=your-sonarcloud-project-key

languages=(abap apex c cobol cpp cs css flex go java js jsp kotlin objc php plsql py ruby scala swift ts tsql vbnet web xml)

for lang in "${languages[@]}"; do
    params="language=$lang&name=empty&organization=$org"
    curl -u"$token:" "https://sonarcloud.io/api/qualityprofiles/create?$params" -X POST

    params="project=$project&language=$lang&qualityProfile=empty&organization=$org"
    curl -u"$token:" "https://sonarcloud.io/api/qualityprofiles/add_project?$params" -X POST
done

This will set the empty profile for all languages. So you will need to go to Administration / Quality Profiles of your project to set a non-empty profile for the languages you're interested in.

janos
  • 120,954
  • 29
  • 226
  • 236