[Misc] Fix SonarCloud instanceof-pattern-matching issues in the xml modules - #1849
Merged
Conversation
…ules * Replace instanceof checks followed by a cast with instanceof pattern matching Co-Authored-By: Vincent Massol <vincent@massol.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes 34 open SonarCloud issues of rule
java:S6201("Replace this instanceof check and cast with 'instanceof Foo foo'") in thexwiki-commons-xmlandxwiki-commons-filter-xmlmodules.Every site binds a pattern variable and drops the now-redundant cast; where an explicit local already held the cast result, that local's name is reused as the pattern variable and its declaration removed. No behaviour change, no API change.
Verified with
mvn clean install -Plegacy,qualityon both modules (unit tests, Checkstyle, Revapi, Enforcer and the JaCoCo coverage gate all green).SonarCloud issues fixed
java:S6201 — Replace the instanceof check and cast with instanceof pattern matching (34)
XMLInputFilterStreamUtils.java:82XMLInputFilterStreamUtils.java:84XMLInputFilterStreamUtils.java:87XMLInputFilterStreamUtils.java:110XMLInputFilterStreamUtils.java:112XMLInputFilterStreamUtils.java:115AbstractXMLOutputFilterStream.java:76AbstractXMLOutputFilterStream.java:107XMLOutputFilterStreamUtils.java:81XMLOutputFilterStreamUtils.java:84XMLOutputFilterStreamUtils.java:87DefaultXMLParser.java:220DefaultXMLParser.java:240DefaultXMLParser.java:259DefaultXMLParser.java:306DefaultXMLParser.java:417DefaultXMLParser.java:423DefaultXMLParserFactory.java:85DefaultXMLSerializer.java:170DefaultXMLSerializer.java:170Sax2Dom.java:106Sax2Dom.java:134Sax2Dom.java:136XMLUtils.java:679XMLUtils.java:750XMLUtils.java:761LocalEntityResolver.java:569SanitizerFilter.java:155SAXEventWriter.java:80SAXEventWriter.java:83StAXUtils.java:106StAXUtils.java:133StAXUtils.java:174StAXUtils.java:178Related
Part of one SonarCloud sweep across the three repositories:
Generated by Claude Code