Package org.sonar.squidbridge.api

Examples of org.sonar.squidbridge.api.SourceFile


        .noMore();
  }

  @Test
  public void test2() {
    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/tabCharacter.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .noMore();
  }
View Full Code Here


  private BooleanEqualityComparisonCheck check = new BooleanEqualityComparisonCheck();

  @Test
  public void test() {
    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/booleanEqualityComparison.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .next().atLine(1).withMessage("Remove the literal \"true\" boolean value.")
      .next().atLine(2)
      .next().atLine(3).withMessage("Remove the literal \"false\" boolean value.")
      .next().atLine(4)
      .next().atLine(5).withMessage("Remove the literal \"false\" boolean value.")
View Full Code Here

  private FunctionNameCheck check = new FunctionNameCheck();

  @Test
  public void testDefault() {
    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/FunctionName.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .next().atLine(4).withMessage("Rename this 'DoSomething' function to match the regular expression " + check.DEFAULT)
      .next().atLine(10)
      .next().atLine(17)
      .next().atLine(23)
      .noMore();
View Full Code Here

  @Test
  public void testCustom() {
    check.format = "^[A-Z][a-zA-Z0-9]*$";

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/FunctionName.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .next().atLine(1).withMessage("Rename this 'doSomething' function to match the regular expression " + check.format)
      .next().atLine(7)
      .next().atLine(14)
      .next().atLine(20)
      .noMore();
View Full Code Here

  @Test
  public void test() {
    FutureReservedWordsCheck check = new FutureReservedWordsCheck();

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/futureReservedWords.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(1).withMessage("Rename \"implements\" identifier to prevent potential conflicts with future evolutions of the JavaScript language.")
        .next().atLine(2).withMessage("Rename \"interface\" identifier to prevent potential conflicts with future evolutions of the JavaScript language.")
        .next().atLine(3).withMessage("Rename \"package\" identifier to prevent potential conflicts with future evolutions of the JavaScript language.")
        .next().atLine(4).withMessage("Rename \"private\" identifier to prevent potential conflicts with future evolutions of the JavaScript language.")
        .next().atLine(5).withMessage("Rename \"protected\" identifier to prevent potential conflicts with future evolutions of the JavaScript language.")
View Full Code Here

  private FixmeTagPresenceCheck check = new FixmeTagPresenceCheck();

  @Test
  public void test() {
    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/fixmeTagPresence.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .next().atLine(3).withMessage("Take the required action to fix the issue indicated by this comment.")
      .next().atLine(7)
      .next().atLine(8)
      .next().atLine(11)
      .next().atLine(13);
View Full Code Here

  @Test
  public void test() {
    UnreachableCodeCheck check = new UnreachableCodeCheck();

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/unreachableCode.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(3).withMessage("This statement can't be reached and so start a dead code block.")
        .next().atLine(7)
        .next().atLine(14)
        .next().atLine(17)
        .next().atLine(38)
View Full Code Here

  private TooManyLinesInFileCheck check = new TooManyLinesInFileCheck();

  @Test
  public void testDefault() {
    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/tooManyLinesInFile.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .noMore();
  }
View Full Code Here

  }

  @Test
  public void testCustom() {
    check.maximum = 1;
    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/tooManyLinesInFile.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .next().withMessage("File \"tooManyLinesInFile.js\" has 7 lines, which is greater than 1 authorized. Split it into smaller files.")
      .noMore();
  }
View Full Code Here

  @Test
  public void test() {
    FileHeaderCheck check = new FileHeaderCheck();
    check.headerFormat = "// copyright 2005";

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/FileHeaderCheck/file1.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .noMore();

    check = new FileHeaderCheck();
    check.headerFormat = "// copyright 20\\d\\d";

    file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/FileHeaderCheck/file1.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .next().atLine(null);

    check = new FileHeaderCheck();
    check.headerFormat = "// copyright 2005";

    file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/FileHeaderCheck/file2.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .next().atLine(null).withMessage("Add or update the header of this file.");

    check = new FileHeaderCheck();
    check.headerFormat = "// copyright 2012";

    file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/FileHeaderCheck/file2.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .noMore();

    check = new FileHeaderCheck();
    check.headerFormat = "// copyright 2012\n// foo";

    file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/FileHeaderCheck/file2.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .noMore();

    check = new FileHeaderCheck();
    check.headerFormat = "// copyright 2012\r\n// foo";

    file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/FileHeaderCheck/file2.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .noMore();

    check = new FileHeaderCheck();
    check.headerFormat = "// copyright 2012\r// foo";

    file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/FileHeaderCheck/file2.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .noMore();

    check = new FileHeaderCheck();
    check.headerFormat = "// copyright 2012\r\r// foo";

    file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/FileHeaderCheck/file2.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .next().atLine(null);

    check = new FileHeaderCheck();
    check.headerFormat = "// copyright 2012\n// foo\n\n\n\n\n\n\n\n\n\ngfoo";

    file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/FileHeaderCheck/file2.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .next().atLine(null);

    check = new FileHeaderCheck();
    check.headerFormat = "/*foo http://www.example.org*/";

    file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/FileHeaderCheck/file3.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .noMore();
  }
View Full Code Here

TOP

Related Classes of org.sonar.squidbridge.api.SourceFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.