Package org.sonar.squid.api

Examples of org.sonar.squid.api.SourceFile


  @Rule
  public CheckMessagesVerifierRule checkMessagesVerifier = new CheckMessagesVerifierRule();

  @Test
  public void detected() {
    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/TodoTagPresenceCheck.cc"), new TodoTagPresenceCheck());
    checkMessagesVerifier.verify(file.getCheckMessages())
      .next().atLine(3).withMessage("Complete the task associated to this TODO comment.")
      .next().atLine(7)
      .next().atLine(8)
      .next().atLine(11)
      .next().atLine(13)
View Full Code Here


  public void check() {
    XPathCheck check = new XPathCheck();
    check.xpathQuery = "//declaration";
    check.message = "Avoid declarations!! ";

    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/xpath.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(1).withMessage(check.message)
        .noMore();
  }
View Full Code Here

  private NoSonarCheck check = new NoSonarCheck();

  @Test
  public void test() {
    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/NoSonarTagPresenceCheck.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(2).withMessage("Is //NOSONAR used to exclude false-positive or to hide real quality flaw ?")
        .noMore();
  }
View Full Code Here

  public void test() {
    CommentRegularExpressionCheck check = new CommentRegularExpressionCheck();
    check.regularExpression = "(?i).*TODO.*";
    check.message = "Avoid TODO";

    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/commentRegularExpression.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(3).withMessage("Avoid TODO")
        .next().atLine(5)
        .next().atLine(6)
        .noMore();
  }
View Full Code Here

  @Rule
  public CheckMessagesVerifierRule checkMessagesVerifier = new CheckMessagesVerifierRule();

  @Test
  public void detected() {
    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/IndentationCheck.cc"), new IndentationCheck());
    checkMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(5).withMessage("Make this line start at column 3.")
        .next().atLine(11)
        .next().atLine(12)
        .next().atLine(16)
        .next().atLine(20)
View Full Code Here

  @Test
  public void custom() {
    IndentationCheck check = new IndentationCheck();
    check.indentationLevel = 4;

    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/IndentationCheck.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(4).withMessage("Make this line start at column 5.")
        .next().atLine(9)
        .next().atLine(11);
  }
View Full Code Here

  @Rule
  public CheckMessagesVerifierRule checkMessagesVerifier = new CheckMessagesVerifierRule();

  @Test
  public void detected() {
    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/StringLiteralDuplicatedCheck.cc"), new StringLiteralDuplicatedCheck());
    checkMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(12).withMessage("Define a constant instead of duplicating this literal \"bbbbb\" 2 times.")
        .next().atLine(14).withMessage("Define a constant instead of duplicating this literal \"ccccc\" 3 times.");
  }
View Full Code Here

  @Rule
  public CheckMessagesVerifierRule checkMessagesVerifier = new CheckMessagesVerifierRule();

  @Test
  public void detected() {
    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/UseCorrectTypesCheck.cc"), new UseCorrectTypeCheck());
    checkMessagesVerifier.verify(file.getCheckMessages())
    .next().atLine(7).withMessage("Use the correct type instead of NULL (1 times).")
    .next().atLine(10).withMessage("Use the correct type instead of WORD (1 times).")
    .next().atLine(11).withMessage("Use the correct type instead of DWORD (1 times).")
    .next().atLine(12).withMessage("Use the correct type instead of BOOL (1 times).")
    .next().atLine(16).withMessage("Use the correct type instead of BYTE (1 times).")
View Full Code Here

  public void test() {
    SafetyTagCheck check = new SafetyTagCheck();
    check.regularExpression = "<Safetykey>.*</Safetykey>";
    check.suffix = "_SAFETY";

    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/SafetyTagCheck.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .next().atLine(21).withMessage("Source files implementing risk mitigations shall use special name suffix '_SAFETY' : <Safetykey>MyRimName</Safetykey>");
   
    check = new SafetyTagCheck();
    check.regularExpression = "<Safetykey>.*</Safetykey>";
    check.suffix = "_SAFETY";
           
    file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/SafetyTagCheck_SAFETY.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .noMore();
   
    check = new SafetyTagCheck();
    check.regularExpression = "<Safetykey>";
    check.suffix = "_SAFETY";
           
    file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/SafetyTagCheck_SAFETY.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .noMore();

    check = new SafetyTagCheck();
    check.regularExpression = "@hazard";

    file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/SafetyTagCheck_SAFETY.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .noMore();
    }
View Full Code Here

  private MissingNewLineAtEndOfFileCheck check = new MissingNewLineAtEndOfFileCheck();

  @Test
  public void test() {
    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/MissingNewLineAtEndOfFile.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().withMessage("Add a new line at the end of this file.")
        .noMore();
  }
View Full Code Here

TOP

Related Classes of org.sonar.squid.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.