Skip to content

CLI-172 filter issues by status#165

Open
sophio-japharidze-sonarsource wants to merge 1 commit intomasterfrom
CLI-172_filter_issues_by_status
Open

CLI-172 filter issues by status#165
sophio-japharidze-sonarsource wants to merge 1 commit intomasterfrom
CLI-172_filter_issues_by_status

Conversation

@sophio-japharidze-sonarsource
Copy link
Copy Markdown
Contributor

No description provided.

@hashicorp-vault-sonar-prod
Copy link
Copy Markdown

hashicorp-vault-sonar-prod bot commented Apr 9, 2026

CLI-172

@sonar-review-alpha
Copy link
Copy Markdown
Contributor

sonar-review-alpha bot commented Apr 9, 2026

Summary

This PR adds support for filtering issues by status via a new --status option on the list issues command. The implementation follows the existing severity filter pattern: accepts comma-separated values (OPEN, CONFIRMED, FALSE_POSITIVE, ACCEPTED, FIXED), validates input with helpful error messages, and normalizes case before passing to the SonarQube API.

Also includes a parameter rename in the internal API contract from statuses to issueStatuses to better distinguish the issue-filtering parameter from other status concepts. The fake test server and unit tests have been updated to support filtering by this new parameter.

What reviewers should know

Where to start: Check the command definition in command-tree.ts (lines 131-141) to see the option added and how it displays valid values. The validation logic is in issues.ts (lines 80-88).

Key decisions:

  • The status parameter is named issueStatuses in the API contract to avoid ambiguity with other status fields—this name change touches multiple files (types.ts, issues.ts, tests)
  • Input is normalized to uppercase before validation (case-insensitive UX) and normalized again before passing to the API
  • The refactoring of searchIssues() to use Object.entries().forEach() is broader than strictly necessary for this feature—review whether that style change is acceptable

Test coverage: Integration tests verify validation errors, single-value filtering, and multi-value filtering. The fake server filters by the new parameter correctly. Old unit test updated to use new parameter name.


  • Generate Walkthrough
  • Generate Diagram

🗣️ Give feedback

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

@sonar-review-alpha sonar-review-alpha bot left a comment

Choose a reason for hiding this comment

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

LGTM! ✅

One real bug needs fixing before merge: the --severity help text was updated to advertise comma-separated input, but the validation code still rejects anything other than a single value.

🗣️ Give feedback

Copy link
Copy Markdown
Member

@nquinquenel nquinquenel left a comment

Choose a reason for hiding this comment

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

Looks good, mostly one important feedback about wrong description or logic

Comment on lines +138 to +141
.option(
'--severity <severity>',
`Filter by severity (comma-separated list of: ${VALID_SEVERITIES.join(', ')})`,
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Severity moved from single value to comma-separated, but the implementation in issues.ts still treats it as a single value. Should align the implementation

expect(result.stdout).toContain('"total": 2');
});

it('passes single severity to API when --status is provided with a single value', async () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Title mentions "passes single severity" but uses --status, I think it should be changed

await issuesClient.searchIssues({
projects: 'my-project',
statuses: 'OPEN,REOPENED',
issueStatuses: 'OPEN,REOPENED',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is REOPENED a valid status? It's not in VALID_STATUSES

`Invalid status(es): '${options.status}'. Valid statuses are: ${VALID_STATUSES.join(', ')}`,
);
}
options.status = statuses.join(',');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor feedback, but it mutates the incoming options parameter, maybe you could assign in a value, as we do below for sev?

});

it('should pass statuses parameter', async () => {
it('should pass issueStatuses parameter', async () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor feedback, but there's a test to check that --severity throws when invalid, but not for --status. It's already handled in the integration tests, but maybe for having consistent tests?

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.

2 participants