SonarQube Python插件 - 扫描python代码:无法装饰

时间:2015-02-25 16:57:03

标签: python python-2.7 sonarqube sonar-runner

我正在尝试在示例项目中运行扫描(我实际上是在尝试扫描更大的项目,但问题是一样的。我正在研究示例项目,因为它更简单)它给了我以下错误:

INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 29.790s
Final Memory: 14M/379M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: Fail to decorate 'org.sonar.api.resources.File@56ffc188[key=src/__init__.py,deprecatedKey=__init__.py,path=src/__init__.py,dir=[root],filename=__init__.py,language=Python]'
ERROR: Caused by: 0
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.

任何人都知道这意味着什么?这是开箱即用的示例项目,我的sonnar runner配置非常简单:

#----- Default SonarQube server
sonar.host.url=http://localhost:9000

#----- MySQL
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8

#----- Global database settings
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar

#----- Default source code encoding
sonar.sourceEncoding=UTF-8

#----- Security (when 'sonar.forceAuthentication' is set to 'true')
sonar.login=admin
sonar.password=admin

我已根据这些规则在新配置文件中启用了所有pylint规则。默认配置文件为默认配置文件(Sonar Way),不会发生错误。奇怪的是我从pylint启用了一个随机规则并且它有效。因此,一条(或多条)规则可能会破坏分析。

Pylint整合对我来说至关重要。

堆栈跟踪虽然不是很有用但是如下:

ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
        at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
        at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
        at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
        at org.sonar.runner.api.Runner.execute(Runner.java:100)
        at org.sonar.runner.Main.executeTask(Main.java:70)
        at org.sonar.runner.Main.execute(Main.java:59)
        at org.sonar.runner.Main.main(Main.java:53)
Caused by: org.sonar.api.utils.SonarException: Fail to decorate 'org.sonar.api.resources.File@3f3674b2[key=src/__init__.py,deprecatedKey=__init__.py,path=src/__init__.py,dir=[root],filename=__init__.py,language=Python]'
        at org.sonar.batch.phases.DecoratorsExecutor.executeDecorator(DecoratorsExecutor.java:103)
        at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:86)
        at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:78)
        at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:78)
        at org.sonar.batch.phases.DecoratorsExecutor.execute(DecoratorsExecutor.java:70)
        at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:126)
        at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:222)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
        at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:235)
        at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:230)
        at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:223)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
        at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:65)
        at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:52)
        at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:128)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
        at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:171)
        at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
        at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
        ... 9 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
        at org.sonar.plugins.core.issue.tracking.FileHashes.getHash(FileHashes.java:75)
        at org.sonar.plugins.core.issue.IssueTracking.setChecksumOnNewIssues(IssueTracking.java:69)
        at org.sonar.plugins.core.issue.IssueTracking.track(IssueTracking.java:54)
        at org.sonar.plugins.core.issue.IssueTrackingDecorator.doDecorate(IssueTrackingDecorator.java:138)
        at org.sonar.plugins.core.issue.IssueTrackingDecorator.decorate(IssueTrackingDecorator.java:112)
        at org.sonar.batch.phases.DecoratorsExecutor.executeDecorator(DecoratorsExecutor.java:95)
        ... 36 more

感谢您的帮助!

1 个答案:

答案 0 :(得分:2)

我遇到了同样的问题。我必须停用两个规则来停止此错误消息:

  • 缺少docstring
  • 应定义docstring

我也停用了已弃用的规则,但我不知道它是否有效。