Skip to content

feature: adds other environment support#14

Merged
manufacturist merged 1 commit into
mainfrom
feature/environment-support
Jun 17, 2026
Merged

feature: adds other environment support#14
manufacturist merged 1 commit into
mainfrom
feature/environment-support

Conversation

@pedrobpereira

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings June 17, 2026 10:41
manufacturist
manufacturist previously approved these changes Jun 17, 2026
@codacy-production

codacy-production Bot commented Jun 17, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication 0

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_URL when setting OpenAPI.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.

Comment thread src/index.ts
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";
Comment thread src/index.ts
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";

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/index.ts
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";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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";

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/index.ts
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";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Suggested change
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";

@pedrobpereira pedrobpereira force-pushed the feature/environment-support branch from aa20b78 to a094e02 Compare June 17, 2026 10:46
@manufacturist manufacturist merged commit ca896df into main Jun 17, 2026
4 checks passed
@manufacturist manufacturist deleted the feature/environment-support branch June 17, 2026 10:55
@github-actions github-actions Bot mentioned this pull request Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants