Junie is a new power and advanced artificial intelligence (AI) that helps the developers to create, review and analyze code to improve the quality and avoid common issues that sometimes we cannot see during the development process.
Junie is integrated in all the IDEs offered by JetBrains for this demo. We will use Rider and also a C# code related to a simple api that uses the minimal api template provided by dotnet.
I created a new branch and I commited some changes that include bad practices and issues. Here is the list of issues:
- Hardcode id used for testing proposal
id = 1; //testing with item 1
- bad formatted code (this code looks like Python)
if (region is null)
{
return
Results.NotFound();
}
- Some unuseful or innecesary conditions:
if (!isValidSort)
{
if (region is not null)
{
if (db is not null)
{
return Results.BadRequest(RequestMessages.BadRequest);
}
}
}
- A hardcoded value is embedded within a query. Sometimes this is valid but not for this case because it refers to the Id.
var region = await db.Regions.Include(p => p.Departments)
.SingleOrDefaultAsync(p => p.Id == 0);
After addressing these issues, we can use Junie to review our code and identify any problems before creating a pull request and moving forward with the changes. This is how Junie looks in Rider when you have a project open:
In the chat we need to write the prompt depending on what we want to do with the code. To perform a codereview of the git changes in the branch this is a possible prompt:
Execute an in-depth code review of the current branch, analyzing all committed changes. Generate a document summarizing your findings and ensure to incorporate every recommendation into the code.
Junie will perform some commands in order to complete the instructions requested in the promtp.
After completing all the steps planned by Junie we have now the changes applied in the code and we can see how effective the code review
The hardcoded ID and improperly formatted code have been identified:
Junie identified unnecessary conditions, a hardcoded ID in the query, typos in the department variable, and an issue in the produces function where it's returning department instead of regions.
In conclusion, Junie proves to be an exceptional tool for conducting code reviews. I am truly impressed by its ability to not only identify newly introduced issues but also to catch additional changes made in previous commits around the same code.
We can highlight some advantages of using Junie in our local environment to perform the code review:
We can detect additional changes or issues code analyzing our changes but also all the code around
We can save time and resources by opting to perform the whole code review in the pull request.
We can generate additional code like documentation and relese notes, creating a prompt with more details and steps.
I suggest taking time and working with this AI for some weeks so you can see the potential of this tool.
Top comments (0)