mulesoft-catalyst / mule-sonarqube-plugin

The Mule SonarQube Plugin provides the capability to do code inspecting and taking project metrics from a mule project using SonarQube.
The Unlicense
48 stars 69 forks source link

About LineNumbers displaying on Issue #15

Open ptupakul opened 4 years ago

ptupakul commented 4 years ago

HI,

I am Uisng the SonarQube to check my Mule Code Quality, But for Java,C++... other languages it is displaying the Line number at right side corner but it is not for MuleCode see below fig.

I think should be more useful for quick understanding and fixing the issue if it has that feature.

image

Thanks,

fperezpa commented 3 years ago

Hi, The plugin doesn't set the line number. It evaluates XPath expressions and uses Jdom 2 for that. I haven't found yet a solution to evaluate the expression and get the line number.

ca-stefan-cordes commented 3 years ago

The xml plugin from sonar has some nice helpers to find the line numbers (XmlTextRange). With the original xpath boolean the location is not possible to find. I added the XmlFile from

sonar-xml-parsing

and now it looks like this.

image

abhayagarwalonline commented 3 years ago

hello

Does Mule sonar plugin codebase has this change of showing line numbers in file where bug is ?
I took latest sonar plugin codebase , built up sonar and ran code analysis. I am not seeing line number of file. please help

thanks abhay

ca-stefan-cordes commented 3 years ago

Hi @abhayagarwalonline , just a few rules are prepared to show line numbers: "HTTP Listener should use HTTPS protocol" and "HTTP Listener should use a specific port property".

All others currently does not have an locationHint xpath and so still are showing on top of file.

abhayagarwalonline commented 3 years ago

thanks for the reply ... please let me know how to add locationHint xpath for other Rules

ca-stefan-cordes commented 3 years ago

Just edit the rules-4.xml (and create a pull-request) ;-)

Each body of the nodes has a boolean xpath. The locationHint="" needs to have "the same" rule but returning the first matching node.

Example: value=

            count(//mule:mule/http:listener-config)=0
            or
            //mule:mule/http:listener-config/http:listener-connection/@port='${https.port}'
            or
            //mule:mule/http:listener-config/http:listener-connection/@port='${https.private.port}'

locationHint="//*[local-name()='listener-config']"

Maybe just the "count(" parameter is working as well, but I did not check it: locationHint="//mule:mule/http:listener-config" (as currently two different xml implementations are used #23 ) the root note for locationHint probably needs to be whithout namespace:) locationHint="//mule/http:listener-config"

abhayagarwalonline commented 3 years ago

Thanks for the reply, I will check and revert if it works for me

gurupradeep088 commented 3 years ago

The locationHint without the name space locationHint="//mule/http:listener-config" doesn't seems to be working. I have used locationHint="//http:request" which will return the all http:request nodes. But it isn't working

ca-stefan-cordes commented 3 years ago

Did you try locationHint="//*[local-name()='listener-config']" ?