Integrate CodeScene with GitHub Pull Requests¶
CodeScene identifies and prioritizes technical debt, while at the same time uncovering and measuring social factors of the organization behind the system. The earlier you can react to any potential finding, the better. That’s why CodeScene offers an integration with GitHub pull requests that let you incorporate the analysis results into your existing delivery workflow.
CodeScene and Pull Requests: Use Cases¶
The purposes of CodeScene’s pull request integration is to:
Specify quality gates that trigger in case the Code Health of a hotspot declines.
Prioritize code reviews based on the risk of the commits.
Get early warnings such a complexity trend increases and detect the absence of expected change coupling.
Quality Gates for declining Code Health¶
CodeScene integrates with pull requests via GitHub’s checks API. That way, CodeScene can act as a (soft) quality gate during development. If a hotspot declines in health, CodeScene detects it and informs via the checks:
Prioritize Code Reviews via the predicted Delivery Risk¶
In many organizations, code reviews tend to become bottlenecks. There’s only so much code we can review each day, and after a while it becomes easy to slip. Suddenly, a critical error makes its way to production.
To help optimize code reviews, CodeScene predicts a delivery risk of each change set and commit. You see the predicted delivery risk in the detailed information:
CodeScene scores each commit on the range 1 to 10. 1 is a low risk change and 10 is the highest risk.
Use the risk prediction to focus your reviews and verification activities on the places where they are likely to be needed the most; high-risk changes might require two independent reviewers, whereas you can roll through low-risk changes more quickly.
How are high risk commits identified?¶
CodeScene calculates a unique risk profile for your codebase. The risk profile is based on how the system has evolved and what a typical change looks like. That is, CodeScene looks at how a specific commit or pull request differs from your normal ways of working.
CodeScene’s risk profile is a combination of technical and social metrics. The technical metrics relate to the scope and diffusion of the changes (e.g. how many different sub-systems does the commit touch compared to your typical change).
The social dimension of the risk profile relates to the experience of the programmer doing the change. The more experienced the programmer, the lower the risk. This means that two commits with identical changes may be classified differently depending on the measured experience of the programmer doing the change; Experience mediates risk.
Enable the Pull Request Integration¶
Navigate to your project’s configuration in CodeScene. The first step is to install the GitHub app for the integration. CodeScene will inform you of this step, if needed:
With the app installed, all you need to do is to check a box and you are up and running with a single click:
Set Up an Automatic Analysis Schedule¶
CodeScene will always try to fetch the latest version of every file changed in a pull request, but it won’t do that for large pull requests containing more than 30 files.
To get the best results for the Pull Request Integration checks, it’s a good idea to set up an automatic full analysis for your project.
You can do this in the Analysis schedule section of the project configuration. See the Getting Started section to learn more about this feature.
Enable CodeScene’s Status Badges¶
At this point you might want to add CodeScene’s status badges to your project as well. Status badges allow your teams to keep an eye on the health of their projects at a glance:
The status badges are intended for embedding in your GitHub README file. Sample GitHub markup is provided on the “Status Badges” configuration tab.
Constraints and Limitations¶
CodeScene’s pull request integration requires a paid plan.
Pull requests created from forked repositories are supported with a caveat: If the fork’s branch (from which the PR has been created) is not up to date with the corresponding upstream repository’s main branch then it’s possible that CodeScene fails to detect a code health decline (or an improvement) due to obsolete versions of changed files in the fork. This should only happen when the files modified by the PR has been changed, in the meantime, in the upstream repository . A recommended remedy is to keep forks synchronized with upstream repositories.