All Your (Re)Base Are Belong To Us - Lab 5

 This lesson couldn't have come at a better time!

While putting the finishing touches on one of my PRs for Hacktoberfest earlier this week, I ran into some issues with having numerous commits, and all around making a mess of the place. So eventually, it was suggested that I tackle squashing my commits into one. After a bit of research, I felt I was ready to tackle this feat (mistake #1). With this newfound knowledge, I dove head-first in this new task, thinking that I was properly prepared (mistake #2). I was able to get the problem solved, but not before causing more harm than good.

Now that I have been able to take a step back and see the fault of my ways, the second attempt at rebasing went smoother. My main mistake seemed to be pushing to the branch first, and trying to rebase after. Maybe this strategy will work if I get more comfortable with the technique, but by the time I finished this lab, I knew that rebasing AND THEN pushing to the necessary branch was the proper order to avoid that trouble all together.

As for the improvements I made to my link checker, I was able to find 3 things to work on:

  1. Removing some unneeded lines of code that were in the program.
  2. Implementing shorter options for arguments.
  3. Fixing a bug that had crept into the feature to save the processed links to a text file.
When searching my code, the first thing I did was go through and see if there was anything that I needed to simplify/shorten. During this search, I did a scan on the regular expression variable that I had globally initialized. Knowing that it would be better if it were located within whichever function it was being utilized in, I set off to find where I had used it. In the end, I discovered that, along the way, I had replaced it with BeautifulSoup for my HTML parsing. With that discovery, I removed the declaration of the regex, and ran some tests to ensure I didn't miss something.

My next step was to introduce shortcuts for arguments. While the current options worked well, since they were verbose, it was inconvenient to type them out. To fix this, I included an additional option for users to use a shorthand version of each option. During this process, however, I found that I needed to update some naming conventions so that they aligned with the options I was planning on using. The main culprit was my '--parse_url' option along with my '--unknown' link filter option. Since they both required the letter 'u' for their shorthand to make sense, I instead altered '--parse_url' to read '--parse_link'. Since I made that change, I then proceeded to look through my naming conventions and ensure that the rest of the program matched the change I just made in terms of naming.

My final alteration came as I was testing my new options. When I reached trying to use the '--save_file' option, there was an error that occurred when a message was returned to my main function. It turns out that the data being returned when the links timed out (a string) didn't match the data being returned when a link was successfully inspected (an array). Due to this, the data being written to the file had the chance to fail due to the code that was expected. To fix this, I introduced a second piece of data to return (a dummy status code) so that both pathways worked seamlessly.

I'm happy that this lab came during this time, since it happened to fall into when I was also trying to delve out on my own to solve my own rebase. It allowed me to work through the issue on my own first, learn from my mishaps, and then sit down and work my way through it in a more controlled environment, where I was able to reflect on the things I approached the wrong way, and see the error of my ways.

Anyways, it's time for me to get back to my next PR for Hacktoberfest. I'll get another post out soon!

Comments