Skip to content

Sonar-Fix: Extract duplicated "error" string literal into constant#1

Open
meysholdt wants to merge 10 commits into
mainfrom
sonar-fix/java-S1192
Open

Sonar-Fix: Extract duplicated "error" string literal into constant#1
meysholdt wants to merge 10 commits into
mainfrom
sonar-fix/java-S1192

Conversation

@meysholdt
Copy link
Copy Markdown
Collaborator

@meysholdt meysholdt commented Feb 25, 2026

SonarQube Issue

Field Value
Issue View in SonarQube Cloud
Rule java:S1192View rule
Severity HIGH
Type ADAPTABLE
Message Define a constant instead of duplicating this literal "error" 3 times.

What changed

Extracted the duplicated "error" string literal in OwnerController into a private static final String FLASH_ATTR_ERROR constant and replaced all three usages. This satisfies rule S1192 by ensuring the literal is defined once, reducing refactoring risk.

Verification

  • ./mvnw compile test passes
  • Fix is minimal and preserves existing behavior

meysholdt and others added 8 commits February 25, 2026 14:03
- Add .ona/mcp-config.json with SonarQube MCP server configuration
- Add SonarLint and Node.js to devcontainer, preserving upstream features
- Remove unused Dockerfile in favor of upstream base image
- Update README with SonarQube Cloud setup instructions

Co-authored-by: Ona <no-reply@ona.com>
Install SonarScanner CLI 6.2.1 in a custom Dockerfile and switch
devcontainer.json from image to build. Document CLI and SonarLint
usage in README.

Co-authored-by: Ona <no-reply@ona.com>
Configure sonar-maven-plugin 5.1.0 in pom.xml to enable running
scans via ./mvnw sonar:sonar.

Co-authored-by: Ona <no-reply@ona.com>
Define init (build) and run (spring-boot:run) automation tasks
matching the spring-petclinic reference configuration.

Co-authored-by: Ona <no-reply@ona.com>
Co-authored-by: Ona <no-reply@ona.com>
Co-authored-by: Ona <no-reply@ona.com>
Co-authored-by: Ona <no-reply@ona.com>
@meysholdt meysholdt force-pushed the sonar-fix/java-S1192 branch from cf938b4 to 4a3036a Compare February 26, 2026 07:47
@meysholdt meysholdt changed the title Sonar-Fix: Extract duplicated "error" string literal into constant Sonar-Fix: Extract duplicated "error" string literal into a constant Feb 26, 2026
meysholdt and others added 2 commits February 26, 2026 07:54
…nto constant

Co-authored-by: Ona <no-reply@ona.com>
@meysholdt meysholdt force-pushed the sonar-fix/java-S1192 branch from 4a3036a to 58695ef Compare February 26, 2026 07:59
@meysholdt meysholdt changed the title Sonar-Fix: Extract duplicated "error" string literal into a constant Sonar-Fix: Extract duplicated "error" string literal into constant Feb 26, 2026
@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.

1 participant