CLion 2022.3 Help

Review code in Space

The Space plugin allows you to invite your colleagues to review code and discuss changes directly in CLion. With the Space plugin, you can:

Create code reviews

A code review lets your teammates review the changes made in scope of selected commits.

  1. In the View | Tool Windows | Git tool window, select the Log tab.

  2. Right-click a commit and select Space | Create Code Review. To narrow down the list of commits, you can use the search field and filters.

  3. In the Code Reviews tool window that opens, enter a meaningful title for your code review and assign reviewers.

  4. Click Create Code Review.

    Create Space code review

Create merge requests

A merge request is a special type of code review, which lets you compare two branches and invite your colleagues to review it.

  1. From the main menu, select Tools | Space | Code Reviews.

  2. In the Code Reviews tool window that opens, click the Add button and select Create Merge Request.

  3. Select the source and target branches. By default, the currently checked out branch is selected as the source branch, and the configured main branch as the target.

  4. Enter a meaningful title and assign reviewers.

  5. Click Create Merge Request.

    Create Space merge request

Review tools

In CLion, you can use the Code Reviews tool window to browse available reviews, the Timeline pane to view the history of a review, and the Diff pane to preview changes and post line comments.

Code Reviews tool window

If your code is hosted on Space, the Code Reviews tool window opens automatically. It is also available via the Tools | Space menu or by clicking your profile picture on the right side of the toolbar.

The Code Reviews shows all code reviews of your Space project. The list of code reviews available in Code Reviews depends on the repository that is currently opened in CLion. Selecting a code review opens its main page with the following tabs:

  • Details: shows the author and reviewers. For code reviews, this also shows the branch, which is under review; for merge requests, it shows the source and target branches.

  • Files: list of files to be reviewed. If a file contains line comments, their count is also displayed here. You can select a file to open the Diff pane.

  • Commits: select a commit to narrow down the scope of displayed changes. Or right-click a commit and select Show in Git Log to view commit details and history in the Git log.

Details

Timeline pane

The Timeline pane appears in the editor when you open a code review or a merge request. It lists all comments and events related to the review. You can post general comments here.

Timeline

Diff pane

The Diff pane appears in the editor when you select a file. It is a regular CLion Difference viewer, which shows the comparison between the previous and the current version of the file. With the Space plugin, you can use it to post line comments.

Diff pane

Review code

In Space, a typical code review process involves two roles: an author and a reviewer. Both participants can view code, post comments, and reply to them. While reviewing the code, you can post two types of comments:

  • On the Timeline pane: general comments (or review comments), which are not attached to any file or part of code. You can start a thread by replying to general comments.

  • On the Diff pane: line comments, which are used to discuss a particular line of code. You can reply to line comments to continue the discussion. You can then resolve and reopen these discussions.

When you post a comment, a notification is sent to the other party of the review. If you don't want to disturb other participants before you are finished reviewing or revising, you can save your comments as drafts and submit them all at once when you're done.

All comments in CLion and in the Space web version are instantly synchronized, so you can continue discussions wherever you like. To format your text, you can use the Markdown syntax.

Find a code review

  1. In the Code Reviews tool window, filter reviews by their state, type, author, or reviewer.

    You can also use quick filters (App general filter) to quickly apply filters to the review list:

    • Open: all open reviews in your project.

    • Includes my changes: all open code reviews where you are the author.

    • Needs my attention: open code reviews where you are the author, and it's your turn.

    • Needs my review: open code reviews where you are a reviewer, and it's your turn.

    • Assigned to me: open and closed reviews in which you participate as a reviewer.

    • Closed: all closed reviews in your project.

    Space quick filters
  2. Click a code review to open its details, view commits, and post comments.

Post a general comment

  1. In the Code Reviews tool window, select a review.

  2. In the Timeline pane that opens, enter your comment and press Enter.

  3. If it's your turn in the review, you can also select how to post the comment:

    • Select Post now if you want to notify the review participants immediately.

    • Select Save as Draft if you do not want to post this comment right now. Draft comments will be automatically posted when you complete your turn in the review.

Post a line comment

  1. In the Code Reviews tool window, select a review.

  2. In the Files tab, double-click a file that you want to open for comments. You can then use the Code Reviews | Commits tab to narrow down the list of changes.

  3. Hover over a line of code and click App general add. To select multiple lines, click a line of code and drag your cursor up or down.

  4. Enter your comment and press Enter.

  5. If it's your turn in the review, you can also select how to post the comment:

    • Select Post now if you want to notify the review participants immediately.

    • Select Save as Draft if you do not want to post this comment right now. Draft comments will be automatically posted when you complete your turn in the review.

Mark files as viewed or not viewed

Files that have not been reviewed yet are marked with a blue dot on the Files tab. If you open the file diff, it is considered as viewed. You can mark files as viewed and not viewed to keep track of what remains to review.

Files tab
  1. In the Code Reviews tool window, select a review.

  2. Open the Files tab.

  3. Right-click a file and in the context menu click Mark as Viewed or Mark as Not Viewed.

Mention people

In general and line comments, you can mention users of your Space organization to invite them to discussions. They will then receive a message in Space Chats.

  1. While writing a comment, enter @.

  2. Select a user from the list.

Complete your turn in a review

If you are a reviewer in a turn-based review, you are usually supposed to complete your turn by either accepting the changes or requesting additional information from the author. When you complete your turn, draft comments become visible to other participants of the review. For a detailed description of turn-based reviews, refer to Space documentation.

  1. In the Code Reviews tool window, select a review.

  2. On the Details tab, select how you want to complete the review:

    • Click Wait for Response if you want to come back to this review later; for example, you expect the author to make changes and want to review them.

    • Click Accept if you accept the changes.

    These two buttons also display the count of your line comments that are saved as drafts and are not yet visible to other participants of the review.

Details

If you have selected the Wait for Response option, it will now be the author's turn to review your comments and send the review back to you. You can repeat this process until both of you accept the changes.

Currently, closing a review and merging a branch are not supported in CLion; you can close reviews and merge branches using the web version of Space.

Quit a review

You can quit a review if, for example, you no longer participate in it and don't want to receive notifications on new comments.

  1. In the Code Reviews tool window, select a review.

  2. Click Leave review.

Last modified: 18 January 2023