Once I was a child my parents were convincing me that it was worth double checking both my homework as well as tests before handing them in, to catch errors and fix them. It soon became a habit for me. The habit that once evaluated into a self code review process :)
I will share with you the steps I take before commiting code. Probably most of them are obvious to you, but maybe you will find something interesting and worth including into your routine?
1. Compilation errors
This might seem to be quite obvious. If the code doesn’t compile, how can you even check if it works? I have added this step to my in-mind checklist lately as in our TypeScript projects the compile
script is a little more “strict” than the one for running an app in the hot reloading mode (e.g. compilation errors on unused imports). So even though the app recompiles seamlessly, it will not compile on the CI server.
2. Warnings
I actually quite like a strict approach when warnings prevent compilation. But this is not always the case, so it’s worth having in mind to look through the warnings and apply fixes where needed.
3. Unit and integration tests
Just run all tests and see if they are green. This is also the time for some framework-specific checks, e.g. mocha
requires to append only()
to test methods to run a specific subset of the tests. Of course you need to remove it before commiting :) Do you know any other frameworks’ features which are likely to produce this kind of leftovers?
4. The code review itself
I usually list all the files that have changed and then read them carefully one by one, paying special attention to the following elements (the similarity to an ordinary code review process is not accidental :) ).
- All the little things that make the code cleaner like all the shorthands or smart methods that modern languages have (to name a few: Kotlin’s
isNullOrEmpty
or Scala'sgetOrElse
). IDEs give lots of such hints, we just need to make use of them. - Spelling - typos make the code messy :)
- Rethink the names of classes, variables and so on. Are they meaningful enough? Or maybe too verbose?
- Any too complicated constructions like long computations or nested conditions? If I have just written it and still do not get the sense at first glance, maybe there is a way to make it cleaner?
IDEs make this kind of reading easier. In the code editing window you have the changed lines marked so you know which ones to focus on at most. I know some of us use the diff window for this purpose. I usually prefer the more gentle way of highlighting the differences, but that’s quite personal - try both and decide which is the best for you. Or just combine them.
5. The big picture
Then I read the code again, taking the big picture this time. The aim is to check if the code is clear and understandable, if it just reads smoothly.
6. CI server check
Once I have committed and pushed, the last step is to check if the code compiles and the tests are green on the CI server.
Do I apply this routine each and every time? Does this routine prevent me from checking some fishy code in? Of course not, we all know scenarios of delivering a feature as soon as possible or just a little change which surely does not require all these steps. Commits like Fix typos
or Remove “only” from tests
still happen :) But after all, we are only humans and we all make mistakes. And the teammate code review is just irreplaceable :)
Originally published at brightinventions.pl
By Agnieszka Olszewska, Software Engineer @ Bright Inventions
Email
Top comments (37)
As a trusted travel agency Stoney Creek, we are dedicated to providing exceptional travel planning services. Our team works closely with you to create customized itineraries that reflect your preferences and budget. From booking flights and accommodations to organizing tours and activities, we handle all aspects of your trip, ensuring a seamless and enjoyable experience.
Ensure your business stays protected with HQNS’s Managed IT Security & Compliance in Whitby. Our team implements advanced security measures tailored to your specific needs, ensuring your data is secure and compliant with industry standards. Protect your business with our reliable and responsive managed IT services.
Finding a skilled and trustworthy car mechanic in Brampton is easy with our dedicated team. With over 25 years of experience, we provide exceptional service, handling everything from routine maintenance to complex repairs. Our mechanics are committed to ensuring your vehicle’s optimal performance and safety.
Experience top-notch Track And Field Training In Ontario with programs inspired by Olympian Donna Clarke’s transition from gymnastics to track and field. Our training emphasizes building strength, speed, and agility, helping athletes prepare for competitions at both provincial and national levels.
Choose Liberty Tax Milton for all your tax preparation and filing needs. Our knowledgeable team of tax professionals is committed to delivering exceptional services that help you maximize your refund and stay compliant with tax laws. We pride ourselves on being a trusted partner in the Milton community for reliable tax services.
Conveniently located, our Mississauga road physiotherapy clinic offers comprehensive services aimed at enhancing your physical health. Whether you're dealing with sports injuries, chronic pain, or post-surgical recovery, our team is committed to providing effective treatments in a comfortable environment.
Searching for Welland homes for sale? Triplets Homes offers a modern approach to real estate marketing, combining professional architectural photography with advanced Internet marketing tools. Our innovative strategies ensure your Welland property gets maximum exposure, attracting the right buyers and achieving faster sales.
Healing Zone Physiotherapy Clinic provides custom orthotics Milton to help address foot-related issues, improve posture, and enhance your overall mobility. Our orthotics are tailored to fit your unique needs, ensuring that you receive the best possible support and comfort. Experience relief and improved foot function with our custom orthotics.
At Excel World, our team of dedicated immigration consultants Toronto provides personalized guidance to help individuals navigate the complexities of the Canadian immigration system. Our consultants are recognized for their professionalism, expertise, and success in helping clients achieve their immigration goals.
Creative Squad provides expert web development services designed to create visually stunning and highly functional websites. By collaborating closely with clients, we transform their ideas into digital experiences that captivate audiences and drive success. Our websites are built to perform seamlessly across all devices, ensuring a lasting impression.
Some comments have been hidden by the post's author - find out more