Skip to content

Conversation

@ric03
Copy link
Contributor

@ric03 ric03 commented Sep 9, 2025

Hey, I just made a Pull Request!

Background: The SonarQubeRelatedEntitiesOverview collects all components of a system and displays them in a table. Those components may or may not have a sonarqube-annotation. The sonarqube-annotation is used to query the API. If there is no annotation, no data is displayed.

Problem: If there are rows without an annotation, meaning no data, then the sorting does not work as intended.

Current faulty behaviour:
test2

Note about the fix:
I did not dig deep enough, but i suspect that the deeply-nested object structure of the resolved object (with potentially undefined values) causes the problem. I opted to add the two sort-function. I am happy for alternative suggestions.

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

@ric03 ric03 requested review from a team as code owners September 9, 2025 23:11
@ric03 ric03 requested a review from awanlin September 9, 2025 23:11
@backstage-goalie
Copy link
Contributor

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage-community/plugin-sonarqube workspaces/sonarqube/plugins/sonarqube patch v0.18.0

Copy link
Member

@vinzscam vinzscam left a comment

Choose a reason for hiding this comment

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

thank you @ric03 🙏

Comment on lines 18 to 30
describe('datetimeSort', () => {
[
{ a: new Date(2025, 1).toISOString(), b: new Date(2026, 2).toISOString() },
{ a: new Date(2019, 3).toISOString(), b: new Date(2024, 5).toISOString() },
{
a: new Date(2019, 2, 1).toISOString(),
b: new Date(2019, 2, 2).toISOString(),
},
].forEach(({ a, b }) => {
it(`should return negative number when ${a} < ${b}`, () => {
const result = datetimeSort<string>(x => x)(a, b, undefined);
expect(result).toBeLessThan(0);
});
});
Copy link
Member

Choose a reason for hiding this comment

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

jest can help a bit here:

Suggested change
describe('datetimeSort', () => {
[
{ a: new Date(2025, 1).toISOString(), b: new Date(2026, 2).toISOString() },
{ a: new Date(2019, 3).toISOString(), b: new Date(2024, 5).toISOString() },
{
a: new Date(2019, 2, 1).toISOString(),
b: new Date(2019, 2, 2).toISOString(),
},
].forEach(({ a, b }) => {
it(`should return negative number when ${a} < ${b}`, () => {
const result = datetimeSort<string>(x => x)(a, b, undefined);
expect(result).toBeLessThan(0);
});
});
describe('datetimeSort', () => {
it.each([
[new Date(2025, 1), new Date(2026, 2)],
[new Date(2019, 3), new Date(2024, 5)],
[new Date(2019, 2, 1), new Date(2019, 2, 2)],
])(`should return negative number when %o < %o`, (a, b) => {
const result = datetimeSort<string>(x => x)(
a.toISOString(),
b.toISOString(),
undefined,
);
expect(result).toBeLessThan(0);
});

same below 👇

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice, thank you. I have applied your suggestion. Additionally i have wrapped the invalid params in a nested describe.

…itiesOverview`

if there are rows without an annotation, meaning no data, then the sorting does not work as intended.

The sort-behavior mimics `Array.prototype.sort()`, with undefined values sorted to the end.

Signed-off-by: Tom Schneider <[email protected]>
Copy link
Member

@vinzscam vinzscam left a comment

Choose a reason for hiding this comment

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

thank you @ric03 🚢

@vinzscam vinzscam merged commit 9d3c263 into backstage:main Sep 22, 2025
11 checks passed
sebaparedero14 pushed a commit to sebaparedero14/community-plugins that referenced this pull request Oct 2, 2025
…itiesOverview` (backstage#5297)

if there are rows without an annotation, meaning no data, then the sorting does not work as intended.

The sort-behavior mimics `Array.prototype.sort()`, with undefined values sorted to the end.

Signed-off-by: Tom Schneider <[email protected]>
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