forked from checkstyle/checkstyle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue checkstyle#13772: IllegalImport with class pattern fails on the…
… static import
- Loading branch information
1 parent
a6a339f
commit 53b7ea5
Showing
3 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
97 changes: 97 additions & 0 deletions
97
.../puppycrawl/tools/checkstyle/checks/imports/illegalimport/InputIllegalImportDefault8.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
IllegalImport | ||
illegalPkgs = java\\.util | ||
illegalClasses = ^java\\.awt\\..* | ||
regexp = true | ||
*/ | ||
|
||
package com.puppycrawl.tools.checkstyle.checks.imports.illegalimport; | ||
|
||
import java.io.*; | ||
import java.lang.*; | ||
import java.sql.Connection; | ||
import static java.util.List.copyOf; // violation | ||
import java.util.List; // violation | ||
import java.lang.ArithmeticException; | ||
import org.junit.jupiter.api.*; | ||
import java.util.Enumeration; // violation | ||
import java.util.Arrays; // violation | ||
|
||
import javax.swing.JToolBar; | ||
import javax.swing.JToggleButton; | ||
import javax.swing.ScrollPaneLayout; | ||
import javax.swing.BorderFactory; | ||
import static java.io.File.listRoots; | ||
|
||
import static javax.swing.WindowConstants.*; | ||
import static javax.swing.WindowConstants.*; | ||
import static java.io.File.createTempFile; | ||
import org.junit.jupiter.api.*; | ||
|
||
import java.awt.Component; // violation | ||
import static java.awt.Label.ABORT; // violation | ||
import java.awt.HeadlessException; // violation | ||
import java.awt.Label; // violation | ||
import java.util.Date; // violation | ||
import java.util.Calendar; // violation | ||
import java.util.BitSet; // violation | ||
|
||
class InputIllegalImportDefault8 | ||
{ | ||
/** ignore **/ | ||
private Class mUse1 = Connection.class; | ||
/** ignore **/ | ||
private Class mUse2 = java.io.File.class; | ||
/** ignore **/ | ||
private Class mUse3 = null; | ||
/** ignore **/ | ||
private Class mUse4 = java.util.Enumeration[].class; | ||
/** usage of illegal import **/ | ||
private String ftpClient = null; | ||
|
||
/** usage via static method, both normal and fully qualified */ | ||
{ | ||
int[] x = {}; | ||
Arrays.sort(x); | ||
Object obj = javax.swing.BorderFactory.createEmptyBorder(); | ||
File[] files = listRoots(); | ||
} | ||
|
||
/** usage of inner class as type */ | ||
private JToolBar.Separator mSep = null; | ||
|
||
/** usage of inner class in Constructor */ | ||
private Object mUse5 = new Object(); | ||
|
||
/** usage of inner class in constructor, fully qualified */ | ||
private Object mUse6 = new javax.swing.JToggleButton.ToggleButtonModel(); | ||
|
||
/** we use class name as member's name. | ||
* also an inline JavaDoc-only import {@link Vector linkText} */ | ||
private int Component; | ||
|
||
/** | ||
* method comment with JavaDoc-only import {@link BitSet#aMethod()} | ||
*/ | ||
public void Label() {} | ||
|
||
/** | ||
* Renders to a {@linkplain Graphics2D graphics context}. | ||
* @throws HeadlessException if no graphis environment can be found. | ||
* @exception HeadlessException if no graphis environment can be found. | ||
*/ | ||
public void render() {} | ||
|
||
/** | ||
* First is a class with a method with arguments {@link TestClass1#method1(TestClass2)}. | ||
* Next is a class with typed method {@link TestClass3#method2(TestClass4, TestClass5)}. | ||
* | ||
* @param param1 with a link {@link TestClass6} | ||
* @throws TestClass7 when broken | ||
* @deprecated in 1 for removal in 2. Use {@link TestClass8} | ||
*/ | ||
@Deprecated | ||
public void aMethodWithManyLinks() {} | ||
} |