use of com.synopsys.integration.detectable.detectable.util.DependencyHistory in project synopsys-detect by blackducksoftware.
the class GradleReportTransformer method addConfigurationToGraph.
private void addConfigurationToGraph(MutableDependencyGraph graph, GradleConfiguration configuration) {
DependencyHistory history = new DependencyHistory();
TreeNodeSkipper treeNodeSkipper = new TreeNodeSkipper();
for (GradleTreeNode currentNode : configuration.getChildren()) {
if (treeNodeSkipper.shouldSkip(currentNode)) {
continue;
}
if (currentNode.getNodeType() == GradleTreeNode.NodeType.GAV) {
history.clearDependenciesDeeperThan(currentNode.getLevel());
Optional<GradleGav> currentNodeGav = currentNode.getGav();
if (currentNodeGav.isPresent()) {
addGavToGraph(currentNodeGav.get(), history, graph);
} else {
// We know this is a GradleTreeNode.NodeType.GAV
// So if its missing data, something is probably wrong.
logger.debug("Missing expected GAV from known NodeType. {}", currentNode);
}
} else {
treeNodeSkipper.skipUntilLineLevel(currentNode.getLevel());
}
}
}
use of com.synopsys.integration.detectable.detectable.util.DependencyHistory in project synopsys-detect by blackducksoftware.
the class PubDepsParser method parseLines.
private void parseLines(List<String> lines, Map<String, String> resolvedVersions, DependencyGraph dependencyGraph) {
DependencyHistory dependencyHistory = new DependencyHistory();
for (String line : lines) {
int depthOfLine = calculateDepth(line);
if (depthOfLine == 0) {
// non-graph line
continue;
}
int dependencyDepth = depthOfLine - 1;
dependencyHistory.clearDependenciesDeeperThan(dependencyDepth);
String nameOfDependency = parseNameFromlLine(line);
Dependency dependency = createDependency(nameOfDependency, resolvedVersions);
if (dependencyHistory.isEmpty()) {
dependencyGraph.addChildToRoot(dependency);
} else {
dependencyGraph.addChildWithParent(dependency, dependencyHistory.getLastDependency());
}
dependencyHistory.add(dependency);
}
}
use of com.synopsys.integration.detectable.detectable.util.DependencyHistory in project synopsys-detect by blackducksoftware.
the class GradleReportTransformer method addConfigurationToGraph.
private void addConfigurationToGraph(DependencyGraph graph, GradleConfiguration configuration) {
DependencyHistory history = new DependencyHistory();
TreeNodeSkipper treeNodeSkipper = new TreeNodeSkipper();
for (GradleTreeNode currentNode : configuration.getChildren()) {
if (treeNodeSkipper.shouldSkip(currentNode)) {
continue;
}
if (currentNode.getNodeType() == GradleTreeNode.NodeType.GAV) {
history.clearDependenciesDeeperThan(currentNode.getLevel());
Optional<GradleGav> currentNodeGav = currentNode.getGav();
if (currentNodeGav.isPresent()) {
addGavToGraph(currentNodeGav.get(), history, graph);
} else {
// We know this is a GradleTreeNode.NodeType.GAV
// So if its missing data, something is probably wrong.
logger.debug("Missing expected GAV from known NodeType. {}", currentNode);
}
} else {
treeNodeSkipper.skipUntilLineLevel(currentNode.getLevel());
}
}
}
use of com.synopsys.integration.detectable.detectable.util.DependencyHistory in project synopsys-detect by blackducksoftware.
the class Rebar3TreeParser method parseRebarTreeOutput.
public RebarParseResult parseRebarTreeOutput(List<String> dependencyTreeOutput) {
DependencyGraph graph = new BasicDependencyGraph();
DependencyHistory history = new DependencyHistory();
Dependency project = null;
for (String line : dependencyTreeOutput) {
if (!line.contains(HORIZONTAL_SEPARATOR_CHARACTER)) {
continue;
}
Dependency currentDependency = createDependencyFromLine(line);
int lineLevel = getDependencyLevelFromLine(line);
try {
history.clearDependenciesDeeperThan(lineLevel);
} catch (IllegalStateException e) {
logger.warn(String.format("Problem parsing line '%s': %s", line, e.getMessage()));
}
if (history.isEmpty() && isProject(line)) {
project = currentDependency;
} else if (history.getLastDependency().equals(project)) {
graph.addChildToRoot(currentDependency);
} else if (history.isEmpty()) {
graph.addChildToRoot(currentDependency);
} else {
graph.addChildWithParents(currentDependency, history.getLastDependency());
}
history.add(currentDependency);
}
if (project == null) {
CodeLocation codeLocation = new CodeLocation(graph);
return new RebarParseResult(codeLocation);
} else {
CodeLocation codeLocation = new CodeLocation(graph, project.getExternalId());
return new RebarParseResult(new NameVersion(project.getName(), project.getVersion()), codeLocation);
}
}
use of com.synopsys.integration.detectable.detectable.util.DependencyHistory in project synopsys-detect by blackducksoftware.
the class PipInspectorTreeParser method parse.
public Optional<NameVersionCodeLocation> parse(List<String> pipInspectorOutputAsList, String sourcePath) {
NameVersionCodeLocation parseResult = null;
DependencyGraph graph = new BasicDependencyGraph();
DependencyHistory history = new DependencyHistory();
Dependency project = null;
int unResolvedPackageCount = 0;
for (String line : pipInspectorOutputAsList) {
String trimmedLine = StringUtils.trimToEmpty(line);
if (StringUtils.isEmpty(trimmedLine) || !trimmedLine.contains(SEPARATOR) || trimmedLine.startsWith(UNKNOWN_REQUIREMENTS_PREFIX) || trimmedLine.startsWith(UNPARSEABLE_REQUIREMENTS_PREFIX) || trimmedLine.startsWith(UNKNOWN_PACKAGE_PREFIX)) {
boolean wasUnresolved = parseErrorsFromLine(trimmedLine);
if (wasUnresolved) {
unResolvedPackageCount++;
}
continue;
}
Dependency currentDependency = parseDependencyFromLine(trimmedLine, sourcePath);
adjustForIndentLevel(history, line);
project = addDependencyToGraph(graph, history, project, currentDependency);
history.add(currentDependency);
}
adviseIfUnresolvedPackages(unResolvedPackageCount);
if (project != null) {
CodeLocation codeLocation = new CodeLocation(graph, project.getExternalId());
parseResult = new NameVersionCodeLocation(project.getName(), project.getVersion(), codeLocation);
}
return Optional.ofNullable(parseResult);
}
Aggregations