New method detection in a javascript/java file

48 views
Skip to first unread message

anand sudhan

unread,
Jan 12, 2016, 10:32:40 AM1/12/16
to SonarQube

Hello,

 

I am currently trying to customize issue-report, javascript and java plugins.

I needed help on 2 issues I was running into:

 

                 a)      I would like to be able run sonar-runner against a file at different times and compare the issues in the file at those times - at a function level. 

                       Is there an API in sonarqube – that keeps track of functions of a file (by keys or signature of function) so that I can distinguish new functions added to a file from existing functions? 


                 b)      In javascript - it is hard to distinguish one anonymous function from another in a file by function signature As anonymous functions - don't have names!

                       Is there an API level (key/signature) to distinguish different anonymous functions in a javascript file?

 

I am currently using:


              javascript plugin 2.8,

              java plugin 3.0 and

              issue reports plugin 1.2.1.

              sonarqube server 4.5.5

 

Thanks in advance,
Anand

Elena Vilchik

unread,
Jan 12, 2016, 12:02:26 PM1/12/16
to SonarQube
Hello,

About "b" :
You want to achieve the list of function declaration nodes which correspond to newly created javascript functions. Am I right?
Looks like there is nothing ready for that. So you should first decide on your side what does mean "same functions": same name? same signature? same line? same implementation? 
And after that implement appropriate for your targets approach. 

anand sudhan

unread,
Jan 12, 2016, 5:26:29 PM1/12/16
to SonarQube
Hi Elena,


i) Is there an  api to just get the list of all functions (function nodes in the file)? In the Java/Javascript plugin?

ii) Is there an api to get function body of javascript functions? 
    I need this, because for anonymous functions - just line number is not going to help - in identifying a function , as in a different version of the same file - my function might move around and change its line number.

Elena Vilchik

unread,
Jan 13, 2016, 3:04:37 AM1/13/16
to SonarQube
Hello,

No, there are no ready solutions.

Nicolas Peru

unread,
Jan 13, 2016, 3:24:27 AM1/13/16
to anand sudhan, SonarQube
Hi Anand, 

I can tell you that for java there is no such API and no plan to have one for the reasons raised by Elena. So for this you are on your own for each language. For Java you can try implement what you want by relying on custom rules but as far as I understand the feature you want, this is not going to be an easy task (not undoable but quite some work). 

Cheers,



Nicolas PERU | SonarSource
Senior Developer
http://sonarsource.com


--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/ec4527dd-646b-4f8f-bdab-f0be112821c1%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

anand sudhan

unread,
Jan 13, 2016, 7:19:19 PM1/13/16
to SonarQube, anand.su...@gmail.com
Hi Nicolas & Elena,

In an attempt to get a better understanding on how issues are created and closed - I looked at the database of sonarqube.

There is a "checksum" column for the issue table. Do the checksums correspond to the tree node(say a  function) that caused the issue?
Can I leverage it any form to figure out what the corresponding function node is, for that checksum?

Many thanks for your continued support!

Anand
Reply all
Reply to author
Forward
0 new messages