Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.2k views
in Technique[技术] by (71.8m points)

java - How to tell SonarQube not to apply a certain rule if the affected code satisfies some regex rule

There is a SonarQube rule named The diamond operator ("<>") should be used. The codebase I'm working on is pretty old so there are numerous instances like this:

List<String> list = new ArrayList<String>();

SonarQube suggests removal of 'String' on the right-side. So far so good.

The problem is, SonarQube also reports cases where we have something like this:

foobar.setItems(new ArrayList<String>());

How do I tell SonarQube to ignore all such cases (where for example, the new keyword is preceded by a parenthesis (?

Or is there a better way to disregard such reports, other than marking everyone of them as false positive?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

62 comments

56.6k users

...