Skip to content

fix( #2034 ): Used Regex in replaceAll methods - #2035

Merged
sureshms merged 1 commit into
open-metadata:mainfrom
yasarshaikh:main
Jan 4, 2022
Merged

sureshms merged 1 commit into
open-metadata:mainfrom
yasarshaikh:main

Conversation

@yasarshaikh

Copy link
Copy Markdown
Contributor

Describe your changes :

Used Regex in replaceAll methods. It was part of #2034.

This issue was captured in Sonar as a code smell. Fixing it would help to make code good.

Type of change :

  • Bug fix

Checklist:

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my own.
  • I have tagged my reviewers below.
  • I have commented on my code, particularly in hard-to-understand areas.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • All new and existing tests passed.

Reviewers

@sureshms

@yasarshaikh

Copy link
Copy Markdown
Contributor Author

It seems something wrong with the job instance which is not able to download related dependencies/software to execute all actions.

@sureshms

sureshms commented Jan 4, 2022

Copy link
Copy Markdown
Contributor

@yasarshaikh, I think in most of these cases replaceAll can be replaced by just replace. See more details here -
https://sonarcloud.io/organizations/open-metadata/rules?open=java%3AS5361&rule_key=java%3AS5361

@sureshms

sureshms commented Jan 4, 2022

Copy link
Copy Markdown
Contributor

It seems something wrong with the job instance which is not able to download related dependencies/software to execute all actions.

There is some intermittent failure unrelated to this.

static final String FIELDS = "owner,followers,tags";
public static final List<String> FIELD_LIST = Arrays.asList(FIELDS.replaceAll(" ", "").split(","));
public static final List<String> FIELD_LIST = Arrays.asList(FIELDS.replaceAll("\\s", "").split(","));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In this case just replace is sufficient per Sonar Cloud guidelines.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Let me know if I should change the replaceAll to replace, I can do that it'd be a minor change :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That works as well. You can also create a separate issue to do that.

@sonarqubecloud

sonarqubecloud Bot commented Jan 4, 2022

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

90.7% 90.7% Coverage
0.0% 0.0% Duplication

@sureshms

sureshms commented Jan 4, 2022

Copy link
Copy Markdown
Contributor

Since most of these replaceAll calls are one time calls, better performance of replace call is not important. Merging the change. Thank you @yasarshaikh for your first contribution 🥳 !!!

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