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/UselessParenthesesCheck.cc"), new UselessParenthesesCheck());
    checkMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(4).withMessage("Remove those useless parentheses.")
        .next().atLine(5);
  }
View Full Code Here


  @Test
  public void test() {
    TooManyStatementsPerLineCheck check = new TooManyStatementsPerLineCheck();
    check.excludeCaseBreak = false;
    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/TooManyStatementsPerLine.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(10).withMessage("At most one statement is allowed per line, but 2 statements were found on this line.")
        .next().atLine(13)
        .next().atLine(16)
        .next().atLine(20)
        .next().atLine(22)
View Full Code Here

  @Test
  public void testExcludeCaseBreak() {
    TooManyStatementsPerLineCheck check = new TooManyStatementsPerLineCheck();
    check.excludeCaseBreak = true;
    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/TooManyStatementsPerLine.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(10).withMessage("At most one statement is allowed per line, but 2 statements were found on this line.")
        .next().atLine(13)
        .next().atLine(16)
        .next().atLine(20)
        .next().atLine(24)
View Full Code Here

  @Test
  public void check() {
    UseCorrectIncludeCheck check = new UseCorrectIncludeCheck();

    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/UseCorrectIncludeCheck.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(2).withMessage("Do not use relative path for #include directive.")
        .next().atLine(3)
        .next().atLine(4)
        .next().atLine(5)
        .next().atLine(6)
View Full Code Here

  private MissingCurlyBracesCheck check = new MissingCurlyBracesCheck();

  @Test
  public void test() {
    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/MissingCurlyBraces.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(6).withMessage("Missing curly brace.")
        .next().atLine(7)
        .next().atLine(8)
        .next().atLine(11)
        .next().atLine(22)
View Full Code Here

   
  @Test
  public void test_syntax_error_recovery() {
    CxxConfiguration config = new CxxConfiguration();
    config.setErrorRecoveryEnabled(true);
    SourceFile file = CxxAstScanner.scanSingleFileConfig(new File("src/test/resources/checks/parsingError3.cc"), config, new ParsingErrorRecoveryCheck());
   
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .next().atLine(2).withMessage("C++ Parser can't read code. Declaration is skipped.")
      .noMore();
  }   
View Full Code Here

  private TabCharacterCheck check = new TabCharacterCheck();

  @Test
  public void test() {
    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/TabCharacter.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().withMessage("Replace all tab characters in this file by sequences of white-spaces.")
        .noMore();
  }
View Full Code Here

        .noMore();
  }

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

  @Rule
  public CheckMessagesVerifierRule checkMessagesVerifier = new CheckMessagesVerifierRule();

  @Test
  public void test() {
    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/magicNumber.cc"), new MagicNumberCheck());

    checkMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(13).withMessage("Extract this magic number '0.85' into a constant, variable declaration or an enum.");
  }
View Full Code Here

  @Test
  public void custom() {
    MagicNumberCheck check = new MagicNumberCheck();
    check.exceptions = "0.85 , 1,,";

    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/magicNumber.cc"), check);

    checkMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(14)
        .next().atLine(17)
        .next().atLine(18);
  }
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.