Code Clean up & Junit Test - UQdeco2800/2022-studio-2 GitHub Wiki

Code Smell

Class Minor smells Major smells Critical
NPCFactory* 0 13 0
ProjectileFactory* 0 0 0
MovementTask 0 0 0
PhysicsMovementComponent 0 0 0
WanderTask 0 0 0
WaitTask 0 0 0
ProjectileTask 0 1 0
DeadTask 0 1 0
ChaseTask 0 0 0
JumpTask 0 1 0
NPCConfigs* 0 0 0
GymBroConfigs 0 0 0
PoopsConfig 0 0 0
HeraclesConfigs 0 0 0
BaseNPCConfigs 0 0 0
MegaPoopsConfigs 0 0 0
GymBroAnimationController 0 0 0
PoopsAnimationController 0 0 0
HeraclesAnimationController 0 0 0
MegaPoopsAnimationController 0 0 0

Notes:

For classes that mark * such as ProjectileFactory and NPCFactory, the code smell is only cleaned for the enemies (Not the NPC one). To look for the enemies-related function within the corresponding classes, below is a summary of what belongs to enemies:

  • NPCFactory: CreateGymBro, CreatePoops, CreateHeracles, CreateMegaPoop

  • ProjectileFactory: createPoopSludge, createDiscus

  • NPCConfigs: gymBro, heracles, poops, megapoop.

Reasons for unsolvable code smell

The error illustrated in the image above belongs to NPCFactory in the enemies-related function. Since every instance of the Configs of each enemy needs to be independent, the call needs to be an instance reference instead of a static reference.

Another significant error comes from JumpTask and ProjectileTask as it contains duplicated codes of each other. This is because this replicates some measurement methods from Chase Task such as getActivePriority, isTargetVisible, etc. Hence, the duplicate is needed to ease the process of coding. Moreover, by duplicating the calculating methods instead of using directly from the tasks, it helps the current task not to be interfered with the chase task as there would be a chance that other task would be triggered by accident if calling the need method from the chase task.

Junit Tests

Class Code Coverage
JumpTask % 44
WanderTask % 52
ChaseTask % 86.3
ProjectileTask % 81.2
MovementTask % 90
DeadTask % 80.5
WaitTask % 100
NPCConfigs % 100
GymBroConfigs % 100
PoopsConfigs % 100
HeraclesConfigs % 100
MegaPoopConfigs % 100
GymBroAnimationController % 100
PoopsAnimationController % 100
HeraclesAnimationController % 100
MegaPoopAnimationController % 100