DEV Community

gus
gus

Posted on • Edited on

1

Rebased

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. +

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay