Skip to content

Instantly share code, notes, and snippets.

@kitsook
Created October 31, 2022 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kitsook/b2f6df549c6e50e161e7c8a3e7f511a7 to your computer and use it in GitHub Desktop.
Save kitsook/b2f6df549c6e50e161e7c8a3e7f511a7 to your computer and use it in GitHub Desktop.
Rule based static analysis - rules
---
name: "BigDecimal explicit toString"
description: "find code that explicitly call BigDecimal toString"
condition: "resolvedMethodRef.getPackageName().toString().equals(\"java.math\") &&
resolvedMethodRef.getClassName().toString().equals(\"BigDecimal\") &&
node.getName().toString() == \"toString\""
actions:
- "System.out.print(\"Cautions! Explicitly calling BigDecimal toString() in \" + file.toString());
if (node.getRange().isPresent()) {
System.out.println(\" at \" + node.getRange().get().toString());
}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment