S2 – Week #7 – Metrics

Hey There

This weeks posts is dedicated to the topic of Code Metrics.

For this project, we chose Codacy to analyze and grade our two repositories.

The installation went smoothly, we quickly realised how well Codacy is integrated into the GitHub interface. The only thing we had to change is that we needed to have an organisation set-up in order for Codacy to work properly.
This is also why our two repositories have been transferred to the organisations GitHub account and are now accessible under

https://github.com/GyroInc

Anyway, lets get back to metrics.

First up we had to change some settings within Codacy because it was flagging our BAD code all over the place.

However, a lot of these issues could be fixed by just ignoring the directories containing code we didn’t even write.

Our cube firmware repository for example includes all of the 3rd party libraries we used to make the firmware.

Luckily Codacy supports ignoring of folders

We have also chosen to ignore some folders, containing code that doesn’t actually run on the hardware and is only there for testing or configuration purposes.

For our Unity project repository it looked even worse at first:

Oof….

But there were a lot of issues that were only related to the way Unity handles things.

These two issue types for example are not relevant for this project.

  1. Public fields that are only used within the class are acceptable, because they can (and should) be changed within the Unity Editor when creating a scene.
  2. The Update() method (and many other similar methods) are not being called from within the C# code we have written, but they are crucial to the architecture of the Unity Engine. The Update() method of each script is therefore called once every frame.

So we disabled all the irrelevant patterns in Codacy, that were not applicable for this project.

Now THIS already looks a lot better

But there was still a lot to improve.

Our starting point for refactoring

We started out with a badge grade of C, which isn’t all that great.

After looking at the issues and fixing a lot of them, the dashboard now looks like this:

Most of the refactoring has been done in this commit, if you want to see what improved the code quality so much.

The best thing about that is that we have earned a green badge, which looks fantastic on our GitHub.

Look at that, isn’t that nice?

Alright, that would be it for this week.
See ya in the final blog post of this semester!

Manu & Simon

Icon made by Freepik from www.flaticon.com