Skip to content

Resolve error-prone violations #17988

@Atharv3221

Description

@Atharv3221

Follow up of #17845

task is convert WARN to ERROR and fix all violations

checkstyle/pom.xml

Lines 276 to 282 in 2a5ed2f

<!-- Reason at https://github.com/checkstyle/checkstyle/issues/17988. -->
-Xep:EqualsGetClass:WARN
-Xep:InlineFormatString:WARN
-Xep:JdkObsolete:WARN
-Xep:StatementSwitchToExpressionSwitch:WARN
-Xep:StringSplitter:WARN
-Xep:EffectivelyPrivate:WARN

each rule should be in separate PR.

Some old list problems:

Source File: "AbbreviationAsWordInNameCheck.java"
Bug Pattern: "JdkObsolete"
Description: "It is very rare for LinkedList to out-perform ArrayList or ArrayDeque. Avoid it unless you&apos;re willing to invest a lot of time into benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does not."
Line Contents: "final List&lt;DetailAST&gt; result = new LinkedList&lt;&gt;();"
Line Number: 436

Source File: "AbstractImportControl.java"
Bug Pattern: "JdkObsolete"
Description: "It is very rare for LinkedList to out-perform ArrayList or ArrayDeque. Avoid it unless you&apos;re willing to invest a lot of time into benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does not."
Line Contents: "private final Deque&lt;AbstractImportRule&gt; rules = new LinkedList&lt;&gt;();"
Line Number: 33

Source File: "AbstractSuperCheck.java"
Bug Pattern: "JdkObsolete"
Description: "It is very rare for LinkedList to out-perform ArrayList or ArrayDeque. Avoid it unless you&apos;re willing to invest a lot of time into benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does not."
Line Contents: "private final Deque&lt;MethodNode&gt; methodStack = new LinkedList&lt;&gt;();"
Line Number: 48

Source File: "ConfigurationLoader.java"
Bug Pattern: "InlineFormatString"
Description: "Prefer to create format strings inline, instead of extracting them to a single-use constant"
Line Contents: "private static final String SAX_PARSE_EXCEPTION_FORMAT = &quot;%s - %s:%s:%s&quot;;"
Line Number: 78

Source File: "CsvFilterElement.java"
Bug Pattern: "EqualsGetClass"
Description: "Prefer instanceof to getClass when implementing Object#equals."
Line Contents: "public boolean equals(Object object) {"
Line Number: 105

Source File: "CustomImportOrderCheck.java"
Bug Pattern: "StringSplitter"
Description: "String.split(String) has surprising behavior"
Line Contents: "final String[] import1Tokens = import1.split(separator);"
Line Number: 654

Source File: "CustomImportOrderCheck.java"
Bug Pattern: "StringSplitter"
Description: "String.split(String) has surprising behavior"
Line Contents: "final String[] import2Tokens = import2.split(separator);"
Line Number: 655

Source File: "DescendantIterator.java"
Bug Pattern: "JdkObsolete"
Description: "It is very rare for LinkedList to out-perform ArrayList or ArrayDeque. Avoid it unless you&apos;re willing to invest a lot of time into benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does not."
Line Contents: "private final Queue&lt;NodeInfo&gt; queue = new LinkedList&lt;&gt;();"
Line Number: 48

Source File: "EmptyCatchBlockCheck.java"
Bug Pattern: "StringSplitter"
Description: "String.split(String) has surprising behavior"
Line Contents: "final String[] lines = LINE_END_PATTERN.split(commentContent);"
Line Number: 155

Source File: "EmptyLineSeparatorCheck.java"
Bug Pattern: "JdkObsolete"
Description: "It is very rare for LinkedList to out-perform ArrayList or ArrayDeque. Avoid it unless you&apos;re willing to invest a lot of time into benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does not."
Line Contents: "final List&lt;DetailAST&gt; childNodes = new LinkedList&lt;&gt;();"
Line Number: 502

Source File: "InlineTagUtil.java"
Bug Pattern: "StringSplitter"
Description: "String.split(String) has surprising behavior"
Line Contents: "final String[] precedingLines = NEWLINE_PATTERN.split(precedingText);"
Line Number: 126

Source File: "JavadocPropertiesGenerator.java"
Bug Pattern: "StatementSwitchToExpressionSwitch"
Description: "This statement switch can be converted to a new-style arrow switch"
Line Contents: "switch (node.getType()) {"
Line Number: 279

Source File: "JavadocTypeCheck.java"
Bug Pattern: "StringSplitter"
Description: "String.split(String) has surprising behavior"
Line Contents: "TYPE_NAME_IN_JAVADOC_TAG_SPLITTER.split(tag.getFirstArg())[0];"
Line Number: 405

Source File: "JavadocTypeCheck.java"
Bug Pattern: "StringSplitter"
Description: "String.split(String) has surprising behavior"
Line Contents: "typeParamName = TYPE_NAME_IN_JAVADOC_TAG_SPLITTER.split(tag.getFirstArg())[0];"
Line Number: 430

Source File: "LineColumn.java"
Bug Pattern: "EqualsGetClass"
Description: "Prefer instanceof to getClass when implementing Object#equals."
Line Contents: "public boolean equals(Object other) {"
Line Number: 78

Source File: "Main.java"
Bug Pattern: "InlineFormatString"
Description: "Prefer to create format strings inline, instead of extracting them to a single-use constant"
Line Contents: "final String msg = &quot;Could not find config XML file &apos;%s&apos;.&quot;;"
Line Number: 878

Source File: "Main.java"
Bug Pattern: "JdkObsolete"
Description: "It is very rare for LinkedList to out-perform ArrayList or ArrayDeque. Avoid it unless you&apos;re willing to invest a lot of time into benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does not."
Line Contents: "final List&lt;File&gt; result = new LinkedList&lt;&gt;();"
Line Number: 220

Source File: "ModifiedControlVariableCheck.java"
Bug Pattern: "JdkObsolete"
Description: "It is very rare for LinkedList to out-perform ArrayList or ArrayDeque. Avoid it unless you&apos;re willing to invest a lot of time into benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does not."
Line Contents: "final List&lt;DetailAST&gt; foundExpressions = new LinkedList&lt;&gt;();"
Line Number: 400

Source File: "ModifiedControlVariableCheck.java"
Bug Pattern: "StatementSwitchToExpressionSwitch"
Description: "This statement switch can be converted to a new-style arrow switch"
Line Contents: "switch (ast.getType()) {"
Line Number: 164

Source File: "ModuleJavadocParsingUtil.java"
Bug Pattern: "StringSplitter"
Description: "String.split(String) has surprising behavior"
Line Contents: "final String[] javadocPortionLinesSplit = javadocPortion.split(NEWLINE"
Line Number: 109

Source File: "PropertiesMacro.java"
Bug Pattern: "InlineFormatString"
Description: "Prefer to create format strings inline, instead of extracting them to a single-use constant"
Line Contents: "private static final String URL_F = &quot;%s#%s&quot;;"
Line Number: 72

Source File: "PropertiesMacro.java"
Bug Pattern: "JdkObsolete"
Description: "It is very rare for LinkedList to out-perform ArrayList or ArrayDeque. Avoid it unless you&apos;re willing to invest a lot of time into benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does not."
Line Contents: "final List&lt;String&gt; orderProperties = new LinkedList&lt;&gt;(properties);"
Line Number: 222

Source File: "RedundantModifierCheck.java"
Bug Pattern: "StatementSwitchToExpressionSwitch"
Description: "This statement switch can be converted to a new-style arrow switch"
Line Contents: "switch (ast.getType()) {"
Line Number: 257

Source File: "RequireThisCheck.java"
Bug Pattern: "JdkObsolete"
Description: "It is very rare for LinkedList to out-perform ArrayList or ArrayDeque. Avoid it unless you&apos;re willing to invest a lot of time into benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does not."
Line Contents: "final Deque&lt;AbstractFrame&gt; frameStack = new LinkedList&lt;&gt;();"
Line Number: 207

Source File: "ReturnCountCheck.java"
Bug Pattern: "StatementSwitchToExpressionSwitch"
Description: "This statement switch can be converted to a new-style arrow switch"
Line Contents: "switch (ast.getType()) {"
Line Number: 161

Source File: "ReverseDescendantIterator.java"
Bug Pattern: "JdkObsolete"
Description: "It is very rare for LinkedList to out-perform ArrayList or ArrayDeque. Avoid it unless you&apos;re willing to invest a lot of time into benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does not."
Line Contents: "private final Deque&lt;NodeInfo&gt; stack = new LinkedList&lt;&gt;();"
Line Number: 43

Source File: "ReverseDescendantIterator.java"
Bug Pattern: "JdkObsolete"
Description: "It is very rare for LinkedList to out-perform ArrayList or ArrayDeque. Avoid it unless you&apos;re willing to invest a lot of time into benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does not."
Line Contents: "private final Queue&lt;NodeInfo&gt; queue = new LinkedList&lt;&gt;();"
Line Number: 39

Source File: "SummaryJavadocCheck.java"
Bug Pattern: "StatementSwitchToExpressionSwitch"
Description: "This statement switch can be converted to a new-style arrow switch"
Line Contents: "switch (currentAst.getType()) {"
Line Number: 211

Source File: "SuppressFilterElement.java"
Bug Pattern: "EqualsGetClass"
Description: "Prefer instanceof to getClass when implementing Object#equals."
Line Contents: "public boolean equals(Object other) {"
Line Number: 187

Source File: "SuppressWarningsHolder.java"
Bug Pattern: "JdkObsolete"
Description: "It is very rare for LinkedList to out-perform ArrayList or ArrayDeque. Avoid it unless you&apos;re willing to invest a lot of time into benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does not."
Line Contents: "ThreadLocal.withInitial(LinkedList::new);"
Line Number: 83

Source File: "SuppressWarningsHolder.java"
Bug Pattern: "JdkObsolete"
Description: "It is very rare for LinkedList to out-perform ArrayList or ArrayDeque. Avoid it unless you&apos;re willing to invest a lot of time into benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does not."
Line Contents: "final List&lt;String&gt; valueList = new LinkedList&lt;&gt;();"
Line Number: 488

Source File: "SuppressWarningsHolder.java"
Bug Pattern: "StatementSwitchToExpressionSwitch"
Description: "This statement switch can be converted to a new-style arrow switch"
Line Contents: "switch (nextType) {"
Line Number: 354

Source File: "SuppressionXpathFilter.java"
Bug Pattern: "EqualsGetClass"
Description: "Prefer instanceof to getClass when implementing Object#equals."
Line Contents: "public boolean equals(Object obj) {"
Line Number: 278

Source File: "TagParser.java"
Bug Pattern: "JdkObsolete"
Description: "It is very rare for LinkedList to out-perform ArrayList or ArrayDeque. Avoid it unless you&apos;re willing to invest a lot of time into benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does not."
Line Contents: "private final List&lt;HtmlTag&gt; tags = new LinkedList&lt;&gt;();"
Line Number: 49

Source File: "TodoCommentCheck.java"
Bug Pattern: "StringSplitter"
Description: "String.split(String) has surprising behavior"
Line Contents: "final String[] lines = ast.getText().split(&quot;\n&quot;);"
Line Number: 93

Source File: "TokenUtil.java"
Bug Pattern: "InlineFormatString"
Description: "Prefer to create format strings inline, instead of extracting them to a single-use constant"
Line Contents: "private static final String TOKEN_ID_EXCEPTION_FORMAT = &quot;unknown TokenTypes id &apos;%s&apos;&quot;;"
Line Number: 54

Source File: "TranslationCheck.java"
Bug Pattern: "InlineFormatString"
Description: "Prefer to create format strings inline, instead of extracting them to a single-use constant"
Line Contents: "private static final String DEFAULT_TRANSLATION_FILE_NAME_FORMATTER = &quot;%s.%s&quot;;"
Line Number: 147

Source File: "TranslationCheck.java"
Bug Pattern: "InlineFormatString"
Description: "Prefer to create format strings inline, instead of extracting them to a single-use constant"
Line Contents: "private static final String FILE_NAME_WITH_LANGUAGE_CODE_FORMATTER = &quot;%s_%s.%s&quot;;"
Line Number: 149

Source File: "TranslationCheck.java"
Bug Pattern: "InlineFormatString"
Description: "Prefer to create format strings inline, instead of extracting them to a single-use constant"
Line Contents: "private static final String REGEXP_FORMAT_TO_CHECK_DEFAULT_TRANSLATIONS = &quot;^%s\\.%s$&quot;;"
Line Number: 155

Source File: "TranslationCheck.java"
Bug Pattern: "InlineFormatString"
Description: "Prefer to create format strings inline, instead of extracting them to a single-use constant"
Line Contents: "private static final String REGEXP_FORMAT_TO_CHECK_REQUIRED_TRANSLATIONS ="
Line Number: 152

Source File: "XMLLogger.java"
Bug Pattern: "StatementSwitchToExpressionSwitch"
Description: "This statement switch can be converted to a new-style arrow switch"
Line Contents: "switch (chr) {"
Line Number: 265

Source File: "XpathFilterElement.java"
Bug Pattern: "EqualsGetClass"
Description: "Prefer instanceof to getClass when implementing Object#equals."
Line Contents: "public boolean equals(Object other) {"
Line Number: 218

Each Bug Pattern should be fixed and tested in individual PR after fixing mark WARN as ERROR


Solve FormatStringShouldUsePlaceholders error-prone violations from test area of code.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions