Xpath rule for line alignment PLSQL plugin

sonarqube

(Durga madhaba nanda) #1

1.Right-align operators (INTO, WHERE, AND, OR etc.) under SELECT should be properly aligned .

like below

correct.

SELECT oe.order_number
INTO v_order_number
FROM apps.oe_order_headers_all oe
WHERE oe.order_number = 10001;

Not correct
SELECT oe.order_number INTO v_order_number
FROM apps.oe_order_headers_all oe
WHERE oe.order_number = 10001;

along with below xpath query also

2.Line spacing between program sections and logical structures should be achieved using double hyphen (“–“)
3.For a function or procedure declaration, place each parameter specification on a new line
4.Each variable declaration inside a procedure, function or package should be on a new line

we need xpath query for this for plsql plugin


(Dinesh Bolkensteyn) #2

Hey @Durga

I won’t be able to help you with all your custom XPath queries, however is a starting point to detect SELECT ... INTO statements where the SELECT and INTO tokens are not aligned on the same column:

//SELECT_INTO_STATEMENT[INTO_CLAUSE/@tokenColumn != SELECT/@tokenColumn]

Perhaps you’ll want to refine this to allow queries where the INTO appears on the same line as the SELECT, but that is entirely up to you.

Have fun with XPath :slight_smile:


(Durga madhaba nanda) #3

ok…


(Durga madhaba nanda) #4

suggestion not working …we are not getting anything called SELECT_INTO_STATEMENT on xml tree.Any other alternate wil help us. Using Xpath we are not able to trace any alignment yet.