In this article, we will outline how you can utilize Code Review questions within your live interview sessions with candidates. The following topics will be covered:
- What is a Code Review question?
- Functionality
- Adding a New Comment
- Creating a Code Review question
- Limitations
What is a Code Review question?
CodeSignal's Code Review question type is designed to evaluate a candidate's ability to review code, a crucial skill for software engineers. In these questions, candidates are presented with a piece of code and are asked to critically analyze existing code, identify errors, suggest improvements or evaluate the code's efficiency and readability. This type of question helps assess a candidate's understanding of best coding practices, ability to optimize code, and attention to detail.
Functionality
The Code Review question type is a tool you can use in our Interview product to simulate a common real-world task that software engineers often have to work with.
To use a Code Review question, you will need
- A Code Review question
- An active interview
In a Code Review question type, all parties can view all files and add new comments. Files in the diff view can be newly added, modified, or deleted.
Adding a New Comment
- To add a comment, hover over the line you want to add a comment on.
- Click on the blue plus sign next to the line of code.
- Write a comment and save.
- To edit or delete a comment, click on the pencil or trash icon next to the comment you want to delete.
Creating a Code Review question
Create a Code Review Question in-app
Click on the Question Library, and then click Create Question.
Select Code Review.
-
At first, you should choose an environment.
Click + ADD AN ENVIRONMENT and choose from the list.
- Then, select the Environment icon on the left navigation bar, below the Global Settings icon to add your question description.
-
Navigate to the Files tab next to the Environment Settings to add an initial and final states of the file.
You can upload initial and final states of your files directly to the question or create new files from scratch.
In a Code Review question type, all parties can view all files and add new comments. Files in the diff view can be newly added, modified, or deleted.
- Click Save SAVE in the bottom right when you're done configuring the question.
You will be able to view the Diff of your files in progress to see what code changes will look like in the question.
Create a Code Review Question via GraphQL
Code Review questions can also be created through GraphQL. Below is a sample of the operation. You can find more information on how to access CodeSignals API here. Once the files are added, the files will be read-only.
Operation:
mutation createCodeReviewTask($taskFields: CreateCodeReviewTaskInput!, $options: CreateTaskOptionsInput) {
createCodeReviewTask(taskFields: $taskFields, options: $options) {
executionEnvironments {
codeChanges {
changeType
path
source
}
description
environment
initialFiles {
isFolder
source
path
}
title
}
generalType
id
labels
maxScore
mode
overviewType
title
}
}
Variable:
{
"taskFields": {
"executionEnvironments": [
{
"codeChanges": [
{
"changeType": "deleted",
"path": "app.py",
"source": ""
},
{
"changeType": "modified",
"path": "main.py",
"source": "print('This is the main file')"
},
{
"changeType": "added",
"path": "test.py",
"source": "print('This is a test')"
}
],
"description": "Code Review question description",
"environment": "py3",
"initialFiles": [
{
"isFolder": false,
"path": "app.py",
"source": ""
},
{
"isFolder": false,
"path": "main.py",
"source": "print('Hello world')"
},
{
"isFolder": false,
"path": "test.py",
"source": ""
}
],
"title": "Python"
}
],
"name": "Code Review Example",
"title": "Code Review Example"
},
"options": {
"companyId": "abcdefg12345"
}
}
Limitation
At this time, the files can only be viewed in a split view.