- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 10:33 PM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 10:38 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 10:38 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 11:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 01:30 AM
@Naman Srivastav , Oh okay then lets give a try to the below modified script and let me know how it works for you.
(function(engine) {
engine.rootNode.visit({
visitNode: function(node, e, c) {
// Check if the node is a string, part of gs.getMessage, and has the value 'yyyy-MM-dd'
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.increment(node, "Avoid using 'yyyy-MM-dd' as a parameter in gs.getMessage");
}
c(node.getChildren());
}
});
})(engine);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 02:13 AM
@Aniket Chavan thanks for helping me with the scripts, I ran the given script now it is showing failure with the given error as "Rhino error: java.lang.NullPointerException" I have shared the screenshot, and again thanks for looking into my problem.