Search in sources :

Example 96 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class IndentationTest method correctIfTest.

@Test
public void correctIfTest() throws Exception {
    final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
    final Configuration checkConfig = getCheckConfig("Indentation");
    final String filePath = getPath("InputIndentationCorrectIfAndParameter.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) Test(org.junit.Test)

Example 97 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class AnnotationLocationTest method annotationTestVariables.

@Test
public void annotationTestVariables() throws Exception {
    final Class<AnnotationLocationCheck> clazz = AnnotationLocationCheck.class;
    getCheckMessage(clazz, "annotation.location.alone");
    final Configuration checkConfig = getCheckConfig("AnnotationLocation", "AnnotationLocationVariables");
    final String msgLocation = "annotation.location";
    final String[] expected = { "63: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "7", "4") };
    final String filePath = getPath("InputAnnotationLocationVariables.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) AnnotationLocationCheck(com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocationCheck) Test(org.junit.Test)

Example 98 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class CommentsIndentationTest method testSurroundingCode.

@Test
public void testSurroundingCode() throws Exception {
    final String[] expected = { "13: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 14, 14, 12), "23: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.block", 24, 16, 12), "25: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.block", 27, 16, 12), "28: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.block", 31, 16, 12), "50: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 53, 27, 36), "51: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.block", 53, 23, 36), "90: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 91, 14, 8), "98: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 100, 13, 8), "108: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 109, 33, 8) };
    final Configuration checkConfig = getCheckConfig("CommentsIndentation");
    final String filePath = getPath("InputCommentsIndentationSurroundingCode.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) Test(org.junit.Test)

Example 99 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class CommentsIndentationTest method testCommentIsInsideSwitchBlock.

@Test
public void testCommentIsInsideSwitchBlock() throws Exception {
    final String[] expected = { "19: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.block", 20, 12, 16), "25: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", "24, 26", 19, "16, 12"), "31: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", "30, 32", 19, "16, 12"), "48: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 49, 6, 16), "55: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 56, 8, 12), "59: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 58, 22, 16), "68: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", "65, 69", 14, "12, 16"), "88: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 89, 24, 20), "113: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", "112, 114", 15, "17, 12"), "125: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 126, 8, 12), "138: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 139, 4, 8), "157: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", "156, 158", 18, "16, 12"), "200: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", "199, 201", 4, "12, 12"), "203: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", "202, 206", 22, "16, 12"), "204: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", "202, 206", 20, "16, 12"), "205: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", "202, 206", 17, "16, 12"), "229: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", "228, 230", 6, "12, 12") };
    final Configuration checkConfig = getCheckConfig("CommentsIndentation");
    final String filePath = getPath("InputCommentsIndentationInSwitchBlock.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) Test(org.junit.Test)

Example 100 with Configuration

use of com.puppycrawl.tools.checkstyle.api.Configuration in project checkstyle by checkstyle.

the class CommentsIndentationTest method testCommentIsInsideEmptyBlock.

@Test
public void testCommentIsInsideEmptyBlock() throws Exception {
    final String[] expected = { "9: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 12, 19, 31), "10: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.block", 12, 23, 31), "33: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 34, 0, 8), "57: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 58, 0, 8), "71: " + getCheckMessage(CommentsIndentationCheck.class, "comments.indentation.single", 72, 0, 8) };
    final Configuration checkConfig = getCheckConfig("CommentsIndentation");
    final String filePath = getPath("InputCommentsIndentationInEmptyBlock.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) Test(org.junit.Test)

Aggregations

Configuration (com.puppycrawl.tools.checkstyle.api.Configuration)137 Test (org.junit.Test)127 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)21 DefaultConfiguration (com.puppycrawl.tools.checkstyle.DefaultConfiguration)16 Properties (java.util.Properties)13 CheckstyleException (com.puppycrawl.tools.checkstyle.api.CheckstyleException)9 File (java.io.File)9 Checker (com.puppycrawl.tools.checkstyle.Checker)5 PropertiesExpander (com.puppycrawl.tools.checkstyle.PropertiesExpander)4 OneTopLevelClassCheck (com.puppycrawl.tools.checkstyle.checks.design.OneTopLevelClassCheck)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 ModuleFactory (com.puppycrawl.tools.checkstyle.ModuleFactory)2 AuditListener (com.puppycrawl.tools.checkstyle.api.AuditListener)2 RootModule (com.puppycrawl.tools.checkstyle.api.RootModule)2 AnnotationLocationCheck (com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocationCheck)2 EmptyLineSeparatorCheck (com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck)2 MethodParamPadCheck (com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2