def report(self): """Execute the SonarQube Scanner. Returns according to the successful of the analysis: * ``GNAThub.EXEC_SUCCESS``: on successful execution and analysis * ``GNAThub.EXEC_FAILURE``: on any error """ return GNAThub.EXEC_SUCCESS if GNAThub.Run( self.name, self.__cmd_line(), workdir=SonarQube.workdir() ).status == 0 else GNAThub.EXEC_FAILURE
def report(self): """Execute the SonarQube Scanner. Returns according to the successful of the analysis: * ``GNAThub.EXEC_SUCCESS``: on successful execution and analysis * ``GNAThub.EXEC_FAILURE``: on any error """ return GNAThub.EXEC_SUCCESS if GNAThub.Run( self.name, self.__cmd_line(), workdir=SonarQube.workdir()).status == 0 else GNAThub.EXEC_FAILURE
def __cmd_line(): """Return command line for sonar scanner execution. :return: the SonarQube Scanner command line :rtype: collections.Iterable[str] """ # Enable verbose and debugging output with -e and -X. This is handy for # debugging in case of issue in the SonarScanner step. sonarqube_conf = SonarQube.configuration() if platform.system() == 'Windows': if (" " in sonarqube_conf): sonarqube_conf = "/".join(sonarqube_conf.split("\\")) sonarqube_conf = sonarqube_conf.replace(' ', "\ ") sonarqube_conf = '\"' + SonarQube.configuration() + '\"' cmdline = [ 'sonar-scanner', '-e', '-X', '-Dproject.settings={}'.format(sonarqube_conf) ] return cmdline
def run(self): """Generate SonarQube Scanner configuration file.""" self.info('generate %s' % SonarQube.CONFIGURATION) try: SonarScannerProperties(self.log).write(SonarQube.configuration()) except IOError as why: self.log.exception( 'SonarQube Scanner configuration generation failed') self.error(str(why)) return GNAThub.EXEC_FAILURE else: return GNAThub.EXEC_SUCCESS
def __cmd_line(): """Return command line for sonar scanner execution. :return: the SonarQube Scanner command line :rtype: collections.Iterable[str] """ # Enable verbose and debugging output with -e and -X. This is handy for # debugging in case of issue in the SonarScanner step. cmdline = [ 'sonar-scanner', '-e', '-X', '-Dproject.settings={}'.format(SonarQube.configuration()) ] if platform.system() == 'Windows': return ['cmd', '/c', ' '.join(cmdline)] return cmdline
def setup(self): super(SonarConfig, self).setup() SonarQube.make_workdir()
def setup(self): # Do not call the super method: we do not need a database session to be # opened. SonarQube.make_workdir()