Skip to content

Template for Maven project with CI SonarCloud, CI QL-Analyse and CD to automatically deploy docker container image on GitHub Packages.

License

Notifications You must be signed in to change notification settings

MathieuSoysal/Java-Maven-Project-Template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Quality Gate

Kata - Datanumia

Coverage Maintainability Rating Reliability Rating Duplicated Lines (%) Code Smells Javadoc Mutation Testing Report Fuzzing Test Report

Table of Contents

Introduction

This README provides an overview of the Kata - Datanumia project, showcasing its quality, code coverage, and maintainability metrics. It also outlines DevOps practices, including the use of Devcontainer for a consistent development environment and GitHub Actions integrated with SonarCloud for continuous code quality monitoring.

DevOps

Devcontainer

I have implemented a Devcontainer setup to facilitate development on this project. Devcontainer allows developers to use Visual Studio Code in a containerized environment, ensuring a consistent development environment for all team members. It automates the installation of essential tools such as Java, Maven, and Sonar Scanner.

To use Devcontainer, please install the Remote - Containers extension in Visual Studio Code.

GitHub Actions - SonarCloud

I have integrated GitHub Actions with SonarCloud to run code analysis on each push to the master branch. This integration checks the code quality and code coverage of the project, providing valuable insights into code maintainability and reliability.

To view the analysis results, click on the badge at the top of this README or here.

Refactor

πŸ”΄ Bad Practices in Test

Name of the Tests

In some instances, test names do not adhere to appropriate naming conventions or lack consistency with other tests.

Content of the Tests

Tests may exhibit redundancy or perform unnecessary work, making them less efficient.

🟒 Solution to Refactor Test

Test Parameterization

I have introduced parameterized tests to reduce code repetition and improve test readability.

Rename Test Methods

To ensure uniformity in test method naming, I have aligned them with Java naming conventions and consistent naming practices across the project.

πŸ”΄ Bad Practices in the Main Code

Too Many Methods in the Same Class

The main class, Yatzy, contains an excessive number of methods, some of which are overly lengthy or do not adhere to proper naming conventions. This violates the Single Responsibility Principle.

Too Many Parameters in the Same Method

Certain methods suffer from an overload of parameters, leading to readability and maintainability issues. Additionally, some parameter names do not follow naming conventions.

Bad Scoping of the Methods

Methods lack consistent scoping, with some being static while others are not.

🟒 Solution to Refactor the Main Code

Split the Main Class

I have refactored the Yatzy class into multiple smaller classes, each with a specific role. To split the class, I used the design pattern command. I created a class for each kind of score calculator, and I created a class YatzyMod to manage the score calculator. The class Yatzy is now a facade and the Single responsibility principle is respected.

Handling Incorrect Dice Values

I added a method to validate dice values, ensuring that incorrect values result in an exception.

Reduce the Number of Parameters

To enhance code readability, I reduced the number of parameters in certain methods by introducing a new class, "Dices," to manage dice-related operations.

Reduce the Size of Methods

I have reduced the size of methods to improve code comprehension and maintainability. To do that I used IntStream and Stream API.

Conclusion

Thank you for exploring the Kata - Datanumia project. I have focused on enhancing code quality, maintainability, and test readability, as well as implementing DevOps practices for a smoother development experience, including the use of Devcontainer and GitHub Actions integrated with SonarCloud. Your feedback and contributions are greatly appreciated.

About

Template for Maven project with CI SonarCloud, CI QL-Analyse and CD to automatically deploy docker container image on GitHub Packages.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Languages