DEV Community

Matheus Mello
Matheus Mello

Posted on

How to improve your merge request 🤯

Create a DRAFT merge request

Creating a Draft merge request will allow your team to help you achieve better coding since they will do it as soon as possible the code review. Also, they will be able to raise your attention to some points that maybe you are missing.

Write a clear description

This will help your teammates understands what they are reviewing
All merge requests are able to receive a description, which may sound simple, but can help you a lot to check all points that you were supposed to cover, and also it will help your team understand what is your code about.

Small functions

Long functions are hard to debug and maintain. It is really hard to test it and understand its context of it.

function testing() {
    // ... really long function
}
Enter fullscreen mode Exit fullscreen mode

Small functions will help you handle the cases easily when you are writing test cases, and also it will help you to understand easily what is the context of a specific method/function.

function testing() {
    // smallFunction_1();
    // smallFunction_2();
    // smallFunction_3();
}
Enter fullscreen mode Exit fullscreen mode

A more descriptive variable names

Are you able to understand what is this if condition about?

  if (
            PUBLIC_FILE.test(nextUrl.pathname) ||
            nextUrl.pathname.startsWith("/_next") ||
            nextUrl.pathname.includes("/api") ||
            nextUrl.pathname.includes("/log")
        ) {
            return undefined;
        }
Enter fullscreen mode Exit fullscreen mode

Small merge requests

Sometimes we get so excited coding that we create huge monster requests 👹.
This is not a good practice because it will require so much effort in testing, doing the code review, and discussing improvements since the developed code could be really tight to each developed part. Small merge requests will help you handle this smoothly.

Write tests

Tests are the natural way to prove that something is working as supposed to, and from the logical perspective, you will be totally able to understand what the code does if you have it well tested.

Add comments

Adding comments to your code is a really powerful way to explain the core functionalities and responses from your code. Some people will argue that you need to avoid comments because if the code requires comments it is not clear, but this is not a necessary truth. Sometimes, we are dealing with so many cases and logic that it will help you and your team to understand why you decided to implement something using the XYZ method.

As you can see, these are simple suggestions but really powerful that will help you and your teammates with coding reviews.

👇 Let me know what you think about this topic in the comments section.
👉 Follow me to know more about it.
✅ This is my medium where I write all type of topics.
👋 This is my LinkedIn where I share some of my thoughts.

Top comments (0)