With this rule I want to check if there is a Where in a Update statement. SonarLint checks it correctly, but does not show the note in the correct line:
I will assume you have the same behavior in SonarQube.
I think the problem is that your XPath rule is a boolean expression. When it returns true, there is no other way for SonarQube/SonarLint than raising an issue globally to the file.
To report an issue on a specific location, your XPath expression has to select/return the actual offending node (for example here I would select the UPDATE node).
yes I tried with the not: //ANY_TOKEN[@tokenValue='SQL']/following-sibling::ANY_TOKEN[(position()=1 and ((contains(@tokenValue,'UPDATE') or contains(@tokenValue,'DELETE'))))]/following-sibling::ANY_TOKEN[not(contains(@tokenValue,'WHERE'))]
//ANY_TOKEN[@tokenValue='SQL']/following-sibling::ANY_TOKEN[(position()=1 and ((@tokenValue='UPDATE' or @tokenValue='DELETE'))) and count(following-sibling::ANY_TOKEN[@tokenValue='WHERE']) = 0]