SonarCloud Set Up ================== There are different ways to set up and use https://www.sonarcloud.io/, it's an enterprise level product for analysing source code to maintain code quality. OppiaMobile Server ------------------------ We use the `sonar-scanner `_ tool on the command line to analyse the Oppia server source code and submit the results to `SonarCloud `_. First we create the test coverage report, using the `Coverage `_ tool, using:: $ coverage erase $ coverage run --branch --source=activitylog,api,av,content,gamification,integration,oppia,profile,quiz,reports,summary,viz manage.py test $ coverage xml -i Then copy the generated ``django-oppia/coverage.xml`` file into the ``django-oppia/tests/`` directory. Then we run the sonar-scanner using:: /sonar-scanner \ -Dsonar.projectKey=XXXXXXX \ -Dsonar.organization=XXXXXXX \ -Dsonar.sources=. \ -Dsonar.host.url=https://sonarcloud.io \ -Dsonar.login=XXXXXXX \ -Dsonar.exclusions=docs/_build/**/*,tests/**/*,oppiamobile/settings_secret.py \ -Dsonar.python.coverage.reportPath=./tests/coverage.xml If you are running with your own SonarCloud account, you'll need to use your projectKey, organisation and login. OppiaMobile Android App ------------------------ The Oppia app source code analysis can be found at: https://sonarcloud.io/project/overview?id=DigitalCampus_oppia-mobile-android To run the analysis for the app, follow these steps: #. First, you previously need to generate the code coverage. (see: :doc:`../app/code-coverage`). #. Then, from the root of the app code directory, run:: ./gradlew sonarqube .. note:: You will need to set up the secret sonarcloud token for the previous command to work. There are three different ways to do it: #. Create an environment variable: **SONAR_TOKEN=** #. Create a file named sonarqube.properties in the root of the app code directory. Include the following line inside the file: **sonar.login=** #. Include the parameter in the gradlew command: **./gradlew sonarqube -Dsonar.login=** .. note:: If you want to generate sonarcloud analysis for your own sonarcloud project, make sure to update sonarqube.gradle file so it includes the information of your project.