@@ -60,19 +60,24 @@ case class LintCommand(inputDir: File, skipWarnings: Boolean, linters: List[Lint
60
60
val stubCommand = GenerateCommand (stubFile, stubFile)
61
61
val (_, schemas) = splitValidations(validatedJsons.map(_.extractSelfDescribingSchema))
62
62
val schemaVerValidation : Result = stubCommand.validateSchemaVersions(schemas)
63
- // strip GenerateCommand related parts off & prepare LintCommand failure messages
64
- val lintSchemaVerMessages : List [String ] = schemaVerValidation match {
65
- case Warnings (lst) => lst.map(w => " FAILURE" + w.stripPrefix(" Warning" ))
66
- case Errors (lst) => lst.map(e => " FAILURE" + e.stripPrefix(" Error" ).stripSuffix(" Use --force to switch off schema version check." ))
67
- case VersionSuccess (_) => List .empty[String ]
68
- }
69
- lintSchemaVerMessages.foreach(println)
70
63
71
64
val reports = jsons.map { file =>
72
65
val report = file.map(check)
73
66
flattenReport(report)
74
67
}
75
- reports.foldLeft(Total (0 , 0 , lintSchemaVerMessages.size))((acc, cur) => acc.add(cur)).exit()
68
+
69
+ // strip GenerateCommand related parts off & prepare LintCommand messages & create a Total per schema version check
70
+ schemaVerValidation match {
71
+ case Warnings (lst) =>
72
+ lst.map(w => " WARNING" + w.stripPrefix(" Warning" )).foreach(println)
73
+ reports.foldLeft(Total (0 , 0 , 0 , lst.size))((acc, cur) => acc.add(cur)).exit()
74
+ case Errors (lst) =>
75
+ lst.map(e => " FAILURE" +
76
+ e.stripPrefix(" Error" ).stripSuffix(" Use --force to switch off schema version check." )).foreach(println)
77
+ reports.foldLeft(Total (0 , 0 , lst.size, 0 ))((acc, cur) => acc.add(cur)).exit()
78
+ case VersionSuccess (_) =>
79
+ reports.foldLeft(Total (0 , 0 , 0 , 0 ))((acc, cur) => acc.add(cur)).exit()
80
+ }
76
81
}
77
82
78
83
/**
@@ -111,14 +116,15 @@ object LintCommand {
111
116
* @param successes number of successfully validated schemas
112
117
* @param failedSchemas number of schemas with errors
113
118
*/
114
- case class Total (successes : Int , failedSchemas : Int , totalFailures : Int ) {
119
+ case class Total (successes : Int , failedSchemas : Int , totalFailures : Int , totalWarnings : Int ) {
115
120
/**
116
121
* Exit from app with error status if invalid schemas were found
117
122
*/
118
123
def exit (): Unit = {
119
124
println(s " TOTAL: $successes Schemas were successfully validated " )
120
125
println(s " TOTAL: $failedSchemas invalid Schemas were encountered " )
121
126
println(s " TOTAL: $totalFailures errors were encountered " )
127
+ println(s " TOTAL: $totalWarnings warnings were encountered " )
122
128
123
129
if (failedSchemas + totalFailures > 0 ) sys.exit(1 )
124
130
else sys.exit(0 )
0 commit comments