From 4bbe5a064b85209d687e04c0b396be9b9136e7a2 Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Fri, 12 Jun 2020 13:09:31 -0700 Subject: [PATCH] [racerd] document GuardedBy issue Summary: As per title Reviewed By: jvillard Differential Revision: D22019339 fbshipit-source-id: 0aab4475e --- .../documentation/issues/GUARDEDBY_VIOLATION.md | 16 ++++++++++++++++ infer/src/base/IssueType.ml | 1 + 2 files changed, 17 insertions(+) create mode 100644 infer/documentation/issues/GUARDEDBY_VIOLATION.md diff --git a/infer/documentation/issues/GUARDEDBY_VIOLATION.md b/infer/documentation/issues/GUARDEDBY_VIOLATION.md new file mode 100644 index 000000000..16314b5aa --- /dev/null +++ b/infer/documentation/issues/GUARDEDBY_VIOLATION.md @@ -0,0 +1,16 @@ +A field annotated with `@GuardedBy` is being accessed by a call-chain that starts at a non-private method without synchronization. + +Example: + +```java +class C { + @GuardedBy("this") + String f; + + void foo(String s) { + f = s; // unprotected access here + } +} +``` + +Action: Protect the offending access by acquiring the lock indicated by the `@GuardedBy(...)`. diff --git a/infer/src/base/IssueType.ml b/infer/src/base/IssueType.ml index 7ce20575d..42fe5d992 100644 --- a/infer/src/base/IssueType.ml +++ b/infer/src/base/IssueType.ml @@ -575,6 +575,7 @@ let _global_variable_initialized_with_function_or_method_call = let guardedby_violation_racerd = register_from_string Warning ~id:"GUARDEDBY_VIOLATION" ~hum:"GuardedBy Violation" RacerD + ~user_documentation:[%blob "../../documentation/issues/GUARDEDBY_VIOLATION.md"] let impure_function = register_from_string ~id:"IMPURE_FUNCTION" Error Impurity