DEV Community


Posted on • Updated on


This week's work involved refactoring code from my GAS SSG. I started by making a refactoring branch where I staged my changes before committing them.

My first set of changes were variable name changes to make variable names more meaningful and consistent throughout my code. I changed a lot of "line" arguments to specify things like input/output, order of use, or in my header function, which was being made into a header. I committed these changes and went on to the next.

The next set involved creating a few functions for validating filetype when the SSG receives CLI arguments. I created functions to determine if a file was text, markdown, json, or a folder. I then took out any redundant logic throughout the program to call my functions instead.

Finally, I implemented a change my prof requested earlier, which was to use std::filesystem's status function to check the type of argument being passed as input. I upgraded my newly created folder checking function to check specifically for a directory from the path given, rather than just checking if it wasn't a text or markdown file.

With all these changes tested, committed, and ready to go I entered the last stretch of squashing the commits by rebasing the main.

Image description

I had to do some Googling to refresh my non existent vim skills, but got it saved and committed without too much trouble. I amended the commit to add some more details to my commit messages and finally merged and pushed the changes. This was probably the easiest lab so far, I found everything straightforward and was able to fix up my code without breaking anything. 10/10 would refactor again. +

Top comments (0)