feature: adds other environment support#14
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Duplication | 0 |
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull request overview
This PR makes the CLI’s Codacy API endpoint configurable via an environment variable, enabling use against non-default Codacy environments while keeping the generated API client wiring unchanged.
Changes:
- Allows overriding the API host/base via
CODACY_API_BASE_URLwhen settingOpenAPI.BASE. - Normalizes the configured base URL to avoid a trailing slash before appending the API path.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const program = new Command(); | ||
|
|
||
| OpenAPI.BASE = "https://app.codacy.com/api/v3"; | ||
| OpenAPI.BASE = (process.env.CODACY_API_BASE_URL || "https://app.codacy.com").replace(/\/$/, "") + "/api/v3"; |
| const program = new Command(); | ||
|
|
||
| OpenAPI.BASE = "https://app.codacy.com/api/v3"; | ||
| OpenAPI.BASE = (process.env.CODACY_API_BASE_URL || "https://app.codacy.com").replace(/\/$/, "") + "/api/v3"; |
There was a problem hiding this comment.
Code Review
This pull request updates the Codacy API base URL configuration to support the CODACY_API_BASE_URL environment variable, stripping trailing slashes before appending /api/v3. The review feedback suggests making this more robust by also stripping any existing /api/v\d+ suffix from the environment variable to prevent malformed URLs.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| const program = new Command(); | ||
|
|
||
| OpenAPI.BASE = "https://app.codacy.com/api/v3"; | ||
| OpenAPI.BASE = (process.env.CODACY_API_BASE_URL || "https://app.codacy.com").replace(/\/$/, "") + "/api/v3"; |
There was a problem hiding this comment.
To make the CODACY_API_BASE_URL configuration more robust, consider also stripping a potential API path suffix (e.g., /api/v3) from the provided URL. This would prevent a malformed final URL like .../api/v2/api/v3 if a user mistakenly includes an API path in the environment variable. This change would make the URL construction resilient to this common configuration error.
| OpenAPI.BASE = (process.env.CODACY_API_BASE_URL || "https://app.codacy.com").replace(/\/$/, "") + "/api/v3"; | |
| OpenAPI.BASE = (process.env.CODACY_API_BASE_URL || "https://app.codacy.com").replace(/\/$/, "").replace(/\/api\/v\d+$/, "") + "/api/v3"; |
There was a problem hiding this comment.
Pull Request Overview
This PR enables custom environment support via the CODACY_API_BASE_URL environment variable. Although Codacy results are up to standards, there is a significant logic concern regarding the normalization of the base URL. If the environment variable includes the API version or trailing slashes, the current implementation may produce malformed URLs (e.g., duplicate /api/v3/api/v3). This should be addressed to ensure the feature works reliably across different user configurations. Furthermore, the PR lacks a description and automated tests to validate the new logic.
About this PR
- There are no tests included in this PR to verify the environment variable logic or the URL normalization. Automated tests are required to ensure the default behavior and custom URL overrides work as expected.
- The PR description is empty. Please provide context on the change and instructions for testing the new environment support.
Test suggestions
- Verify OpenAPI.BASE defaults to 'https://app.codacy.com/api/v3' when CODACY_API_BASE_URL is not defined.
- Verify OpenAPI.BASE uses the value from CODACY_API_BASE_URL when provided.
- Verify trailing slashes in CODACY_API_BASE_URL are correctly stripped before appending the API version suffix.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify OpenAPI.BASE defaults to 'https://app.codacy.com/api/v3' when CODACY_API_BASE_URL is not defined.
2. Verify OpenAPI.BASE uses the value from CODACY_API_BASE_URL when provided.
3. Verify trailing slashes in CODACY_API_BASE_URL are correctly stripped before appending the API version suffix.
TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback
| const program = new Command(); | ||
|
|
||
| OpenAPI.BASE = "https://app.codacy.com/api/v3"; | ||
| OpenAPI.BASE = (process.env.CODACY_API_BASE_URL || "https://app.codacy.com").replace(/\/$/, "") + "/api/v3"; |
There was a problem hiding this comment.
🟡 MEDIUM RISK
Suggestion: The base URL construction will double-append the API version if it is already present in the environment variable. Use a regex to safely handle both the host-only and full-path cases.
| OpenAPI.BASE = (process.env.CODACY_API_BASE_URL || "https://app.codacy.com").replace(/\/$/, "") + "/api/v3"; | |
| OpenAPI.BASE = (process.env.CODACY_API_BASE_URL || "https://app.codacy.com").replace(/\/+(api\/v3)?\/*$/, "") + "/api/v3"; |
aa20b78 to
a094e02
Compare
No description provided.