forked from yegor256/qulice
-
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.
For yegor256#772: Removal of overlapping checks of PMD and checkstyle
- Loading branch information
1 parent
e96aa02
commit 282ffe5
Showing
5 changed files
with
160 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
64 changes: 64 additions & 0 deletions
64
qulice-pmd/src/test/java/com/qulice/pmd/LocalVariableCouldBeFinalRuleTest.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,64 @@ | ||
/* | ||
* Copyright (c) 2011-2018, Qulice.com | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: 1) Redistributions of source code must retain the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer. 2) Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials provided | ||
* with the distribution. 3) Neither the name of the Qulice.com nor | ||
* the names of its contributors may be used to endorse or promote | ||
* products derived from this software without specific prior written | ||
* permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT | ||
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
* OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package com.qulice.pmd; | ||
|
||
import org.hamcrest.core.IsEqual; | ||
import org.hamcrest.core.StringStartsWith; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Test case for LocalVariableCouldBeFinal. | ||
* | ||
* @since 0.18 | ||
*/ | ||
public class LocalVariableCouldBeFinalRuleTest { | ||
|
||
/** | ||
* LocalVariableCouldBeFinal can detect when variable is not | ||
* final and shows correct message. | ||
* | ||
* @throws Exception If something goes wrong | ||
*/ | ||
@Test | ||
public final void detectLocalVariableCouldBeFinal() throws Exception { | ||
new PmdAssert( | ||
"LocalVariableCouldBeFinal.java", | ||
new IsEqual<>(false), | ||
new StringStartsWith( | ||
String.join( | ||
" ", | ||
"PMD: LocalVariableCouldBeFinal.java[6-6]:", | ||
"Local variable 'nonfinal' could be declared final", | ||
"(LocalVariableCouldBeFinal)" | ||
) | ||
) | ||
).validate(); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
qulice-pmd/src/test/java/com/qulice/pmd/UnusedImportsRuleTest.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,64 @@ | ||
/* | ||
* Copyright (c) 2011-2018, Qulice.com | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: 1) Redistributions of source code must retain the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer. 2) Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials provided | ||
* with the distribution. 3) Neither the name of the Qulice.com nor | ||
* the names of its contributors may be used to endorse or promote | ||
* products derived from this software without specific prior written | ||
* permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT | ||
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
* OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package com.qulice.pmd; | ||
|
||
import org.hamcrest.core.IsEqual; | ||
import org.hamcrest.core.StringStartsWith; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Test case for LocalVariableCouldBeFinal. | ||
* | ||
* @since 0.18 | ||
*/ | ||
public class UnusedImportsRuleTest { | ||
|
||
/** | ||
* UnusedImport can detect when the class has an unused import line and | ||
* show error message correctly. | ||
* | ||
* @throws Exception If something goes wrong | ||
*/ | ||
@Test | ||
public final void detectUnusedImportLine() throws Exception { | ||
new PmdAssert( | ||
"UnusedImports.java", | ||
new IsEqual<>(false), | ||
new StringStartsWith( | ||
String.join( | ||
" ", | ||
"PMD: UnusedImports.java[3-3]: Avoid unused imports such", | ||
"as 'unused.bar.foo.UnusedImport'", | ||
"(UnusedImports)" | ||
).trim() | ||
) | ||
).validate(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
qulice-pmd/src/test/resources/com/qulice/pmd/LocalVariableCouldBeFinal.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,9 @@ | ||
package foo; | ||
|
||
public final class LocalVariableCouldBeFinal { | ||
|
||
public int method() { | ||
int nonfinal = 0; | ||
return nonfinal; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
qulice-pmd/src/test/resources/com/qulice/pmd/UnusedImports.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,10 @@ | ||
package foo; | ||
|
||
import unused.bar.foo.UnusedImport; | ||
|
||
public final class UnusedImports { | ||
|
||
public int method() { | ||
return null; | ||
} | ||
} |