Python 声纳无法获得派林测试结果
我正在尝试在sonar和jenkins工作中使用pylint和python插件。然而,即使我的pylint结果已创建并可在工作区中使用,sonar仍无法获取它 执行shell步骤:生成pylint报告文件 执行SonarQube扫描仪:扫描项目并发送到sonar服务器 这项工作成功了,数据被填充到声纳中,但我没有看到任何pylint数据。我尝试直接在工作区中使用作业使用的相同标志(加上已启用调试)手动运行sonar扫描仪,但我甚至没有看到它在查找pylint报告文件:Python 声纳无法获得派林测试结果,python,jenkins,sonarqube,pylint,sonarqube-scan,Python,Jenkins,Sonarqube,Pylint,Sonarqube Scan,我正在尝试在sonar和jenkins工作中使用pylint和python插件。然而,即使我的pylint结果已创建并可在工作区中使用,sonar仍无法获取它 执行shell步骤:生成pylint报告文件 执行SonarQube扫描仪:扫描项目并发送到sonar服务器 这项工作成功了,数据被填充到声纳中,但我没有看到任何pylint数据。我尝试直接在工作区中使用作业使用的相同标志(加上已启用调试)手动运行sonar扫描仪,但我甚至没有看到它在查找pylint报告文件: 09:08:42.040
09:08:42.040 INFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties
09:08:42.044 INFO: Project root configuration file: /var/lib/jenkins/workspace/redacted-sonar/sonar-project.properties
09:08:42.066 INFO: SonarQube Scanner 2.8
09:08:42.066 INFO: Java 1.8.0_121 Oracle Corporation (64-bit)
09:08:42.066 INFO: Linux 3.10.0-514.6.1.el7.x86_64 amd64
09:08:42.262 DEBUG: keyStore is :
09:08:42.262 DEBUG: keyStore type is : jks
09:08:42.262 DEBUG: keyStore provider is :
09:08:42.262 DEBUG: init keystore
09:08:42.263 DEBUG: init keymanager of type SunX509
09:08:42.332 INFO: User cache: /root/.sonar/cache
09:08:42.332 DEBUG: Extract sonar-scanner-api-batch in temp...
09:08:42.339 DEBUG: Get bootstrap index...
09:08:42.340 DEBUG: Download: http://redacted.com/batch_bootstrap/index
09:08:42.401 DEBUG: Get bootstrap completed
09:08:42.402 DEBUG: Create isolated classloader...
09:08:42.417 DEBUG: Start temp cleaning...
09:08:42.429 DEBUG: Temp cleaning done
09:08:42.429 DEBUG: Execution getVersion
09:08:42.433 DEBUG: Execution start
09:08:42.637 DEBUG: Publish global mode
09:08:42.741 INFO: Load global repositories
09:08:42.813 DEBUG: GET 200 http://redacted.com/batch/global | time=68ms
09:08:42.872 INFO: Load global repositories (done) | time=132ms
09:08:42.888 INFO: User cache: /root/.sonar/cache
09:08:43.094 INFO: Load plugins index
09:08:43.100 DEBUG: GET 200 http://redacted.com/deploy/plugins/index.txt | time=5ms
09:08:43.100 INFO: Load plugins index (done) | time=6ms
09:08:43.101 DEBUG: Load plugins
09:08:43.113 DEBUG: Load plugins (done) | time=12ms
09:08:43.123 DEBUG: API compatibility mode is enabled on plugin Git [scmgit] (built with API lower than 5.2)
09:08:43.201 DEBUG: Plugins:
09:08:43.201 DEBUG: * Python 1.7.0.1195 (python)
09:08:43.201 DEBUG: * CSS / SCSS / Less 3.1 (css)
09:08:43.201 DEBUG: * Web 2.5.0.476 (web)
09:08:43.201 DEBUG: * Git 1.2 (scmgit)
09:08:43.201 DEBUG: * JSON 2.2 (JSON)
09:08:43.201 DEBUG: * SonarJS 2.20.0.4207 (javascript)
09:08:43.219 DEBUG: Execution getVersion
09:08:43.219 INFO: SonarQube server 6.2
09:08:43.220 INFO: Default locale: "en_US", source code encoding: "UTF-8"
09:08:43.220 DEBUG: Work directory: /var/lib/jenkins/workspace/redacted-sonar/.sonar
09:08:43.220 DEBUG: Execution getVersion
09:08:43.221 DEBUG: Execution execute
09:08:43.491 INFO: Process project properties
09:08:43.493 DEBUG: Process project properties (done) | time=2ms
09:08:43.622 INFO: Load project repositories
09:08:43.640 DEBUG: GET 200 http://redacted.com/batch/project.protobuf?key=redacted%3Aredacted | time=17ms
09:08:43.707 INFO: Load project repositories (done) | time=85ms
09:08:43.775 DEBUG: Available languages:
09:08:43.775 DEBUG: * Python => "py"
09:08:43.775 DEBUG: * CSS => "css"
09:08:43.775 DEBUG: * SCSS => "scss"
09:08:43.775 DEBUG: * Less => "less"
09:08:43.775 DEBUG: * Web => "web"
09:08:43.775 DEBUG: * JSON => "json"
09:08:43.775 DEBUG: * JavaScript => "js"
09:08:43.779 INFO: Load quality profiles
09:08:43.799 DEBUG: GET 200 http://redacted.com/api/qualityprofiles/search.protobuf?projectKey=redacted%3Aredacted | time=20ms
09:08:43.804 INFO: Load quality profiles (done) | time=25ms
09:08:43.810 INFO: Load active rules
09:08:43.853 DEBUG: GET 200 http://redacted.com/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=css-sonarqube-way-71134&p=1&ps=500 | time=43ms
09:08:43.938 DEBUG: GET 200 http://redacted.com/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=js-sonar-way-27675&p=1&ps=500 | time=46ms
09:08:43.961 DEBUG: GET 200 http://redacted.com/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=json-sonarqube-way-96571&p=1&ps=500 | time=19ms
09:08:44.005 DEBUG: GET 200 http://redacted.com/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=less-sonarqube-way-34273&p=1&ps=500 | time=43ms
09:08:44.039 DEBUG: GET 200 http://redacted.com/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=py-sonar-way-66789&p=1&ps=500 | time=28ms
09:08:44.090 DEBUG: GET 200 http://redacted.com/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=scss-sonarqube-way-58162&p=1&ps=500 | time=49ms
09:08:44.114 DEBUG: GET 200 http://redacted.com/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=web-sonar-way-97604&p=1&ps=500 | time=20ms
09:08:44.125 INFO: Load active rules (done) | time=315ms
09:08:44.160 INFO: Publish mode
09:08:44.160 DEBUG: Start recursive analysis of project modules
09:08:44.161 INFO: ------------- Scan redacted
09:08:44.250 INFO: Language is forced to py
09:08:44.259 INFO: Load server rules
09:08:44.375 DEBUG: GET 200 http://redacted.com/api/rules/list.protobuf | time=116ms
09:08:44.384 INFO: Load server rules (done) | time=125ms
09:08:44.433 DEBUG: Initializers : GenericCoverageSensor
09:08:44.434 INFO: Initializer GenericCoverageSensor
09:08:44.434 INFO: Initializer GenericCoverageSensor (done) | time=0ms
09:08:44.434 INFO: Base dir: /var/lib/jenkins/workspace/redacted-sonar
09:08:44.434 INFO: Working dir: /var/lib/jenkins/workspace/redacted-sonar/.sonar
09:08:44.436 INFO: Source paths: .
09:08:44.436 INFO: Source encoding: UTF-8, default locale: en_US
09:08:44.436 INFO: Index files
09:08:44.439 INFO: Excluded sources:
09:08:44.439 INFO: **/flask/**
09:08:44.441 DEBUG: Declared extensions of language Python were converted to sonar.lang.patterns.py : **/*.py
09:08:44.441 DEBUG: Declared extensions of language CSS were converted to sonar.lang.patterns.css : **/*.css
09:08:44.441 DEBUG: Declared extensions of language SCSS were converted to sonar.lang.patterns.scss : **/*.scss
09:08:44.441 DEBUG: Declared extensions of language Less were converted to sonar.lang.patterns.less : **/*.less
09:08:44.441 DEBUG: Declared extensions of language Web were converted to sonar.lang.patterns.web : **/*.html,**/*.xhtml,**/*.rhtml,**/*.shtml
09:08:44.441 DEBUG: Declared extensions of language JSON were converted to sonar.lang.patterns.json : **/*.json
09:08:44.442 DEBUG: Declared extensions of language JavaScript were converted to sonar.lang.patterns.js : **/*.js
09:08:44.446 DEBUG: Language of file 'app/__init__.py' is detected to be 'py'
09:08:44.446 DEBUG: Language of file 'app/app.py' is detected to be 'py'
09:08:44.447 DEBUG: Language of file 'checks_queue_runner.py' is detected to be 'py'
09:08:44.457 DEBUG: Language of file 'clear_queue.py' is detected to be 'py'
09:08:44.457 DEBUG: Language of file 'config.py' is detected to be 'py'
09:08:44.459 DEBUG: Language of file 'delete_queue_runner.py' is detected to be 'py'
09:08:44.468 DEBUG: Language of file 'get_auth_token.py' is detected to be 'py'
09:08:44.470 DEBUG: Language of file 'osclient.py' is detected to be 'py'
09:08:44.471 DEBUG: Language of file 'queue_runner.py' is detected to be 'py'
09:08:44.477 DEBUG: Language of file 'run.py' is detected to be 'py'
09:08:44.478 DEBUG: Language of file 'tq.py' is detected to be 'py'
09:08:44.490 INFO: 11 files indexed
09:08:44.492 INFO: 0 files ignored because of inclusion/exclusion patterns
09:08:44.507 INFO: Quality profile for py: Sonar way
09:08:44.519 DEBUG: Code colorizer, supported languages:
09:08:45.813 DEBUG: 'Generic Coverage Report' skipped because one of the required properties is missing
09:08:45.813 DEBUG: 'Generic Test Executions Report' skipped because one of the required properties is missing
09:08:45.814 DEBUG: 'CSS Analyzer Sensor' skipped because there is no related file in current project
09:08:45.814 DEBUG: 'SCSS Analyzer Sensor' skipped because there is no related file in current project
09:08:45.815 DEBUG: 'Less Analyzer Sensor' skipped because there is no related file in current project
09:08:45.815 DEBUG: 'Web' skipped because there is no related file in current project
09:08:45.815 DEBUG: 'JSON Squid Sensor' skipped because there is no related file in current project
09:08:45.815 DEBUG: 'JavaScript Squid Sensor' skipped because there is no related file in current project
09:08:45.820 DEBUG: Sensors : Lines Sensor -> PythonXUnitSensor -> SCM Sensor -> Python Squid Sensor -> Embedded CSS Analyzer Sensor -> Zero Coverage Sensor -> Code Colorizer Sensor -> CPD Block Indexer
09:08:45.820 INFO: Sensor Lines Sensor
09:08:45.830 INFO: Sensor Lines Sensor (done) | time=10ms
09:08:45.830 INFO: Sensor PythonXUnitSensor
09:08:45.830 DEBUG: Using pattern 'xunit-reports/xunit-result-*.xml' to find reports
09:08:45.842 DEBUG: No report was found for sonar.python.xunit.reportPath using default pattern xunit-reports/xunit-result-*.xml
09:08:45.842 INFO: Sensor PythonXUnitSensor (done) | time=12ms
09:08:45.842 INFO: Sensor SCM Sensor
09:08:45.850 INFO: Sensor SCM Sensor (done) | time=8ms
09:08:45.851 INFO: Sensor Python Squid Sensor
09:08:46.315 INFO: Python unit test coverage
09:08:46.315 DEBUG: Using pattern 'coverage-reports/coverage-*.xml' to find reports
09:08:46.317 DEBUG: No report was found for sonar.python.coverage.reportPath using default pattern coverage-reports/coverage-*.xml
09:08:46.318 INFO: Python integration test coverage
09:08:46.318 DEBUG: Using pattern 'coverage-reports/it-coverage-*.xml' to find reports
09:08:46.319 DEBUG: No report was found for sonar.python.coverage.itReportPath using default pattern coverage-reports/it-coverage-*.xml
09:08:46.319 INFO: Python overall test coverage
09:08:46.319 DEBUG: Using pattern 'coverage-reports/overall-coverage-*.xml' to find reports
09:08:46.321 DEBUG: No report was found for sonar.python.coverage.overallReportPath using default pattern coverage-reports/overall-coverage-*.xml
09:08:46.321 INFO: Sensor Python Squid Sensor (done) | time=470ms
09:08:46.321 INFO: Sensor Embedded CSS Analyzer Sensor
09:08:46.382 INFO: 0 source files to be analyzed
09:08:46.383 INFO: Sensor Embedded CSS Analyzer Sensor (done) | time=62ms
09:08:46.383 INFO: Sensor Zero Coverage Sensor
09:08:46.387 INFO: 0/0 source files have been analyzed
09:08:46.399 INFO: Sensor Zero Coverage Sensor (done) | time=16ms
09:08:46.399 INFO: Sensor Code Colorizer Sensor
09:08:46.400 INFO: Sensor Code Colorizer Sensor (done) | time=1ms
09:08:46.400 INFO: Sensor CPD Block Indexer
09:08:46.400 INFO: DefaultCpdBlockIndexer is used for py
09:08:46.402 DEBUG: Populating index from /var/lib/jenkins/workspace/redacted-sonar/app/__init__.py
09:08:46.405 DEBUG: Populating index from /var/lib/jenkins/workspace/redacted-sonar/app/app.py
09:08:46.429 DEBUG: Populating index from /var/lib/jenkins/workspace/redacted-sonar/checks_queue_runner.py
09:08:46.431 DEBUG: Populating index from /var/lib/jenkins/workspace/redacted-sonar/clear_queue.py
09:08:46.432 DEBUG: Populating index from /var/lib/jenkins/workspace/redacted-sonar/config.py
09:08:46.434 DEBUG: Populating index from /var/lib/jenkins/workspace/redacted-sonar/delete_queue_runner.py
09:08:46.440 DEBUG: Populating index from /var/lib/jenkins/workspace/redacted-sonar/get_auth_token.py
09:08:46.442 DEBUG: Populating index from /var/lib/jenkins/workspace/redacted-sonar/osclient.py
09:08:46.446 DEBUG: Populating index from /var/lib/jenkins/workspace/redacted-sonar/queue_runner.py
09:08:46.449 DEBUG: Populating index from /var/lib/jenkins/workspace/redacted-sonar/run.py
09:08:46.450 DEBUG: Populating index from /var/lib/jenkins/workspace/redacted-sonar/tq.py
09:08:46.451 INFO: Sensor CPD Block Indexer (done) | time=51ms
09:08:46.456 INFO: Calculating CPD for 9 files
09:08:46.457 DEBUG: Detection of duplications for redacted:redacted:config.py
09:08:46.464 DEBUG: Detection of duplications for redacted:redacted:tq.py
09:08:46.465 DEBUG: Detection of duplications for redacted:redacted:checks_queue_runner.py
09:08:46.471 DEBUG: Detection of duplications for redacted:redacted:queue_runner.py
09:08:46.474 DEBUG: Detection of duplications for redacted:redacted:app/app.py
09:08:46.476 DEBUG: Detection of duplications for redacted:redacted:osclient.py
09:08:46.477 DEBUG: Detection of duplications for redacted:redacted:clear_queue.py
09:08:46.478 DEBUG: Detection of duplications for redacted:redacted:get_auth_token.py
09:08:46.478 DEBUG: Detection of duplications for redacted:redacted:delete_queue_runner.py
09:08:46.479 INFO: CPD calculation finished
09:08:46.557 INFO: Analysis report generated in 74ms, dir size=104 KB
09:08:46.583 INFO: Analysis reports compressed in 25ms, zip size=43 KB
09:08:46.583 INFO: Analysis report generated in /var/lib/jenkins/workspace/redacted-sonar/.sonar/batch-report
09:08:46.583 DEBUG: Upload report
09:08:46.612 DEBUG: POST 200 http://redacted.com/api/ce/submit?projectKey=redacted:redacted&projectName=redacted | time=27ms
09:08:46.614 INFO: Analysis report uploaded in 31ms
09:08:46.614 INFO: ANALYSIS SUCCESSFUL, you can browse http://redacted.com/dashboard/index/redacted:redacted
09:08:46.614 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
09:08:46.614 INFO: More about the report processing at http://redacted.com/api/ce/task?id=redacted
09:08:46.619 DEBUG: Report metadata written to /var/lib/jenkins/workspace/redacted-sonar/.sonar/report-task.txt
09:08:46.620 DEBUG: Post-jobs :
09:08:46.622 INFO: Task total time: 3.396 s
09:08:46.622 INFO: ------------------------------------------------------------------------
09:08:46.622 INFO: EXECUTION SUCCESS
09:08:46.622 INFO: ------------------------------------------------------------------------
09:08:46.622 INFO: Total time: 4.610s
09:08:46.715 INFO: Final Memory: 45M/163M
09:08:46.715 INFO: ------------------------------------------------------------------------
09:08:46.716 DEBUG: Execution getVersion
09:08:46.716 DEBUG: Execution stop
版本:
Java 1.8.0_121 Oracle Corporation
Linux 3.10.0-514.6.1.el7.x86_64 amd64
SonarQube server 6.2
pylint 1.6.5,
astroid 1.4.9
Python 2.7.5 (default, Nov 6 2016, 00:28:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]
Plugins:
* Python 1.7.0.1195 (python)
* CSS / SCSS / Less 3.1 (css)
* Web 2.5.0.476 (web)
* Git 1.2 (scmgit)
* JSON 2.2 (JSON)
* SonarJS 2.20.0.4207 (javascript)
pylint输出示例:
************* Module tq
tq.py:1: [R0801(duplicate-code), ] Similar lines in 2 files
==app.app:246
==get_auth_token:13
***REDACTED RAW CODE***
tq.py:1: [R0801(duplicate-code), ] Similar lines in 2 files
==checks_queue_runner:1
==queue_runner:1
***REDACTED RAW CODE***
# connect to consul
tq.py:1: [R0801(duplicate-code), ] Similar lines in 3 files
==checks_queue_runner:1
==clear_queue:1
==queue_runner:1
***REDACTED RAW CODE***
tq.py:1: [R0801(duplicate-code), ] Similar lines in 2 files
==app.app:40
==tq:11
***REDACTED RAW CODE***
tq.py:1: [R0801(duplicate-code), ] Similar lines in 4 files
==checks_queue_runner:1
==clear_queue:1
==delete_queue_runner:2
==queue_runner:1
***REDACTED RAW CODE***
Report
======
774 statements analysed.
Statistics by type
------------------
+---------+-------+-----------+-----------+------------+---------+
|type |number |old number |difference |%documented |%badname |
+=========+=======+===========+===========+============+=========+
|module |12 |12 |= |25.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+
|class |1 |1 |= |100.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+
|method |16 |16 |= |93.75 |0.00 |
+---------+-------+-----------+-----------+------------+---------+
|function |25 |25 |= |8.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+
External dependencies
---------------------
::
app
\-app (run)
\-app (app)
osclient (clear_queue,app.app,queue_runner,checks_queue_runner,delete_queue_runner)
six (osclient)
Raw metrics
-----------
+----------+-------+------+---------+-----------+
|type |number |% |previous |difference |
+==========+=======+======+=========+===========+
|code |895 |66.59 |895 |= |
+----------+-------+------+---------+-----------+
|docstring |102 |7.59 |102 |= |
+----------+-------+------+---------+-----------+
|comment |141 |10.49 |141 |= |
+----------+-------+------+---------+-----------+
|empty |206 |15.33 |206 |= |
+----------+-------+------+---------+-----------+
Duplication
-----------
+-------------------------+------+---------+-----------+
| |now |previous |difference |
+=========================+======+=========+===========+
|nb duplicated lines |97 |97 |= |
+-------------------------+------+---------+-----------+
|percent duplicated lines |7.282 |7.282 |= |
+-------------------------+------+---------+-----------+
Messages by category
--------------------
+-----------+-------+---------+-----------+
|type |number |previous |difference |
+===========+=======+=========+===========+
|convention |238 |238 |= |
+-----------+-------+---------+-----------+
|refactor |16 |16 |= |
+-----------+-------+---------+-----------+
|warning |681 |681 |= |
+-----------+-------+---------+-----------+
|error |41 |41 |= |
+-----------+-------+---------+-----------+
% errors / warnings by module
-----------------------------
+--------------------+------+--------+---------+-----------+
|module |error |warning |refactor |convention |
+====================+======+========+=========+===========+
|app.app |21.95 |56.09 |25.00 |43.28 |
+--------------------+------+--------+---------+-----------+
|delete_queue_runner |19.51 |4.99 |25.00 |7.98 |
+--------------------+------+--------+---------+-----------+
|queue_runner |14.63 |14.39 |12.50 |15.97 |
+--------------------+------+--------+---------+-----------+
|checks_queue_runner |14.63 |8.22 |0.00 |7.56 |
+--------------------+------+--------+---------+-----------+
|clear_queue |14.63 |7.05 |0.00 |6.30 |
+--------------------+------+--------+---------+-----------+
|get_auth_token |4.88 |7.78 |0.00 |4.62 |
+--------------------+------+--------+---------+-----------+
|osclient |4.88 |0.88 |6.25 |7.56 |
+--------------------+------+--------+---------+-----------+
|app.__init__ |2.44 |0.15 |0.00 |1.26 |
+--------------------+------+--------+---------+-----------+
|tq |2.44 |0.00 |31.25 |3.78 |
+--------------------+------+--------+---------+-----------+
|config |0.00 |0.29 |0.00 |1.26 |
+--------------------+------+--------+---------+-----------+
|run |0.00 |0.15 |0.00 |0.42 |
+--------------------+------+--------+---------+-----------+
Messages
--------
+------------------------------+------------+
|message id |occurrences |
+==============================+============+
|mixed-indentation |233 |
+------------------------------+------------+
|bad-indentation |204 |
+------------------------------+------------+
|unused-wildcard-import |149 |
+------------------------------+------------+
|invalid-name |75 |
+------------------------------+------------+
|bad-whitespace |49 |
+------------------------------+------------+
|line-too-long |44 |
+------------------------------+------------+
|import-error |38 |
+------------------------------+------------+
|unused-variable |33 |
+------------------------------+------------+
|missing-docstring |33 |
+------------------------------+------------+
|unused-import |32 |
+------------------------------+------------+
|bad-continuation |18 |
+------------------------------+------------+
|wrong-import-order |11 |
+------------------------------+------------+
|unnecessary-semicolon |8 |
+------------------------------+------------+
|wildcard-import |6 |
+------------------------------+------------+
|unused-argument |5 |
+------------------------------+------------+
|duplicate-code |5 |
+------------------------------+------------+
|redefined-outer-name |4 |
+------------------------------+------------+
|bare-except |4 |
+------------------------------+------------+
|too-many-statements |3 |
+------------------------------+------------+
|too-many-locals |3 |
+------------------------------+------------+
|too-many-arguments |3 |
+------------------------------+------------+
|superfluous-parens |3 |
+------------------------------+------------+
|undefined-variable |2 |
+------------------------------+------------+
|trailing-whitespace |2 |
+------------------------------+------------+
|wrong-import-position |1 |
+------------------------------+------------+
|too-many-nested-blocks |1 |
+------------------------------+------------+
|too-many-format-args |1 |
+------------------------------+------------+
|too-many-branches |1 |
+------------------------------+------------+
|singleton-comparison |1 |
+------------------------------+------------+
|relative-import |1 |
+------------------------------+------------+
|old-style-class |1 |
+------------------------------+------------+
|broad-except |1 |
+------------------------------+------------+
|anomalous-backslash-in-string |1 |
+------------------------------+------------+
Global evaluation
-----------------
Your code has been rated at -4.73/10 (previous run: -4.73/10, +0.00)
编辑
通过将pylint-report.txt发送给jenkins:jenkins作为我的exec shell步骤的一部分,我能够实现这一点。这似乎使它发挥了作用。我遇到了同样的问题,但解决方案不同:在sonarqube上激活pylint规则。我在我的Python质量概要文件中一个接一个地激活了pylint规则,在sonarqube的描述中,我记下了pylint规则的代码 通常,如果Python的“内置”SonarAnalyzer已经具有相同的规则,则sonarqube上的pylint规则将被视为不推荐使用。(我们不希望同一问题由两条规则报告。) 这些是我在sonarqube上发现的不推荐使用的pylint规则。我在pylint.cfg文件中禁用了它们。
C0103、C0111、C0112、C0301、C0302、C0303、C0304、C0321、C0325、C1001、E0100、E0101、E0103、E0104、E0105、E0106、E0107、E0235、R0201、R0801、R0911、R0912、R0913、W0101、W0107、W0122、W0331、W0333、W1401
激活规则时,您可以指定严重性,因此逐个执行可以配置每种类型的违规行为对项目的“攻击性”。您是否在SonarQube配置文件中激活了Pylint规则?@ElenaVilchik我启用了除不推荐使用的规则外的所有规则。然而,作为exec shell步骤的一部分,我将pylint-report.txt下载到了
jenkins:jenkins
,这似乎使得pylint导入传感器
开始生效(尽管有很多抱怨pylint规则在声纳中是未知的)。虽然它没有拾取重复,但当我手动运行pylint时,肯定会有一些重复。不知道该怎么做。你说的是什么样的复制品?你能提供派林报告吗?@ElenaVilchik补充道。编辑了原始代码pylint输出,以显示哪些代码是重复的。@ElenaVilchik现在我有我的jenkins实例使用clonedigger进行重复代码报告,直到sonar让它工作为止。
Java 1.8.0_121 Oracle Corporation
Linux 3.10.0-514.6.1.el7.x86_64 amd64
SonarQube server 6.2
pylint 1.6.5,
astroid 1.4.9
Python 2.7.5 (default, Nov 6 2016, 00:28:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]
Plugins:
* Python 1.7.0.1195 (python)
* CSS / SCSS / Less 3.1 (css)
* Web 2.5.0.476 (web)
* Git 1.2 (scmgit)
* JSON 2.2 (JSON)
* SonarJS 2.20.0.4207 (javascript)
************* Module tq
tq.py:1: [R0801(duplicate-code), ] Similar lines in 2 files
==app.app:246
==get_auth_token:13
***REDACTED RAW CODE***
tq.py:1: [R0801(duplicate-code), ] Similar lines in 2 files
==checks_queue_runner:1
==queue_runner:1
***REDACTED RAW CODE***
# connect to consul
tq.py:1: [R0801(duplicate-code), ] Similar lines in 3 files
==checks_queue_runner:1
==clear_queue:1
==queue_runner:1
***REDACTED RAW CODE***
tq.py:1: [R0801(duplicate-code), ] Similar lines in 2 files
==app.app:40
==tq:11
***REDACTED RAW CODE***
tq.py:1: [R0801(duplicate-code), ] Similar lines in 4 files
==checks_queue_runner:1
==clear_queue:1
==delete_queue_runner:2
==queue_runner:1
***REDACTED RAW CODE***
Report
======
774 statements analysed.
Statistics by type
------------------
+---------+-------+-----------+-----------+------------+---------+
|type |number |old number |difference |%documented |%badname |
+=========+=======+===========+===========+============+=========+
|module |12 |12 |= |25.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+
|class |1 |1 |= |100.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+
|method |16 |16 |= |93.75 |0.00 |
+---------+-------+-----------+-----------+------------+---------+
|function |25 |25 |= |8.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+
External dependencies
---------------------
::
app
\-app (run)
\-app (app)
osclient (clear_queue,app.app,queue_runner,checks_queue_runner,delete_queue_runner)
six (osclient)
Raw metrics
-----------
+----------+-------+------+---------+-----------+
|type |number |% |previous |difference |
+==========+=======+======+=========+===========+
|code |895 |66.59 |895 |= |
+----------+-------+------+---------+-----------+
|docstring |102 |7.59 |102 |= |
+----------+-------+------+---------+-----------+
|comment |141 |10.49 |141 |= |
+----------+-------+------+---------+-----------+
|empty |206 |15.33 |206 |= |
+----------+-------+------+---------+-----------+
Duplication
-----------
+-------------------------+------+---------+-----------+
| |now |previous |difference |
+=========================+======+=========+===========+
|nb duplicated lines |97 |97 |= |
+-------------------------+------+---------+-----------+
|percent duplicated lines |7.282 |7.282 |= |
+-------------------------+------+---------+-----------+
Messages by category
--------------------
+-----------+-------+---------+-----------+
|type |number |previous |difference |
+===========+=======+=========+===========+
|convention |238 |238 |= |
+-----------+-------+---------+-----------+
|refactor |16 |16 |= |
+-----------+-------+---------+-----------+
|warning |681 |681 |= |
+-----------+-------+---------+-----------+
|error |41 |41 |= |
+-----------+-------+---------+-----------+
% errors / warnings by module
-----------------------------
+--------------------+------+--------+---------+-----------+
|module |error |warning |refactor |convention |
+====================+======+========+=========+===========+
|app.app |21.95 |56.09 |25.00 |43.28 |
+--------------------+------+--------+---------+-----------+
|delete_queue_runner |19.51 |4.99 |25.00 |7.98 |
+--------------------+------+--------+---------+-----------+
|queue_runner |14.63 |14.39 |12.50 |15.97 |
+--------------------+------+--------+---------+-----------+
|checks_queue_runner |14.63 |8.22 |0.00 |7.56 |
+--------------------+------+--------+---------+-----------+
|clear_queue |14.63 |7.05 |0.00 |6.30 |
+--------------------+------+--------+---------+-----------+
|get_auth_token |4.88 |7.78 |0.00 |4.62 |
+--------------------+------+--------+---------+-----------+
|osclient |4.88 |0.88 |6.25 |7.56 |
+--------------------+------+--------+---------+-----------+
|app.__init__ |2.44 |0.15 |0.00 |1.26 |
+--------------------+------+--------+---------+-----------+
|tq |2.44 |0.00 |31.25 |3.78 |
+--------------------+------+--------+---------+-----------+
|config |0.00 |0.29 |0.00 |1.26 |
+--------------------+------+--------+---------+-----------+
|run |0.00 |0.15 |0.00 |0.42 |
+--------------------+------+--------+---------+-----------+
Messages
--------
+------------------------------+------------+
|message id |occurrences |
+==============================+============+
|mixed-indentation |233 |
+------------------------------+------------+
|bad-indentation |204 |
+------------------------------+------------+
|unused-wildcard-import |149 |
+------------------------------+------------+
|invalid-name |75 |
+------------------------------+------------+
|bad-whitespace |49 |
+------------------------------+------------+
|line-too-long |44 |
+------------------------------+------------+
|import-error |38 |
+------------------------------+------------+
|unused-variable |33 |
+------------------------------+------------+
|missing-docstring |33 |
+------------------------------+------------+
|unused-import |32 |
+------------------------------+------------+
|bad-continuation |18 |
+------------------------------+------------+
|wrong-import-order |11 |
+------------------------------+------------+
|unnecessary-semicolon |8 |
+------------------------------+------------+
|wildcard-import |6 |
+------------------------------+------------+
|unused-argument |5 |
+------------------------------+------------+
|duplicate-code |5 |
+------------------------------+------------+
|redefined-outer-name |4 |
+------------------------------+------------+
|bare-except |4 |
+------------------------------+------------+
|too-many-statements |3 |
+------------------------------+------------+
|too-many-locals |3 |
+------------------------------+------------+
|too-many-arguments |3 |
+------------------------------+------------+
|superfluous-parens |3 |
+------------------------------+------------+
|undefined-variable |2 |
+------------------------------+------------+
|trailing-whitespace |2 |
+------------------------------+------------+
|wrong-import-position |1 |
+------------------------------+------------+
|too-many-nested-blocks |1 |
+------------------------------+------------+
|too-many-format-args |1 |
+------------------------------+------------+
|too-many-branches |1 |
+------------------------------+------------+
|singleton-comparison |1 |
+------------------------------+------------+
|relative-import |1 |
+------------------------------+------------+
|old-style-class |1 |
+------------------------------+------------+
|broad-except |1 |
+------------------------------+------------+
|anomalous-backslash-in-string |1 |
+------------------------------+------------+
Global evaluation
-----------------
Your code has been rated at -4.73/10 (previous run: -4.73/10, +0.00)