Blog post

You’re 3 minutes away from clean Java pull requests!

Thomas Olivier photo

Thomas Olivier

Product Marketing Manager

3 min read

  • SonarCloud

How do you ensure your next Java pull request is clean? How do you ensure all your future Java pull requests are also clean? What impact would this have on your project? On your work? How much easier will it be, in the future, to add new features on top of a clean code base? There’s an easy way for every Java developer to get there. In this blog, I’m going to demonstrate how you can get started with SonarCloud in less than 3 minutes and ensure all new Java pull requests are clean, every time.

From sign-up to first PR decoration in record time

Find more videos like this on our Youtube channel.

4 easy steps to decorate your Java pull requests

  1. Start from our login page, and sign-up with your GitHub account. All it takes is one click and your account is created. This will take you to GitHub, so that you can give permissions to SonarCloud to look at your account. 
  2. Back to SonarCloud, begin the import of your GitHub organization. This will take you back to GitHub to install SonarCloud and provide more permissions, including the right to look at your code and pull requests. Once done, you can setup your SonarCloud organization and choose a plan. Let’s keep in mind that SonarCloud is entirely free for open-source projects, with access to the full feature-set. At this point, your organization is created.
  3. It’s time for you to select the repository you want to analyze. Automatic analysis will be triggered instantly. Just wait for the analysis to end - it should be fast (<1 minute for a project <10k lines of code as demoed in the video) - and get access to the results, simply click on the main branch to explore. The last 5 pull requests have also been analyzed.
  4. Our Clean Code monitoring is now active for your Java project. What this means is that every pull request will now be analyzed and decorated instantly after creation.

Disclaimer

  • For the sake of this demonstration, we have picked a pretty simple Java Spring Webapp with 10k lines of code. The analysis duration is expected to grow with the size of your project.
  • Once a Java project is imported, automatic analysis is triggered instantly on SonarCloud as the video demonstrates. Today, this is only available to GitHub organizations. It will come later for other DevOps Platforms. Don’t be scared, getting SonarCloud to work with your CI/CD should be fairly easy. You might just not reach the 3 minutes baseline.
  • The use case we’re presenting in the video is the best way to get started with continuous analysis of your code and also comes with a few limitations - e.g. no taint analysis, no code coverage report. These limitations will be addressed in the future.

Conclusion

That’s it! Getting a Java pull request analyzed and decorated for the first time should never be more difficult than this. You’re on your way to have a major impact on your code and your project! SonarCloud is going to help with systematic remediation of code issues to make your code reviews faster. From now on, every single pull request you will merge into the code base will be clean, with no bugs, no vulnerabilities, and no major code smells.


There is much more you can achieve with SonarCloud in the future. We recommend you get familiar with the tool and the Clean as you Code methodology, then set it up to work with your CI/CD. You will unlock taint analysis, code coverage reports, features that are key to get your code to a higher level of quality.


If you have any questions, or if you encounter a problem, please go to our Community Forum. We’ll be happy to help you get up and running.


Pick a topic to discover more