How do you review code that accompanies a research project or paper? Help rOpenSci plan a Community Call

I’m in the midst of trying to get some type of code review going in my department, so I have some thoughts on this topic. I work in a group where (almost) all of our projects are conducted completely independently, and people program in R, SAS, Stata, and possibly other programs. Additionally, most data cannot (strictly) be shared even among members of our group due to HIPAA issues.

I believe the comments about the necessity of a culture of shared values surrounding coding are spot on, and in trying to get code review up and running in my group I have encountered some challenges related to this. The most common arguments I hear are a) it will be too time consuming and b) my code isn’t good enough to share.

Instead of peer-to-peer code review, which was facing too much resistance, I recently started a “Coding Workshop”. At regular intervals, someone submits a piece of code for review and a reviewer is assigned. The code is also made available to the rest of the group in advance. Then in the meeting, the code author reviews the point of the code briefly, and the reviewer goes over their comments and there is general discussion. The main points we have asked reviewers to focus on, since no data sharing is involved and therefore the code can’t be run, are:

  1. Is the code well commented?
  2. Is there repeated code that could be eliminated through use of a function/macro?
  3. Are numbers used in tables and reports generated automatically to avoid typos or copy/paste errors?
  4. Are there any functions or methods you know of that could improve efficiency?
  5. Is the code readable?
  6. Was there something you learned from reading the code that you would use in the future?

While this process will not catch errors in code that is producing results for manuscripts, the hope is that it will a) help everyone learn better programming principles and b) make people more comfortable sharing their code so that we can ultimately implement a more rigorous code peer review process.

Clearly we are a group in very early stages of thinking about best practices and some sort of shared standards across our very independent work, but I have gotten a lot of positive feedback on Coding Workshop after the first couple of meetings, so I hope it will be successful in leading to more rigorous efforts down the line.

5 Likes