mirror of
https://github.com/ysoftdevs/odc-analyzer.git
synced 2026-03-20 16:24:32 +01:00
Added notice when there are some failed projects. This required some refactorings and fixes, that are also included in this commit.
This commit is contained in:
@@ -2,22 +2,27 @@ package com.ysoft.odc.statistics
|
||||
|
||||
import controllers.ReportInfo
|
||||
|
||||
final class FailedProjects(val failedProjectsSet: Set[String]){
|
||||
final class FailedProjects(val failedProjectsSet: Set[ReportInfo]){
|
||||
|
||||
val failedProjectIdsSet = failedProjectsSet.map(_.projectId)
|
||||
|
||||
def nonEmpty: Boolean = failedProjectsSet.nonEmpty
|
||||
|
||||
def isFailed(projectFullId: String): Boolean = {
|
||||
val projectBareId = projectFullId.takeWhile(_ != '/')
|
||||
failedProjectsSet contains projectBareId
|
||||
failedProjectIdsSet contains projectBareId
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
object FailedProjects {
|
||||
def combineFails(failedReportDownloads: Map[String, Throwable], parsingFailures: Map[ReportInfo, Throwable]): FailedProjects = {
|
||||
def combineFails(failedReportDownloads: Map[ReportInfo, Throwable], parsingFailures: Map[ReportInfo, Throwable]): FailedProjects = {
|
||||
/*
|
||||
Fail can happen at multiple places:
|
||||
1. Build cannot be downloaded (auth error, connection error, …) or is failed (failedReportDownloads)
|
||||
2. Build is successful and can be downloaded, but it cannot be parsed (parsingFailures)
|
||||
*/
|
||||
val failedProjectsSet = failedReportDownloads.keySet ++ parsingFailures.keySet.map(_.projectId)
|
||||
val failedProjectsSet = failedReportDownloads.keySet ++ parsingFailures.keySet
|
||||
new FailedProjects(failedProjectsSet)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,9 @@ case class LibDepStatistics(libraries: Set[(Int, Library)], dependencies: Set[Gr
|
||||
|
||||
object LibDepStatistics{
|
||||
private def computeWeaknessesFrequency(vulnerabilities: Set[Vulnerability]) = vulnerabilities.toSeq.map(_.cweOption).groupBy(identity).mapValues(_.size).map(identity).withDefaultValue(0)
|
||||
def apply(libraries: Set[(Int, Library)], dependencies: Set[GroupedDependency], failedReportDownloads: Map[String, Throwable], parsedReports: Result): LibDepStatistics = LibDepStatistics(
|
||||
def apply(libraries: Set[(Int, Library)], dependencies: Set[GroupedDependency], parsedReports: Result): LibDepStatistics = LibDepStatistics(
|
||||
libraries = libraries,
|
||||
dependencies = dependencies,
|
||||
failedProjects = FailedProjects.combineFails(
|
||||
failedReportDownloads = failedReportDownloads,
|
||||
parsingFailures = parsedReports.failedAnalysises
|
||||
)
|
||||
failedProjects = parsedReports.failedProjects
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user