Repository navigation
CLI-1162 Consolidate repetitive test cases into parameterized tests - #785
Merged
damien-urruty-sonarsource merged 2 commits intoSep 25, 2026
Merged
Conversation
✅ Deploy Preview for sonarqube-cli canceled.
|
Fixed issues: - AZ-uhBkQLZzEXrPCyHIv for typescript:S5976 rule - AZ-uhCAkLZzEXrPCyHJ0 for typescript:S5976 rule - AZ-uhCCFLZzEXrPCyHJ2 for typescript:S5976 rule - AZ-uhB32LZzEXrPCyHJN for typescript:S5976 rule - AZ-uhCBpLZzEXrPCyHJ1 for typescript:S5976 rule Generated by SonarQube Agent (task: e074e3ee-ff7c-4837-b6f7-d371b015b158)
damien-urruty-sonarsource
force-pushed
the
remediate-master-20260907-050105-c6016a87
branch
from
September 25, 2026 06:41
c5c9a76 to
8c9f7f9
Compare
|
damien-urruty-sonarsource
approved these changes
Sep 25, 2026
damien-urruty-sonarsource
deleted the
remediate-master-20260907-050105-c6016a87
branch
September 25, 2026 06:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This change consolidates 18 repetitive test cases across 5 test files into 5 parameterized tests using it.each, eliminating code duplication and improving test maintainability. By replacing structurally identical tests that differ only in literal values with table-driven parameterized tests, the code becomes more concise, easier to modify, and aligns with testing best practices.
View Project in SonarCloud
Fixed Issues
typescript:S5976 - Replace these 4 tests with a single Parameterized one. • MAJOR • View issue
Location:
tests/unit/core/host/connectivity/network-config.test.ts:350Why is this an issue?
When several tests have the same structure and differ only by a few hardcoded values, they are harder to maintain as separate tests. A table-driven test makes the common behavior explicit and keeps the varying data in one place.
What changed
Replaces the four separate test declarations with a single
it.eachparameterized test. The test table encodes the varying data (description suffix, noProxy value, and URL) for each of the original four tests: exact hostname match, suffix match, wildcard *, and * in a comma-separated list. This directly addresses the code smell about having multiple tests with the same structure that should be consolidated into one parameterized test.typescript:S5976 - Replace these 3 tests with a single Parameterized one. • MAJOR • View issue
Location:
tests/unit/commands/integrate/antigravity/health.test.ts:69Why is this an issue?
When several tests have the same structure and differ only by a few hardcoded values, they are harder to maintain as separate tests. A table-driven test makes the common behavior explicit and keeps the varying data in one place.
What changed
This hunk replaces the first of three structurally identical tests with a single parameterized
it.eachtest. The three original tests ('returns configured when sonar-secrets block and script exist', 'returns not_configured when the sonar-secrets block is disabled', and 'returns invalid when the PreToolUse matcher is not view_file') differed only in theenabledflag, thematchervalue, and the expected result. This hunk consolidates them into one table-driven test with parameters[expected, enabled, matcher], directly addressing the code smell about replacing three repetitive tests that share the same structure with a single parameterized test. The parameterized values (enabled: true/false,matcher: 'view_file'/'edit_file', and expected results'configured'/'not_configured'/'invalid') capture all the variation that previously existed across the separate tests.typescript:S5976 - Replace these 4 tests with a single Parameterized one. • MAJOR • View issue
Location:
tests/integration/specs/run/mcp.test.ts:160Why is this an issue?
When several tests have the same structure and differ only by a few hardcoded values, they are harder to maintain as separate tests. A table-driven test makes the common behavior explicit and keeps the varying data in one place.
What changed
This hunk replaces four separate test cases (for --debug, --read-only, --toolsets, and --toolsets with cag/vortex) with a single parameterized
it.eachtest. It defines the parameter table with the varying values (flag, envFlag, envValue) and sets up the parameterized test signature, directly addressing the code smell about replacing duplicated tests with a single parameterized test.typescript:S5976 - Replace these 3 tests with a single Parameterized one. • MAJOR • View issue
Location:
tests/integration/specs/api/api.test.ts:50Why is this an issue?
When several tests have the same structure and differ only by a few hardcoded values, they are harder to maintain as separate tests. A table-driven test makes the common behavior explicit and keeps the varying data in one place.
What changed
This hunk replaces three separate test cases ('exits with code 2 for an invalid HTTP method', 'exits with code 2 when endpoint does not start with /', and 'exits with code 2 when --data is not valid JSON') with a single parameterized
it.each(...)test. It defines the data table containing the varying values (description suffix, command string, and expected error message) and sets up the parameterized test signature, directly addressing the code smell about replacing three structurally identical tests with a single parameterized one.typescript:S5976 - Replace these 3 tests with a single Parameterized one. • MAJOR • View issue
Location:
tests/integration/specs/list/list-issues.test.ts:252Why is this an issue?
When several tests have the same structure and differ only by a few hardcoded values, they are harder to maintain as separate tests. A table-driven test makes the common behavior explicit and keeps the varying data in one place.
What changed
This hunk replaces the beginning of the first individual test ('exits with code 2 when --page-size is greater than 500') with an
it.each([...])parameterized test. It defines a data table containing the three sets of varying values (description, command, expectedError) for the page-size, severities, and statuses validation tests. This consolidates three structurally identical tests into a single parameterized test, directly addressing the code smell about replacing duplicated tests that differ only in hardcoded literal values with a single parameterized test usingit.each.SonarQube Remediation Agent uses AI. Check for mistakes.