Skip to content

Clear the Sonar findings on the branding settings code - #2132

Open
Jakub-Bartal-01 wants to merge 1 commit into
mainfrom
fix/sonar-branding-findings
Open

Clear the Sonar findings on the branding settings code#2132
Jakub-Bartal-01 wants to merge 1 commit into
mainfrom
fix/sonar-branding-findings

Conversation

@Jakub-Bartal-01

Copy link
Copy Markdown
Contributor

Clears the five SonarCloud findings that #2081 and #2082 left on main. No behaviour changes.

BrandingLogoValidator

  • java:S8786SVG_LENGTH matched \s*(unit)?\s*$, so with no unit present both whitespace runs could claim the same spaces and the engine backtracked over every split. The runs are now possessive, which makes the match linear; a 40 000-space input goes from quadratic to 1 ms. The accepted language is unchanged.
  • java:S127 — the PNG chunk walk advanced offset from inside the loop body, because the step is the chunk length read from that chunk. It is a while loop now, so nothing assigns to a for counter.

SvgSanitizer

  • java:S1192"style" appeared three times, for the <style> element and the style attribute. It is a named constant.

Tests

  • java:S8491 — the Javadoc explaining why an unrecognised stored theme code is dropped sat above aBrandingUpdateWaitsForAConcurrentOneToRelease, which it does not describe. Moved onto anUnknownStoredThemeIsIgnoredRatherThanFailingTheRead.
  • java:S5778everyRejectionNamesTheFieldItCameFrom built its PNG fixture inside the assertThrows lambda. The fixture is built first, so only the call under test can throw from inside the lambda.

- SVG_LENGTH made the whitespace runs around the optional unit possessive,
  so a long run of spaces no longer takes quadratic time (java:S8786).
- The PNG chunk walk is a while loop, since its advance depends on the chunk
  length read inside the body and cannot sit in a for update clause (java:S127).
- SvgSanitizer names the "style" literal, used for both the element and the
  attribute (java:S1192).
- The Javadoc for the unknown-stored-theme test moved onto that test instead
  of dangling above an unrelated one (java:S8491).
- The PNG fixture in everyRejectionNamesTheFieldItCameFrom is built before the
  assertThrows lambda, leaving one throwing call inside it (java:S5778).
Copilot AI balanced review requested due to automatic review settings August 24, 2026 09:57

Copilot AI 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

Clears five SonarCloud findings in branding validation, sanitization, and tests without changing behavior.

Changes:

  • Makes SVG length matching linear and clarifies PNG chunk iteration.
  • Reuses a constant for SVG style handling.
  • Improves test fixture isolation and Javadoc placement.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
BrandingLogoValidator.java Uses possessive regex quantifiers and a clearer PNG loop.
SvgSanitizer.java Centralizes the "style" identifier.
BrandingLogoValidatorTest.java Builds the PNG fixture outside assertThrows.
BrandingSettingsITest.java Associates Javadoc with the correct test.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@sonarqubecloud

Copy link
Copy Markdown

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