BerandaComputers and TechnologyShow HN: Raid – GitHub diff with refactoring information

Show HN: Raid – GitHub diff with refactoring information

Tests and Lint
Chrome Web Store
MIT license

Code review is a key practice in modern software development. Currently, this practice is performed using textual diff tools, such as the one provided by GitHub. However, diff results can easily become complex and hard to understand. Refactorings, for example, are not represented at all in diff results. This makes diff understanding more complex because reviewers need to infer themselves that a given group of added and removed lines of code represent, for example, an extract method.

result

RAID is a tool pipeline that seamlessly enriches GitHub diff results with refactoring information. See the following figure:

As presented in this figure, this pipeline has three key components:

  • RefDiff: a tool to detect refactoring operations in commits. We rely on GitHub Actions to automatically execute RefDiff after each Pull Request.

  • An external server, that collects the list of refactorings produced by RefDiff.

  • A Chrome plug-in that seamlessly annotates diff chunks with refactoring data (see the following snapshot).

Move Method

Move Method

Pull Up Method

Pull Up Method

Rename Method

Rename Method

Installation

To detect refactorings in your repository, you must first install this Chrome plug-in and configure RefDiff on Github Actions.


To execute RefDiff as Github Actions, you need to create a workflow file in .github/workflows folder with .yaml extension. Example of configuration: .github/workflows/workflow.yml:

on: [pull_request] # Trigger RefDiff after each pull request

jobs:
    main:
        runs-on: ubuntu-latest
        name: Refactoring Detection
        steps:
            - name: Git Checkout
              uses: actions/checkout@v2
              with:
                  fetch-depth: 0

            - name: raid
              env:
                  LANGUAGE: ${{ github.event.repository.language }} # Supports Java, Javascrit, C and Go.
                  REV_BEFORE: ${{ github.event.pull_request.base.sha }}
                  REV_AFTER: ${{ github.event.pull_request.head.sha }}
              uses: rodrigo-brito/refactoring-aware-diff@action

Simple Example

We created a simple pull request with commits including toy refactorings, to illustrate the usage of our plug-in. See here (but first you need to install our plug in).

License

Distributed under the MIT License. See LICENSE for more information.

Read More

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments