@@ -2,7 +2,7 @@ package com.codacy
22
33import com .codacy .configuration .parser .{CommandConfiguration , ConfigurationParsingApp }
44import com .codacy .di .Components
5- import com .codacy .model .configuration .{FinalConfig , ReportConfig }
5+ import com .codacy .model .configuration .{Configuration , FinalConfig , ReportConfig }
66import com .codacy .rules .ConfigurationRules
77import wvlet .airframe .log
88import wvlet .log .{LogSupport , Logger }
@@ -11,13 +11,16 @@ object CodacyCoverageReporter extends ConfigurationParsingApp with LogSupport {
1111 log.initNoColor
1212
1313 def run (commandConfig : CommandConfiguration ): Int = {
14- val noAvailableTokens = commandConfig.baseConfig.projectToken.isEmpty && commandConfig.baseConfig.apiToken.isEmpty
14+ val configRules = new ConfigurationRules (commandConfig, sys.env)
15+
16+ val noAvailableTokens =
17+ configRules.getProjectToken(commandConfig.baseConfig).isEmpty &&
18+ configRules.getApiToken(commandConfig.baseConfig).isEmpty
1519 if (commandConfig.baseConfig.skipValue && noAvailableTokens) {
1620 logger.info(" Skip reporting coverage" )
1721 0
1822 } else {
19- val result : Either [String , String ] = sendReport(commandConfig, sys.env)
20- result match {
23+ sendReport(configRules.validatedConfig) match {
2124 case Right (message) =>
2225 logger.info(message)
2326 0
@@ -28,10 +31,8 @@ object CodacyCoverageReporter extends ConfigurationParsingApp with LogSupport {
2831 }
2932 }
3033
31- private def sendReport (commandConfig : CommandConfiguration , envVars : Map [String , String ]) = {
32- val configRules = new ConfigurationRules (commandConfig, envVars)
33-
34- configRules.validatedConfig.flatMap { validatedConfig =>
34+ private def sendReport (validatedConfig : Either [String , Configuration ]) = {
35+ validatedConfig.flatMap { validatedConfig =>
3536 val components = new Components (validatedConfig)
3637
3738 if (validatedConfig.baseConfig.debug) {
0 commit comments