Méthode exécutée pour lancer l'audit. @throws IOException e @throws XMLStreamException e
()
| 468 | * @throws XMLStreamException e |
| 469 | */ |
| 470 | public void run() throws IOException, XMLStreamException { |
| 471 | final long start = System.currentTimeMillis(); |
| 472 | try { |
| 473 | totalSize = 0; |
| 474 | progressSize = 0; |
| 475 | lastPercentOfProgress = -1; |
| 476 | for (final File file : parameters.getDirectories()) { |
| 477 | if (isInterrupted()) { |
| 478 | break; |
| 479 | } |
| 480 | if (DcdHelper.isJarOrWarFile(file)) { |
| 481 | // décompression du fichier jar ou war |
| 482 | |
| 483 | // TODO Si le JRE utilisé est en v7, on pourrait peut-être éviter de décompresser les jars |
| 484 | // en utilisant un In-memory filesystem (shrinkwrap nio2 par exemple), |
| 485 | // http://exitcondition.alrubinger.com/2012/08/17/shrinkwrap-nio2/ |
| 486 | // final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "myArchive.jar"); |
| 487 | // final FileSystem fileSystem = ShrinkWrapFileSystems.newFileSystem(archive); |
| 488 | |
| 489 | log("Uncompressing " + file.getPath() + " ..."); |
| 490 | final File tmpDirectory = DcdHelper.unzipIntoTempDirectory(file); |
| 491 | totalSize += getProgressListener() != null |
| 492 | ? DcdHelper.getClassTotalSize(tmpDirectory, true) |
| 493 | : 0; |
| 494 | tmpDirectoriesByJarOrWar.put(file, tmpDirectory); |
| 495 | } else { |
| 496 | totalSize += getProgressListener() != null |
| 497 | ? DcdHelper.getClassTotalSize(file, true) |
| 498 | : 0; |
| 499 | } |
| 500 | } |
| 501 | // les classes étant analysées à chaque étape (2 fois si mode public ou private), |
| 502 | // hors filtres que l'on ignore et classes internes analysées plusieurs fois si local également, |
| 503 | // on multiplie totalSize par les étapes |
| 504 | totalSize *= parameters.getSizeMultiplier(); |
| 505 | |
| 506 | // c'est parti |
| 507 | launchStepAnalyses(); |
| 508 | } finally { |
| 509 | if (isInterrupted()) { |
| 510 | log("Interrupted"); |
| 511 | } |
| 512 | // après l'analyse on supprime les données inutiles |
| 513 | // pour économiser la mémoire même s'il y a une exception |
| 514 | result.clear(); |
| 515 | |
| 516 | // on supprime les répertoires temporaires |
| 517 | if (!tmpDirectoriesByJarOrWar.isEmpty()) { |
| 518 | log("Deleting temporary directories"); |
| 519 | for (final File tmpDirectory : tmpDirectoriesByJarOrWar.values()) { |
| 520 | DcdHelper.rmdir(tmpDirectory); |
| 521 | } |
| 522 | tmpDirectoriesByJarOrWar.clear(); |
| 523 | } |
| 524 | |
| 525 | // et on termine le rapport (résumé et fermeture flux xml) |
| 526 | final long end = System.currentTimeMillis(); |
| 527 | report.close(end - start, suspectCount, analyzedClassCount, |
no test coverage detected