Enforcing Quality Gates in Codeac: A Step-by-Step Guide to Blocking Pull Requests
Learn how to configure Codeac quality gates to automatically block pull requests that exceed complexity, duplication, or style violation thresholds. This guide covers setup, verification, and troubleshooting.
20 May 2026, 01:19 UTC

The Problem: Merging Low-Quality Code
Without automated enforcement, pull requests often merge with excessive complexity, style violations, or security issues. This technical debt compounds across sprints, requiring manual code review overhead and creating inconsistent code quality across the codebase.
The Solution: Configure Quality Gates in Codeac
Codeac's quality gates act as automated gatekeepers, blocking merges when predefined thresholds are exceeded. This guide walks through setting up a gate that prevents merging if code complexity or duplication exceeds acceptable limits.
Prerequisites
- GitHub or GitLab repository with admin access
- Codeac account with repository integration configured
- Write permissions for the repository (required for status checks)
- Basic understanding of code quality metrics: complexity, duplication, style violations
Procedure: Creating and Activating a Quality Gate
- Navigate to Quality Gates: In Codeac's web interface, go to
Settings → Quality Gates - Create New Gate: Click
Create Quality Gateand name it (e.g., "Sprint Quality Gate") - Add Conditions: Configure conditions using metric thresholds:
Complexity: SetCyclomatic Complexity > 10for any fileDuplication: SetDuplicated Lines > 5%in changed codeStyle Violations: SetTotal Violations > 0in new code
- Apply to Repository: Select target repository and branch protection rules
- Configure Branch Protection: In GitHub/GitLab, ensure the branch has status checks enabled for Codeac
Expected Checks and Verification
After configuration, verify the gate works by creating a test pull request:
- Pass Scenario: A PR with simple, clean code should show
Quality Gate: PASSEDand allow merging - Fail Scenario: A PR with complex functions should show
Quality Gate: FAILEDwith specific metric violations listed - Merge Prevention: Attempt to merge the failing PR - it should be blocked with a message referencing Codeac violations
Diagnostic Decision Tree
When a PR fails unexpectedly, use this decision process:
- Check Gate Configuration: Verify thresholds match team expectations in
Settings → Quality Gates - Review Metrics: Examine the Codeac report to identify which specific condition triggered the failure
- Validate Branch Protection: Confirm the target branch has Codeac status checks required for merge in repository settings
- Check Integration Status: Verify the Codeac app has read access to the repository and can post status checks
Recovery Options
If quality gates block legitimate changes:
- Adjust Thresholds: Increase complexity limit from 10 to 15 if legitimate complex code exists
- Exclude Generated Files: Add file patterns (e.g.,
*.generated.js) to exclude from analysis - Override Temporarily: Use
codeac overridecommand for exceptional cases (requires admin permissions)
Limitations and Considerations
Be aware of these constraints:
- Token Security: Integration tokens with write permissions should be rotated quarterly
- Large Repositories: For monorepos, use file filters to analyze only changed directories
- Initial Tuning: Expect false positives during first week; adjust thresholds based on team feedback
- Language Support: Quality gates work best with supported languages (Java, Python, JavaScript, C++).
Practical Verification Steps
- Create a PR with a deliberately complex function (e.g., nested 5-level if statements)
- Confirm Codeac posts a status check with
Quality Gate: FAILED - Attempt merge - verify it's blocked with violation details
- Simplify the function and push update
- Confirm gate now passes and merge is allowed
Monitoring Quality Trends
Once gates are active, use Codeac's historical reports to track:
- Merge rate of PRs passing quality gates (target: >95%)
- Average complexity trend across sprints
- Common violation patterns to inform team training
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.