Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SonarCloud error reduction: java rule S5361: "String#replace" should be preferred to "String#replaceAll" #9945

Open
CDellaGiusta opened this issue Mar 10, 2025 · 2 comments · May be fixed by #9955
Labels
good first issue Good for newcomers sonar-cloud-error-reduction all items related to reduce the number of errors in SonarCloud

Comments

@CDellaGiusta
Copy link
Contributor

SonarCloud issues errors on java rule S5361: "String#replace" should be preferred to "String#replaceAll"
https://sonarcloud.io/organizations/uyuni-project/rules?open=java%3AS5361&rule_key=java%3AS5361

All issues in Uyuni for this rule:
https://sonarcloud.io/project/issues?languages=java&issueStatuses=OPEN%2CCONFIRMED&id=uyuni-project_uyuni&rules=java%3AS5361

These errors should be fixed. This task can be also split into smaller chunks.

@CDellaGiusta CDellaGiusta added good first issue Good for newcomers sonar-cloud-error-reduction all items related to reduce the number of errors in SonarCloud labels Mar 10, 2025
@Princekumarofficial
Copy link

@CDellaGiusta
We can also replace
return cpe.replaceAll(":{1,4}$", "");
with
return cpe.replaceFirst(":{1,4}$", "");
since it seems to be a fixed trailing pattern

@Princekumarofficial
Copy link

i made a PR, this is my first time contributing to some a large and complex project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers sonar-cloud-error-reduction all items related to reduce the number of errors in SonarCloud
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants