Cleanup (light "unnecessary semicolon" inspection test)

This commit is contained in:
Roman Shevchenko
2016-06-30 17:42:33 +03:00
parent f2bff5f36e
commit 45f6d1425b
4 changed files with 62 additions and 111 deletions
@@ -0,0 +1,52 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.siyeh.igtest.style.unnecessary_semicolon;<warning descr="Unnecessary semicolon ';'">;</warning>
import java.util.List;<warning descr="Unnecessary semicolon ';'">;</warning>
class UnnecessarySemicolon {
int i;
<warning descr="Unnecessary semicolon ';'">;</warning> // comment
public UnnecessarySemicolon() {
<warning descr="Unnecessary semicolon ';'">;</warning> // this is a comment
<warning descr="Unnecessary semicolon ';'">;</warning> /* another */
}
} <warning descr="Unnecessary semicolon ';'">;</warning> // comment
enum Status {
BUSY ("BUSY" ),
DONE ("DONE" ) ; // <<---- THIS IS NOT UNNECESSARY
public final String text; <warning descr="Unnecessary semicolon ';'">;</warning>
private Status (String i_text) {
text = i_text;
}
}
enum BuildType {
;
public String toString() {
return super.toString();
}
}
class C {
void m() throws Exception {
try (AutoCloseable r1 = null; AutoCloseable r2 = null /*ok*/ ) { }
try (AutoCloseable r1 = null; AutoCloseable r2 = null<warning descr="Unnecessary semicolon ';'">;</warning> /*warn*/ ) { }
}
}
@@ -1,37 +0,0 @@
package com.siyeh.igtest.style.unnecessary_semicolon;;
import java.util.List;;
public class UnnecessarySemicolonInspection
{
int i;
; // comment
public UnnecessarySemicolonInspection()
{
; // this is a comment
; /* another */
}
} ; // comment
enum Status
{
BUSY ("BUSY" ),
DONE ("DONE" ) ; // <<---- THIS IS NOT UNNECESSARY
public final String text; ;
private Status (String i_text) {
text = i_text;
}
}
enum BuildType
{
;
public String toString() {
return super.toString();
}
}
class C {
void m() throws Exception {
try (AutoCloseable r1 = null; AutoCloseable r2 = null /*ok*/ ) { }
try (AutoCloseable r1 = null; AutoCloseable r2 = null; /*warn*/ ) { }
}
}
@@ -1,58 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>UnnecessarySemicolonInspection.java</file>
<line>2</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unnecessary semicolon</problem_class>
<description>Unnecessary semicolon &lt;code&gt;;&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>UnnecessarySemicolonInspection.java</file>
<line>3</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unnecessary semicolon</problem_class>
<description>Unnecessary semicolon &lt;code&gt;;&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>UnnecessarySemicolonInspection.java</file>
<line>7</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unnecessary semicolon</problem_class>
<description>Unnecessary semicolon &lt;code&gt;;&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>UnnecessarySemicolonInspection.java</file>
<line>10</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unnecessary semicolon</problem_class>
<description>Unnecessary semicolon &lt;code&gt;;&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>UnnecessarySemicolonInspection.java</file>
<line>11</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unnecessary semicolon</problem_class>
<description>Unnecessary semicolon &lt;code&gt;;&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>UnnecessarySemicolonInspection.java</file>
<line>13</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unnecessary semicolon</problem_class>
<description>Unnecessary semicolon &lt;code&gt;;&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>UnnecessarySemicolonInspection.java</file>
<line>19</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unnecessary semicolon</problem_class>
<description>Unnecessary semicolon &lt;code&gt;;&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>UnnecessarySemicolonInspection.java</file>
<line>35</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unnecessary semicolon</problem_class>
<description>Unnecessary semicolon &lt;code&gt;;&lt;/code&gt; #loc</description>
</problem>
</problems>
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,22 +15,16 @@
*/
package com.siyeh.ig.style;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.testFramework.IdeaTestUtil;
import com.siyeh.ig.IGInspectionTestCase;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.siyeh.ig.LightInspectionTestCase;
import org.jetbrains.annotations.Nullable;
public class UnnecessarySemicolonInspectionTest extends IGInspectionTestCase {
public class UnnecessarySemicolonInspectionTest extends LightInspectionTestCase {
public void testUnnecessarySemicolon() { doTest(); }
@Nullable
@Override
protected Sdk getTestProjectSdk() {
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
return IdeaTestUtil.getMockJdk17();
}
public void test() throws Exception {
doTest("com/siyeh/igtest/style/unnecessary_semicolon",
new UnnecessarySemicolonInspection());
protected InspectionProfileEntry getInspection() {
return new UnnecessarySemicolonInspection();
}
}