diff options
Diffstat (limited to 'plugins/InspectionGadgets/test/com/siyeh')
8 files changed, 92 insertions, 0 deletions
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_collection_query_update/MismatchedCollectionQueryUpdate.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_collection_query_update/MismatchedCollectionQueryUpdate.java index 5c53674cd15b..5af84ecb21e7 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_collection_query_update/MismatchedCollectionQueryUpdate.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_collection_query_update/MismatchedCollectionQueryUpdate.java @@ -275,4 +275,18 @@ class SimpleAdd { return null; } +} +class EnumConstant { + private static final List<String> CONSTANT_ARRAY = new ArrayList(); + static { + CONSTANT_ARRAY.add("asdf"); + } + + enum SomeEnum { + ITEM(CONSTANT_ARRAY); // passed as argument + private final List<String> myPatterns; + SomeEnum(List<String> patterns) { + myPatterns = patterns; + } + } }
\ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_string_builder_query_update/MismatchedStringBuilderQueryUpdate.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_string_builder_query_update/MismatchedStringBuilderQueryUpdate.java index c8d9fb80cf19..2274472eb2fa 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_string_builder_query_update/MismatchedStringBuilderQueryUpdate.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_string_builder_query_update/MismatchedStringBuilderQueryUpdate.java @@ -31,3 +31,15 @@ interface List<T> { interface Consumer<T> { void accept(T t); } +class EnumConstant { + private static final StringBuilder sb = new StringBuilder(); + static { + sb.append(""); + } + + enum SomeEnum { + ITEM(sb); // passed as argument + + SomeEnum(StringBuilder sb) {} + } +} diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/if_statement_with_identical_branches/IfStatementWithIdenticalBranches.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/if_statement_with_identical_branches/IfStatementWithIdenticalBranches.java index 666651d71e21..fef2e0f1f6ff 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/if_statement_with_identical_branches/IfStatementWithIdenticalBranches.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/if_statement_with_identical_branches/IfStatementWithIdenticalBranches.java @@ -162,4 +162,15 @@ class NotADup { private static String placeOrder(int i, Object o) { return null; } + + void m() { + int j; + <warning descr="'if' statement with identical branches">if</warning> (true) { + j = 2; + } + else { + j = 2; + } + System.out.println("j = " + j); + } } diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/try_identical_catches/TryIdenticalCatches.after.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/try_identical_catches/TryIdenticalCatches.after.java index 032fa0002dea..a161e388ce3b 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/try_identical_catches/TryIdenticalCatches.after.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/try_identical_catches/TryIdenticalCatches.after.java @@ -117,4 +117,18 @@ class TryIdenticalCatches { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } + + public static void main() { + Throwable causeException; + try { + throw new NullPointerException(); + } catch (final NullPointerException e) { + causeException = e; + } catch (final IllegalArgumentException e) { + causeException = e; + } catch (final IndexOutOfBoundsException e) { + causeException = e; + } + System.out.println("causeException = " + causeException); + } }
\ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/try_identical_catches/TryIdenticalCatches.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/try_identical_catches/TryIdenticalCatches.java index 5d33c50de89e..09694491d69d 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/try_identical_catches/TryIdenticalCatches.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/try_identical_catches/TryIdenticalCatches.java @@ -120,4 +120,18 @@ class TryIdenticalCatches { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } + + public static void main() { + Throwable causeException; + try { + throw new NullPointerException(); + } catch (final NullPointerException e) { + causeException = e; + } <warning descr="catch branch identical to 'NullPointerException' branch">catch (final IllegalArgumentException e)</warning> { + causeException = e; + } <warning descr="catch branch identical to 'NullPointerException' branch">catch (final IndexOutOfBoundsException e)</warning> { + causeException = e; + } + System.out.println("causeException = " + causeException); + } }
\ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/internationalization/implicit_default_charset_usage/ImplicitDefaultCharsetUsage.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/internationalization/implicit_default_charset_usage/ImplicitDefaultCharsetUsage.java index 17dd59eadf7a..151042fa3ed9 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/internationalization/implicit_default_charset_usage/ImplicitDefaultCharsetUsage.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/internationalization/implicit_default_charset_usage/ImplicitDefaultCharsetUsage.java @@ -1,6 +1,9 @@ package com.siyeh.igtest.internationalization.implicit_default_charset_usage; import java.io.*; +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; +import java.nio.charset.CharsetEncoder; import java.util.ArrayList; import java.util.Formatter; import java.util.Locale; @@ -37,4 +40,12 @@ class ImplicitDefaultCharsetUsage { new Scanner("string input"); new ArrayList(10); } + + void charsetEnAndDecoders(InputStream inputStream, OutputStream outputStream) throws IOException { + final Charset cs = Charset.forName("UTF-8"); + CharsetDecoder cd = cs.newDecoder(); + InputStreamReader is = new InputStreamReader(inputStream, cd); + CharsetEncoder ce = cs.newEncoder(); + final OutputStreamWriter ow = new OutputStreamWriter(outputStream, ce); + } }
\ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/logging/logger_initialized_with_foreign_class/LoggerInitializedWithForeignClass.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/logging/logger_initialized_with_foreign_class/LoggerInitializedWithForeignClass.java new file mode 100644 index 000000000000..b252b8af1cd3 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/logging/logger_initialized_with_foreign_class/LoggerInitializedWithForeignClass.java @@ -0,0 +1,13 @@ +import java.util.logging.*; + +class LoggerInitializedWithForeignClass { + + void foo() { + new Object() { + void bar() { + Logger.getLogger(LoggerInitializedWithForeignClass.class.getName()); + Logger.getLogger(<warning descr="Logger initialized with foreign class 'String.class'">String.class</warning>.getName()); + } + }; + } +}
\ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_fully_qualified_name/test1/package-info.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_fully_qualified_name/test1/package-info.java new file mode 100644 index 000000000000..01825303d455 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_fully_qualified_name/test1/package-info.java @@ -0,0 +1,3 @@ +/** + * {@link java.util.Map(java.util.function.BiConsumer)} +*/
\ No newline at end of file |