mirror of
https://github.com/ysoftdevs/odc-analyzer.git
synced 2026-03-28 12:02:00 +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 ProjectSelectorPattern = """^project:(.*)$""".r
|
||||||
private val TeamSelectorPattern = """^team:(.*)$""".r
|
private val TeamSelectorPattern = """^team:(.*)$""".r
|
||||||
|
|
||||||
private def parseFilter(filter: String): Filter = filter match {
|
private def parseFilter(filter: String): Filter = {
|
||||||
case ProjectSelectorPattern(project) => ProjectFilter(projectsReportInfo.reportIdToReportInfo(project))
|
def mapToFilter[T](dataOption: Option[T], filterCreator: T => Filter): Filter =
|
||||||
case TeamSelectorPattern(team) => TeamFilter(projects.teamById(team))
|
dataOption.fold[Filter](BadFilter(filter))(filterCreator)
|
||||||
case other => BadFilter(other)
|
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] = {
|
def selection(selectorOption: Option[String]): Option[ResultWithSelection] = {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ class Projects (
|
|||||||
)
|
)
|
||||||
|
|
||||||
def teamById(id: String): Team = teamsById(id)
|
def teamById(id: String): Team = teamsById(id)
|
||||||
|
def getTeamById(id: String): Option[Team] = teamsById.get(id)
|
||||||
|
|
||||||
def teamSet: Set[Team] = teamsById.values.toSet
|
def teamSet: Set[Team] = teamsById.values.toSet
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user