@@ -220,7 +220,8 @@ def export(self, export_settings: types.ConfigSettings) -> types.ObjectJsonRepr:
220220 :return: The branch new code period definition
221221 :rtype: str
222222 """
223- from sonar import issues
223+ from sonar .issues import count as issue_count
224+ from sonar .hotspots import count as hotspot_count
224225
225226 log .debug ("Exporting %s" , str (self ))
226227 data = {settings .NEW_CODE_PERIOD : self .new_code ()}
@@ -243,16 +244,26 @@ def export(self, export_settings: types.ConfigSettings) -> types.ObjectJsonRepr:
243244 if export_settings .get ("MODE" , "" ) == "MIGRATION" :
244245 tpissues = self .count_third_party_issues ()
245246 issue_data = {"thirdParty" : tpissues if len (tpissues ) > 0 else 0 }
247+ proj_key = self .concerned_object .key
246248 if self .endpoint .version () >= (10 , 0 , 0 ):
247- issue_data ["falsePositives" ] = issues .count (
248- self .endpoint , components = self .concerned_object .key , branch = self .name , issueStatuses = "FALSE_POSITIVE"
249- )
250- issue_data ["accepted" ] = issues .count (self .endpoint , components = self .concerned_object .key , branch = self .name , issueStatuses = "ACCEPTED" )
249+ params = {"components" : proj_key , "branch" : self .name }
250+ data ["issues" ] = {
251+ "falsePositives" : issue_count (self .endpoint , issueStatuses = "FALSE_POSITIVE" , ** params ),
252+ "accepted" : issue_count (self .endpoint , issueStatuses = "ACCEPTED" , ** params ),
253+ }
254+ params = {"project" : proj_key , "branch" : self .name }
251255 else :
252- issue_data ["falsePositives" ] = issues .count (
253- self .endpoint , componentKeys = self .concerned_object .key , branch = self .name , resolutions = "FALSE-POSITIVE"
254- )
255- issue_data ["wontFix" ] = issues .count (self .endpoint , componentKeys = self .concerned_object .key , branch = self .name , resolutions = "WONTFIX" )
256+ params = {"componentKeys" : proj_key , "branch" : self .name }
257+ data ["issues" ] = {
258+ "falsePositives" : issue_count (self .endpoint , resolutions = "FALSE-POSITIVE" , ** params ),
259+ "wontFix" : issue_count (self .endpoint , resolutions = "WONTFIX" , ** params ),
260+ }
261+ params = {"projectKey" : proj_key , "branch" : self .name }
262+ data ["hotspots" ] = {
263+ "acknowledged" : hotspot_count (self .endpoint , resolution = "ACKNOWLEDGED" , ** params ),
264+ "safe" : hotspot_count (self .endpoint , resolution = "SAFE" , ** params ),
265+ "fixed" : hotspot_count (self .endpoint , resolution = "FIXED" , ** params ),
266+ }
256267 data ["issues" ] = issue_data
257268 log .debug ("%s has these notable issues %s" , str (self ), str (data ["issues" ]))
258269 data = util .remove_nones (data )
0 commit comments