Combining loops when combine would have different result

There is a piece of code that prepares sitemap data.
First loop is used to populate urls map and then in second loop this map is used as input to SitemapUrl construcor. This map should be fully populated at the time when passed to SitemapUrl constructor and joining those two loops could not produce the same result.

I get a warning “Combine this loop with the one that starts on line 246.” - Multiple loops over the same set should be combined (java:S3047).

It’s not that I cannot live with this warning, but just to let you know for this case if you want to investigate.

final Map<String, String> urls = new HashMap<>();

final StringBuilder sb = new StringBuilder(XML_DEFINITION).append(CRLF).append(XML_URLSET_OPEN).append(CRLF);

// first fill up the Map
for (final Language lang : activeLanguages) {
	urls.put(lang.getLanguageTag(), this.tagService.getPath(tag.getTextId(), lang.getIso639two(), RestApiConfig.TAGS));

// then use full Map with SitemapUrl constructor
for (final Language lang : activeLanguages) {
		new SitemapUrl(
			this.tagService.getPath(tag.getTextId(), lang.getIso639two(), RestApiConfig.TAGS),



Thanks for this report!

Just to “dot the i’s”, can you provide the version of SonarQube you’re using?