Need a linter check script to get scan the syntax "gs.getMessage("yyyy-mm-dd") from all the scripts

Naman Srivastav
Tera Contributor
Need a linter check script to get scan the syntax "gs.getMessage("yyyy-mm-dd") from all the scripts it is running for the "gs" but  not for the "'yyyy-mm-dd" and getMessage("yyyy-mm-dd"), please help me with the script to scan the findings as I am trying from script include or please modify the given below script. please help me out with this
 
 
 
(function(engine) {

    engine.rootNode.visit(function(node) {

   if(node.getTypeName() === "NAME" &&
           node.getNameIdentifier() === 'yyyy-MM-dd') {
           
            {
                engine.finding.incrementWithNode(node);
            }
        }
    });
})(engine);
1 ACCEPTED SOLUTION

Aniket Chavan
Tera Sage
Tera Sage

Hello @Naman Srivastav ,

You can give a try to the script below and see how it works for you.

(function(engine) {
    engine.rootNode.visit(function(node) {
        if (
            node.getTypeName() === "STRING" &&
            node.getParent() &&
            node.getParent().getTypeName() === "CALL" &&
            node.getParent().getFirstChild() &&
            node.getParent().getFirstChild().getTypeName() === "NAME" &&
            node.getParent().getFirstChild().getNameIdentifier() === "gs.getMessage" &&
            node.getValue() === 'yyyy-MM-dd'
        ) {
            engine.finding.incrementWithNode(node.getParent());
        }
    });
})(engine);

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks,

Aniket

View solution in original post

5 REPLIES 5

Hello @Naman Srivastav ,

Glad that my response was helpful to resolve your query😉.

Can you please mark my solution as helpful and accept my solution as well and close the thread this will help future readers as well.

Thanks & Regards,

Aniket