use of com.synopsys.integration.detectable.detectables.go.gomod.model.GoGraphRelationship in project synopsys-detect by blackducksoftware.
the class GoModGraphGenerator method addModuleToGraph.
private void addModuleToGraph(String moduleName, @Nullable Dependency parent, MutableDependencyGraph graph, GoRelationshipManager goRelationshipManager, GoModDependencyManager goModDependencyManager) {
if (goRelationshipManager.isNotUsedByMainModule(moduleName)) {
logger.debug("Excluding module '{}' because it is not used by the main module.", moduleName);
return;
}
Dependency dependency = goModDependencyManager.getDependencyForModule(moduleName);
if (parent != null) {
graph.addChildWithParent(dependency, parent);
} else {
graph.addChildToRoot(dependency);
}
if (!fullyGraphedModules.contains(moduleName) && goRelationshipManager.hasRelationshipsFor(moduleName)) {
fullyGraphedModules.add(moduleName);
List<GoGraphRelationship> projectRelationships = goRelationshipManager.getRelationshipsFor(moduleName);
for (GoGraphRelationship projectRelationship : projectRelationships) {
addModuleToGraph(projectRelationship.getChild().getName(), dependency, graph, goRelationshipManager, goModDependencyManager);
}
}
}
use of com.synopsys.integration.detectable.detectables.go.gomod.model.GoGraphRelationship in project synopsys-detect by blackducksoftware.
the class GoModGraphGenerator method addModuleToGraph.
private void addModuleToGraph(String moduleName, @Nullable Dependency parent, DependencyGraph graph, GoRelationshipManager goRelationshipManager, GoModDependencyManager goModDependencyManager) {
if (goRelationshipManager.isNotUsedByMainModule(moduleName)) {
logger.debug("Excluding module '{}' because it is not used by the main module.", moduleName);
return;
}
Dependency dependency = goModDependencyManager.getDependencyForModule(moduleName);
if (parent != null) {
graph.addChildWithParent(dependency, parent);
} else {
graph.addChildToRoot(dependency);
}
if (!fullyGraphedModules.contains(moduleName) && goRelationshipManager.hasRelationshipsFor(moduleName)) {
fullyGraphedModules.add(moduleName);
List<GoGraphRelationship> projectRelationships = goRelationshipManager.getRelationshipsFor(moduleName);
for (GoGraphRelationship projectRelationship : projectRelationships) {
addModuleToGraph(projectRelationship.getChild().getName(), dependency, graph, goRelationshipManager, goModDependencyManager);
}
}
}
use of com.synopsys.integration.detectable.detectables.go.gomod.model.GoGraphRelationship in project synopsys-detect by blackducksoftware.
the class GoModCliExtractor method extract.
public Extraction extract(File directory, ExecutableTarget goExe) throws ExecutableFailedException, JsonSyntaxException, DetectableException {
List<GoListModule> goListModules = listModules(directory, goExe);
List<GoListAllData> goListAllModules = listAllModules(directory, goExe);
List<GoGraphRelationship> goGraphRelationships = listGraphRelationships(directory, goExe);
Set<String> excludedModules = listExcludedModules(directory, goExe);
GoRelationshipManager goRelationshipManager = new GoRelationshipManager(goGraphRelationships, excludedModules);
GoModDependencyManager goModDependencyManager = new GoModDependencyManager(goListAllModules, externalIdFactory);
List<CodeLocation> codeLocations = goListModules.stream().map(goListModule -> goModGraphGenerator.generateGraph(goListModule, goRelationshipManager, goModDependencyManager)).collect(Collectors.toList());
// No project info - hoping git can help with that.
return new Extraction.Builder().success(codeLocations).build();
}
use of com.synopsys.integration.detectable.detectables.go.gomod.model.GoGraphRelationship in project synopsys-detect by blackducksoftware.
the class GoGraphParser method parseLine.
private Optional<GoGraphRelationship> parseLine(String line) {
String[] parts = line.split(" ");
if (parts.length != 2) {
logger.warn("Unknown graph line format: {}", line);
return Optional.empty();
}
NameVersion parent = extractNameVersion(parts[0]);
NameVersion child = extractNameVersion(parts[1]);
return Optional.of(new GoGraphRelationship(parent, child));
}
use of com.synopsys.integration.detectable.detectables.go.gomod.model.GoGraphRelationship in project synopsys-detect by blackducksoftware.
the class GoRelationshipManagerTest method init.
@BeforeAll
static void init() {
List<GoGraphRelationship> goGraphRelationships = Arrays.asList(new GoGraphRelationship(parent, child), new GoGraphRelationship(parent, child2), new GoGraphRelationship(child, grandchild));
Set<String> excludedModules = new HashSet<>();
excludedModules.add(child2.getName());
goRelationshipManager = new GoRelationshipManager(goGraphRelationships, excludedModules);
}
Aggregations