I have finally completed the first open source pull request for a real world project. I will talk about the issue I fixed as well as the processes I went through.
Issue worked on
The issue link is as below:
Get rid of all the "vars" in the code · Issue #261 · lbryio/lbry-wunderbot
This codebase has seen contributions from a lot of people. As a consequence it's not very clean and doesn't often…
Research about var vs. let
Before working on this issue, I was not sure about the difference between var and let. The maintainer provided a link which has the explanation of the difference. In general, var is used for variables with function scope whereas let defined variables are only accessible within the block declared.
How I fixed the code
The pull request link is as below:
Fix#261 Replace vars with lets by haichuan0424 · Pull Request #263 · lbryio/lbry-wunderbot
All vars in price.js can be replaced with lets since they are used within the declaration scope. However, some of the…
After taking look at the code, only two files are related with this issue. In the file price.js, there are many variables declared using var. However, after further examination, all of them can be replaced by let as they are all used within the code block they are defined. Another file purge.js has a piece of code like below:
It is obvious that the declaration of amount and adding can be done using let. For the variable newamount, it has to be declared outside the if/else block in order to be accessed in the block, so I changed the code to:
After the commit, there is no variable declared using var so it conform to the code convention with other files.
The issue I worked on was not on Github originally. I found an issue with the same project on a related project called tipbot maintained by the same group of people. After browsing the code, I found that although the issue requested to clean up the var declarations, the code has already been cleaned without a single var. I dropped a comment to the maintainer to bring that up and asked if I understood the issue correctly. Later, the maintainer realized it was not a proper issue so he transferred this issue to the relevant project I worked on.
From this experience, I think that communication is really crucial in the open source community. If I had not dropped the comment, I would not be able to get this issue to work on. It does not cost anything to ask questions or seek to clear your doubts. The opportunities sometime only come up if you take actions.