Ejemplo n.º 1
0
  /** {@inheritDoc} */
  @Override
  public BuildResult perform(final AbstractBuild<?, ?> build, final PluginLogger logger)
      throws InterruptedException, IOException {
    File logFile = build.getLogFile();

    Set<String> validParsers = Sets.newHashSet(getParserNames());
    ParserResult project;
    if (StringUtils.isNotBlank(getPattern())) {
      logger.log("Parsing warnings in files: " + getPattern());
      FilesParser parser =
          new FilesParser(
              logger,
              getPattern(),
              new FileWarningsParser(
                  validParsers, getDefaultEncoding(), getIncludePattern(), getExcludePattern()),
              isMavenBuild(build),
              isAntBuild(build));
      project = build.getWorkspace().act(parser);
    } else {
      project = new ParserResult(build.getWorkspace());
    }

    if (!ignoreConsole || StringUtils.isBlank(getPattern())) {
      logger.log("Parsing warnings in console log...");
      ParserRegistry registry =
          new ParserRegistry(
              ParserRegistry.getParsers(validParsers),
              getDefaultEncoding(),
              getIncludePattern(),
              getExcludePattern());
      Collection<FileAnnotation> warnings = registry.parse(logFile);
      if (!build.getWorkspace().isRemote()) {
        String workspace = build.getWorkspace().getRemote();
        ModuleDetector detector = new ModuleDetector(new File(workspace));
        for (FileAnnotation annotation : warnings) {
          String module = detector.guessModuleName(annotation.getFileName());
          annotation.setModuleName(module);
        }
      }

      project.addAnnotations(warnings);
    }
    project = build.getWorkspace().act(new AnnotationsClassifier(project, getDefaultEncoding()));
    for (FileAnnotation annotation : project.getAnnotations()) {
      annotation.setPathName(build.getWorkspace().getRemote());
    }

    WarningsResult result = new WarningsResult(build, getDefaultEncoding(), project);
    build.getActions().add(new WarningsResultAction(build, this, result));

    return result;
  }
Ejemplo n.º 2
0
  /**
   * Runs all parsers and logs the results to the console.
   *
   * @throws IOException Signals that an I/O exception has occurred.
   */
  @Test
  public void testAllParsersOnOneFile() throws IOException {
    for (ParserDescription parser : ParserRegistry.getAvailableParsers()) {
      List<AbstractWarningsParser> parsers = ParserRegistry.getParsers(parser.getGroup());
      if (!(parsers.get(0) instanceof ViolationsAdapter)) {
        ParserRegistry parserRegistry = createRegistry(parsers);

        long start = System.currentTimeMillis();
        parserRegistry.parse(new File(""));
        long end = System.currentTimeMillis();
        System.out.println(parser.getName() + ": " + (end - start) + "ms"); // NOCHECKSTYLE NOPMD
      }
    }
  }
Ejemplo n.º 3
0
 /** {@inheritDoc} */
 public String getDisplayName() {
   if (group == null) {
     return Messages.Warnings_ProjectAction_Name();
   } else {
     return ParserRegistry.getParser(group).getLinkName().toString();
   }
 }
Ejemplo n.º 4
0
 /**
  * Returns the names of the configured parsers of this publisher.
  *
  * @return the parser names
  */
 public List<String> getParserNames() {
   return ParserRegistry.filterExistingParserNames(parserNames);
 }
Ejemplo n.º 5
0
 @Override
 protected String getSerializationFileName() {
   FileChecker fileChecker = new FileChecker(getOwner().getRootDir());
   return getFileName(fileChecker, ParserRegistry.getUrl(group));
 }
Ejemplo n.º 6
0
 @Override
 public String getSummary() {
   return ParserRegistry.getParser(group).getLinkName()
       + ": "
       + createDefaultSummary(getUrl(), getNumberOfAnnotations(), getNumberOfModules());
 }
Ejemplo n.º 7
0
 @Override
 public String getHeader() {
   return ParserRegistry.getParser(group).getLinkName().toString();
 }