Package org.sonar.squid.api

Examples of org.sonar.squid.api.SourceFile


        .noMore();
  }

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


        .noMore();
  }

  @Test
  public void test3() {
    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 detected() {
    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/FixmeTagPresenceCheck.cc"), new FixmeTagPresenceCheck());
    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

  private void save(Collection<SourceCode> squidSourceFiles) {
    int violationsCount = 0;
    DependencyAnalyzer dependencyAnalyzer = new DependencyAnalyzer(perspectives, project, context, annotationCheckFactory);
    for (SourceCode squidSourceFile : squidSourceFiles) {
      SourceFile squidFile = (SourceFile) squidSourceFile;
      File ioFile = new File(squidFile.getKey());

      org.sonar.api.resources.File sonarFile = org.sonar.api.resources.File.fromIOFile(ioFile, project);

      saveMeasures(sonarFile, squidFile);
      saveFilesComplexityDistribution(sonarFile, squidFile);
View Full Code Here

      cxxConf.setDefines(Arrays.asList(lines));
    }
    cxxConf.setIncludeDirectories(conf.getStringArray(CxxPlugin.INCLUDE_DIRECTORIES_KEY));

    for (File file : files) {
      @SuppressWarnings("unchecked")
      SourceFile source = CxxAstScanner.scanSingleFileConfig(file, cxxConf);
      if(source.hasChildren()) {
        for (SourceCode child : source.getChildren()) {
          if (child instanceof SourceClass) {
            classDeclTable.put(child.getName(), file.getPath());
          }
          else if(child instanceof SourceFunction){
            String clsName = matchClassName(child.getKey());
View Full Code Here

  @Test
  public void check() {
    FileComplexityCheck check = new FileComplexityCheck();
    check.setMax(1);

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

  private HardcodedAccountCheck check = new HardcodedAccountCheck();

  @Test
  public void detected() {
    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/HardcodedAccount.cc"), check);
     CheckMessagesVerifier.verify(file.getCheckMessages())
      .next().atLine(6).withMessage("Do not hard code sensitive data in programs.")
      .next().atLine(8)
      .next().atLine(9);
  }
View Full Code Here

  @Rule
  public CheckMessagesVerifierRule checkMessagesVerifier = new CheckMessagesVerifierRule();

  @Test
  public void detected() {
    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/ReservedNamesCheck.cc"), new ReservedNamesCheck());
    checkMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(3).withMessage("Reserved name used for macro (keyword or alternative token redefined)")
        .next().atLine(4)
        .next().atLine(5)
        .next().atLine(6)
        .next().atLine(14).withMessage("Reserved name used for macro (begins with underscore followed by a capital letter)")
View Full Code Here

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

    SourceFile file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/FileHeaderCheck/Class1.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .noMore();

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

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

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

    file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/FileHeaderCheck/Class2.cc"), 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 = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/FileHeaderCheck/Class2.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .noMore();

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

    file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/FileHeaderCheck/Class2.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .noMore();

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

    file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/FileHeaderCheck/Class2.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .noMore();

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

    file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/FileHeaderCheck/Class2.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .noMore();

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

    file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/FileHeaderCheck/Class2.cc"), 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 = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/FileHeaderCheck/Class2.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .next().atLine(null);

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

    file = CxxAstScanner.scanSingleFile(new File("src/test/resources/checks/FileHeaderCheck/Class3.cc"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .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/CollapsibleIfCandidateCheck.cc"), new CollapsibleIfCandidateCheck());
    checkMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(16).withMessage("Merge this if statement with the enclosing one.")
        .next().atLine(49)
        .next().atLine(54)
        .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.