コード例 #1
0
 @Test
 public void detected() {
   SourceFile file =
       JavaAstScanner.scanSingleFile(
           new File("src/test/files/checks/ReturnEmptyArrayyNotNullCheck.java"),
           new ReturnEmptyArrayyNotNullCheck());
   checkMessagesVerifier
       .verify(file.getCheckMessages())
       .next()
       .atLine(16)
       .withMessage("Return an empty array instead of null.")
       .next()
       .atLine(25)
       .next()
       .atLine(35)
       .next()
       .atLine(40)
       .next()
       .atLine(44)
       .next()
       .atLine(48)
       .next()
       .atLine(53)
       .withMessage("Return an empty collection instead of null.")
       .next()
       .atLine(57)
       .withMessage("Return an empty array instead of null.")
       .next()
       .atLine(61);
 }
コード例 #2
0
 @Test
 public void check_with_exclusion() {
   check.exclude = "com.sun.imageio,com.sun.jersey";
   SourceFile file =
       JavaAstScanner.scanSingleFile(
           new File("src/test/files/checks/SunPackagesUsedCheck.java"), check);
   checkMessagesVerifier
       .verify(file.getCheckMessages())
       .next()
       .atLine(10)
       .withMessage("Replace this usage of Sun classes by ones from the Java API.");
 }
コード例 #3
0
  @Test
  public void check() {
    XPathCheck check = new XPathCheck();
    check.xpathQuery = "//IDENTIFIER[string-length(@tokenValue) >= 10]";
    check.message = "Avoid identifiers which are too long!";

    SourceFile file =
        CSharpAstScanner.scanSingleFile(new File("src/test/resources/checks/xpath.cs"), check);
    checkMessagesVerifier
        .verify(file.getCheckMessages())
        .next()
        .atLine(7)
        .withMessage("Avoid identifiers which are too long!");
  }
 @Test
 public void detected() {
   SourceFile file =
       JavaAstScanner.scanSingleFile(
           new File("src/test/files/checks/RightCurlyBraceDifferentLineAsNextBlockCheck.java"),
           new RightCurlyBraceDifferentLineAsNextBlockCheck());
   checkMessagesVerifier
       .verify(file.getCheckMessages())
       .next()
       .atLine(5)
       .withMessage("Move this \"else\" keyword to a new dedicated line.")
       .next()
       .atLine(14)
       .withMessage("Move this \"catch\" keyword to a new dedicated line.");
 }
コード例 #5
0
 @Test
 public void detected() {
   SourceFile file =
       JavaAstScanner.scanSingleFile(
           new File("src/test/files/checks/SunPackagesUsedCheck.java"), check);
   checkMessagesVerifier
       .verify(file.getCheckMessages())
       .next()
       .atLine(1)
       .withMessage("Replace this usage of Sun classes by ones from the Java API.")
       .next()
       .atLine(2)
       .next()
       .atLine(7)
       .next()
       .atLine(8)
       .next()
       .atLine(10);
 }