mirror of
https://github.com/ysoftdevs/odc-analyzer.git
synced 2026-01-16 16:47:13 +01:00
Report proper error messages when filter is wrong project or wrong team
This commit is contained in:
@@ -139,10 +139,14 @@ object DependencyCheckReportsParser{
|
||||
private val ProjectSelectorPattern = """^project:(.*)$""".r
|
||||
private val TeamSelectorPattern = """^team:(.*)$""".r
|
||||
|
||||
private def parseFilter(filter: String): Filter = filter match {
|
||||
case ProjectSelectorPattern(project) => ProjectFilter(projectsReportInfo.reportIdToReportInfo(project))
|
||||
case TeamSelectorPattern(team) => TeamFilter(projects.teamById(team))
|
||||
case other => BadFilter(other)
|
||||
private def parseFilter(filter: String): Filter = {
|
||||
def mapToFilter[T](dataOption: Option[T], filterCreator: T => Filter): Filter =
|
||||
dataOption.fold[Filter](BadFilter(filter))(filterCreator)
|
||||
filter match {
|
||||
case ProjectSelectorPattern(project) => mapToFilter(projectsReportInfo.reportIdToReportInfo.get(project), ProjectFilter)
|
||||
case TeamSelectorPattern(team) => mapToFilter(projects.getTeamById(team), TeamFilter)
|
||||
case other => BadFilter(other)
|
||||
}
|
||||
}
|
||||
|
||||
def selection(selectorOption: Option[String]): Option[ResultWithSelection] = {
|
||||
|
||||
@@ -21,6 +21,7 @@ class Projects (
|
||||
)
|
||||
|
||||
def teamById(id: String): Team = teamsById(id)
|
||||
def getTeamById(id: String): Option[Team] = teamsById.get(id)
|
||||
|
||||
def teamSet: Set[Team] = teamsById.values.toSet
|
||||
|
||||
|
||||
Reference in New Issue
Block a user