简体   繁体   English

声纳插件-查看源代码

[英]Sonar Plugin - View Source Code

I'm writing a small Sonar Plugin for Abap Code. 我正在为Abap代码编写一个小的Sonar插件。 I alread have presented metrics in Sonar, and also have the source Code of some Abap Files in the Sonar Database (i checked it with a sql client). 我已经在Sonar中介绍了指标,并且在Sonar数据库中也提供了一些Abap文件的源代码(我使用sql客户端对其进行了检查)。 But now I really have no clue how could I present this source code with sonar. 但是现在我真的不知道该如何使用声纳显示此源代码。 I already looked through the sonar source code and some sonar plugins (like the CXXPlugin https://github.com/SonarCommunity/sonar-cxx which also have the Function to output the source Code), but I didn't get smarter. 我已经浏览了声纳源代码和一些声纳插件(例如CXXPlugin https://github.com/SonarCommunity/sonar-cxx ,它们也具有输出源代码的功能),但是我并没有变得更聪明。 Is there an easy way how to present source code with the sonar api? 有一种简单的方法如何使用声纳API呈现源代码? Is there any kind of SourceViewer part of the Sonar Core ( https://github.com/SonarSource/sonar ). 声纳核心( https://github.com/SonarSource/sonar )是否有任何SourceViewer部分。


EDIT: I'm now one step closer but I have a problem with the drilldown-view. 编辑:我现在离我们更近了一步,但是我对明细视图有问题。 My erb-file has the following code snippet: 我的erb文件具有以下代码段:

 %= format_measure(loc_measure, :suffix => '', :url => url_for_drilldown(loc_measure)) -%> 

But my drilldown view do not list the sources which I have in my folder which was analysed by sonar: 但是我的向下钻取视图未列出我的文件夹中已通过声纳分析的来源: 在此处输入图片说明

In my Database I looked at the table 'projects': 在数据库中,我查看了“项目”表: 在此处输入图片说明

Afterwards I tried to directly link in the drilldown view to a source file (in that case with the id 122) and it worked: 之后,我尝试直接在钻取视图中链接到源文件(在这种情况下,其ID为122),并且可以正常工作: 在此处输入图片说明

So my question is, why are the subfolder and source files not listed like classes and package in a normal Java project? 所以我的问题是,为什么子文件夹和源文件没有像普通Java项目中的类和包那样列出?

You can take a look at some of our open-source language plugins that we develop for Sonar. 您可以看一下我们为Sonar开发的一些开源语言插件。 For instance, you can go and see the Javascript plugin - which is probably a better option that the CXX plugin that is not developed by us and there that may not fully comply with our conventions and coding best-practices & guidelines. 例如,您可以去看看Javascript插件 -这可能是一个更好的选择,它不是我们开发的CXX插件,并且那里可能不完全符合我们的约定以及编码最佳实践和准则。

To sum up: 总结一下:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM