使用 pylint 检测python代码质量(sonar-scanner调用pylint,然后数据交给sonar服务器)

来源:互联网 发布:怎么申请淘宝卖家账号 编辑:程序博客网 时间:2024/06/05 18:11

python 代码质量检查

直接使用 sonar-scanner 调用 pylint插件扫描生成 质量分析文件

pylint 官网地址:https://www.pylint.org/

安装 sonar-scanner:

在jenkins master  系统配置 里面配置 安装的插件(jdk,maven等)路径,然后每一台slave 都要这样的路径安装:

注意:每一台slave 机器在对应目录要安装scanner,安装jdk等等!!!

JDK
Clover
Git
 Git installations
Git
  Name  
  Path to Git executable  
         
    
Gradle
Sonar Runner
Ant

   

Maven
Maven项目配置

        Local Maven Repository


sonar-scanner路径:

 Sonar Runner 安装

Sonar Runner
Name  
  SONAR_RUNNER_HOME  
  


然后再安装pylint  假如 pylint安装路径是 usr/bin/

然后再配置sonar-scanner.properties 文件  如下:

sonar.sources=.# Encoding of the source code. Default is default system encodingsonar.sourceEncoding=UTF-8# Languagesonar.language=pysonar.python.pylint=/usr/bin/pylintsonar.python.pylint_config=.pylintrcsonar.python.pylint.reportPath=./pylint-report.txt