Combat Items: SonarCloud Sprint 4 - UQdeco2800/2022-studio-2 GitHub Wiki

Back to Combat Items Contents Page

Introduction and reasoning

To adhere to the final sprint goal of polishing the game's features, we believed that this meant to also improve the quality of the code with its test coverage. To show our code improvement, we have created a table before and after the polishment. This was also further done to validate that the quality of the code and its east coverage our at the whole game standard.

Sonarcloud helped identify the area that needed polishing. It must be noted that Sonarcloud is an automated identifier of code rule breakage. Some of the issue it had severity highlighted within the classes were not appropriate for this project. The cases where it was not appropriate to change will be explained in detail down below.

Sonarcloud Evaluation

Before Sprint 4

Class Minor smells Major smells Critical
AnimatedImage 2 3 0
AreaIfEffectStatsComponent 5 0 0
AuraPickupComponent 4 3 1
BuffDisplayComponent 5 1 1
PhysicalWeaponStatsComponent 2 0 0
WeaponArrowProjectileComponent 5 0 0
WeaponAuraComponent 2 0 0
WeaponAuraManager 6 0 0
WeaponStatsComponent 4 0 0
PlayerTouchAttackComponent 7 2 1
PlayerCombatAnimationController 0 0 0
CombatStatsComponent 7 2 0
AuraConfig 7 0 0
BaseAuraConfig 7 0 0
WeaponConfig 7 0 0
WeaponConfigSetup 12 0 0
WeaponFactory 2 1 0

Final Sonarcloud Table

Class Minor smells Major smells Critical
AnimatedImage 0 0 0
AreaIfEffectStatsComponent 0 0 0
AuraPickupComponent 2 0 0
BuffDisplayComponent 0 0 0
PhysicalWeaponStatsComponent 0 0 0
WeaponArrowProjectileComponent 0 0 0
WeaponAuraComponent 0 0 0
WeaponAuraManager 1 0 0
WeaponStatsComponent 0 0 0
PlayerTouchAttackComponent 0 0 0
PlayerCombatAnimationController 0 0 0
CombatStatsComponent 0 0 0
AuraConfig 7 0 0
BaseAuraConfig 7 0 0
WeaponConfig 7 0 0
WeaponConfigSetup 12 0 0
WeaponFactory 0 0 0

Explanation of unresolvable code smell

Config classses AuraConfig, BaseAuraConfig, WeaponConfig, WeaponConfigSetup

The screenshot above is the error that is present in all of the code smells for each other in the config classes, AuraConfig, BaseAuraConfig, WeaponConfig, WeaponConfigSetup. It is not appropriate to change these smells for multiple reasons. Firstly, the original state of the game file provided had classes that were used to config its components. This structure was followed throughout each sprint by not only us but also the whole studio- it became the standard. Compared to solving the minor code smells or unfollowing the whole studio's code structure, keeping the minor code smells is better. It is acknowledged that the possible solution to this minor code smells using enums. However, measures were taken in place to avoid the disadvantages of such a structure. Although it is not the best practice, the variables within the config classes are 'controlled' in other classes and can be overridden when a new config gets defined.

WeaponConfig config = configs.[_weaponname_]

Another minor code smell present in the WeaponCongif class is the screenshot above. Due to the decision made in sprint 3, the combat items has a null condition within the game. That is that the combat item is not equible once crafted and the the player not having an inital wepaon. Specifically for this variable, there are no materials at the start of the game and it possible to have none at another point in time of the game. Due to this HashMap is the most appropriate field for materials, as it allows for null values and keys. Therefore the code smells remain.

WeaponAuraManager

This code smell is linked with the config setup as explained above. However, this variable manages what config will be applied to the weapon based on the aura. It essentially manages what the code smell SonarCloud has highlighted as a code rule breakage disadvantage, that is, "Member values are subject to change from anywhere in the code and may not meet the programmer’s assumptions", for the config classes mentioned above. Therefore, this code smells error remains.

AuraPickupComponent

Screen Shot 2022-10-17 at 12 12 31 am

One of the code smells errors we received but were unable to resolve was to make the method create() static or remove the logger assignment. This error can be seen directly in the screenshot below. When trying to remove this, upon equipping a buff the game would dispose, causing the terminal to terminate . Additionally we cannot make this a static method, as this method is called in the Aura Factory to construct each individual Aura. Since we don’t want this method to belong to all objects of the class, it is important the method is not static. Therefore, this code smells error remains.

Future Direction

Although we have reached the end of the course, it would be a standard for the next sprint to ensure minimum code smells. It would also be beneficial to prevent

Back to Combat Items Contents Page

Author

  • Nisha Vashist, Madison Feddema
  • GitHub: NishaVashist0, MadiFeddema
  • Discord: nishavashist#4270, MadiFeddema
  • Slack: Nisha Vashist, Madison Feddema