Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About LineNumbers displaying on Issue #15

Open
ptupakul opened this issue Oct 14, 2020 · 9 comments
Open

About LineNumbers displaying on Issue #15

ptupakul opened this issue Oct 14, 2020 · 9 comments

Comments

@ptupakul
Copy link

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
Copy link
Collaborator

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
Copy link
Contributor

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

  • I needed to add "the same" xpath to find the node, see locationHint="//*[local-name()='listener-config'] in the rules-3/4.xml files
  • I needed to parse the file another time as this plugin depends on org.jdom2 and sonar is org.w3c.dom
  • I just added 2 exemplary locationHint

ca-stefan-cordes added a commit to c-a-services/mule-sonarqube-plugin that referenced this issue Dec 3, 2020
ca-stefan-cordes added a commit to c-a-services/mule-sonarqube-plugin that referenced this issue Dec 3, 2020
ca-stefan-cordes added a commit to c-a-services/mule-sonarqube-plugin that referenced this issue Dec 3, 2020
fperezpa added a commit that referenced this issue Dec 7, 2020
@abhayagarwalonline
Copy link

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
Copy link
Contributor

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
Copy link

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

@ca-stefan-cordes
Copy link
Contributor

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
Copy link

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

@gurupradeep088
Copy link

gurupradeep088 commented Mar 26, 2021

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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants