Пример #1
0
 def _get_detector_arguments(version_compile: VersionCompile):
     return {
         key_detector_mode: DetectAllFindingsTask.__DETECTOR_MODE,
         key_target_src_paths: version_compile.original_sources_paths,
         key_target_classes_paths: version_compile.original_classes_paths,
         key_dependency_classpath: version_compile.get_full_classpath()
     }
 def _get_detector_arguments(version_compile: VersionCompile,
                             misuse_compile: MisuseCompile):
     return {
         key_detector_mode: DetectProvidedCorrectUsagesTask.__DETECTOR_MODE,
         key_training_src_path: misuse_compile.correct_usage_sources_path,
         key_training_classes_path:
         misuse_compile.correct_usage_classes_path,
         key_target_src_paths: [misuse_compile.misuse_source_path],
         key_target_classes_paths: [misuse_compile.misuse_classes_path],
         key_dependency_classpath: version_compile.get_full_classpath()
     }
Пример #3
0
    def run(self, misuse: Misuse, version_compile: VersionCompile):
        logger = logging.getLogger("task.compile_patterns")

        misuse_compile = misuse.get_misuse_compile(self.compile_base_path)

        if self.force_compile or version_compile.timestamp > misuse_compile.timestamp:
            misuse_compile.delete()

        if not exists(misuse_compile.misuse_source_path):
            logger.debug("Copying misuse sources...")
            for source_path in version_compile.original_sources_paths:
                CompileMisuseTask._copy_misuse_sources(source_path, misuse, misuse_compile.misuse_source_path)

        if not exists(misuse_compile.misuse_classes_path):
            logger.debug("Copying misuse classes...")
            for classes_path in version_compile.original_classes_paths:
                CompileMisuseTask._copy_misuse_classes(classes_path, misuse, misuse_compile.misuse_classes_path)

        try:
            if misuse_compile.needs_copy_sources() or misuse_compile.needs_compile():
                logger.info("Compiling correct usage for %s...", misuse)

            if misuse_compile.needs_copy_sources():
                logger.debug("Copying correct-usage sources...")
                copy_tree(misuse.correct_usage_path, misuse_compile.correct_usage_sources_path)

            if misuse_compile.needs_compile():
                logger.debug("Compiling correct usages...")
                CompileMisuseTask._compile_correct_usages(misuse_compile.correct_usage_sources_path,
                                                    misuse_compile.correct_usage_classes_path,
                                                    version_compile.get_full_classpath())
                misuse_compile.save(self.run_timestamp)
            elif misuse.correct_usages:
                logger.info("Correct usage already compiled.")
        except Exception:
            misuse_compile.delete()
            raise

        return misuse_compile