From f0199a058a50c487f70012b1e1113a541492d746 Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Thu, 26 Jan 2017 12:53:21 -0800 Subject: [PATCH] [cleanup] alphabetize annotations and remove duplicates Reviewed By: jeremydubreil Differential Revision: D4469125 fbshipit-source-id: ba12c0b --- infer/src/checkers/annotations.ml | 97 +++++++++++++++--------------- infer/src/checkers/annotations.mli | 20 +++--- infer/src/checkers/checkers.ml | 2 +- 3 files changed, 56 insertions(+), 63 deletions(-) diff --git a/infer/src/checkers/annotations.ml b/infer/src/checkers/annotations.ml index 4a75cfd89..f2c70bee1 100644 --- a/infer/src/checkers/annotations.ml +++ b/infer/src/checkers/annotations.ml @@ -14,15 +14,59 @@ module L = Logging (** Annotations. *) +let any_thread = "AnyThread" +let assume_thread_safe = "AssumeThreadSafe" +let bind = "Bind" +let bind_view = "BindView" +let bind_array = "BindArray" +let bind_bitmap = "BindBitmap" +let bind_drawable = "BindDrawable" +let bind_string = "BindString" +let camel_nonnull = "NonNull" +let expensive = "Expensive" +let false_on_null = "FalseOnNull" +let for_ui_thread = "ForUiThread" +let for_non_ui_thread = "ForNonUiThread" +let guarded_by = "GuardedBy" +let ignore_allocations = "IgnoreAllocations" +let initializer_ = "Initializer" +let inject = "Inject" +let inject_view = "InjectView" +let integrity_source = "IntegritySource" +let integrity_sink = "IntegritySink" +let mutable_ = "Mutable" +let nonnull = "Nonnull" +let no_allocation = "NoAllocation" +let nullable = "Nullable" +let on_bind = "OnBind" +let on_event = "OnEvent" +let on_mount = "OnMount" +let on_unbind = "OnUnbind" +let on_unmount = "OnUnmount" +let notnull = "NotNull" +let not_thread_safe = "NotThreadSafe" +let performance_critical = "PerformanceCritical" +let present = "Present" +let privacy_source = "PrivacySource" +let privacy_sink = "PrivacySink" +let strict = "com.facebook.infer.annotation.Strict" +let suppress_lint = "SuppressLint" +let suppress_view_nullability = "SuppressViewNullability" +let thread_confined = "ThreadConfined" +let thread_safe = "ThreadSafe" +let thread_safe_method = "ThreadSafeMethod" +let true_on_null = "TrueOnNull" +let ui_thread = "UiThread" +let verify_annotation = "com.facebook.infer.annotation.Verify" +let visibleForTesting = "com.google.common.annotations.VisibleForTesting" +let volatile = "volatile" + (** Method signature with annotations. *) type annotated_signature = { ret : Annot.Item.t * Typ.t; (** Annotated return type. *) params: (Mangled.t * Annot.Item.t * Typ.t) list (** Annotated parameters. *) } [@@deriving compare] -let visibleForTesting = "com.google.common.annotations.VisibleForTesting" -let suppressLint = "android.annotation.SuppressLint" - let ia_iter f = let ann_iter (a, _) = f a in IList.iter ann_iter @@ -87,53 +131,6 @@ let field_has_annot fieldname (struct_typ : StructTyp.t) f = IList.exists fld_has_taint_annot struct_typ.fields || IList.exists fld_has_taint_annot struct_typ.statics -let initializer_ = "Initializer" -let inject = "Inject" -let inject_view = "InjectView" -let bind = "Bind" -let bind_view = "BindView" -let bind_array = "BindArray" -let bind_bitmap = "BindBitmap" -let bind_drawable = "BindDrawable" -let bind_string = "BindString" -let suppress_view_nullability = "SuppressViewNullability" -let false_on_null = "FalseOnNull" -let mutable_ = "Mutable" -let nullable = "Nullable" -let nonnull = "Nonnull" -let on_bind = "OnBind" -let on_event = "OnEvent" -let on_mount = "OnMount" -let on_unbind = "OnUnbind" -let on_unmount = "OnUnmount" -let camel_nonnull = "NonNull" -let notnull = "NotNull" -let present = "Present" -let strict = "com.facebook.infer.annotation.Strict" -let true_on_null = "TrueOnNull" -let verify_annotation = "com.facebook.infer.annotation.Verify" -let volatile = "volatile" -let expensive = "Expensive" -let performance_critical = "PerformanceCritical" -let no_allocation = "NoAllocation" -let ignore_allocations = "IgnoreAllocations" - -let suppress_lint = "SuppressLint" -let privacy_source = "PrivacySource" -let privacy_sink = "PrivacySink" -let integrity_source = "IntegritySource" -let integrity_sink = "IntegritySink" -let guarded_by = "GuardedBy" -let thread_safe = "ThreadSafe" -let thread_safe_method = "ThreadSafeMethod" -let not_thread_safe = "NotThreadSafe" -let assume_thread_safe = "AssumeThreadSafe" -let ui_thread = "UiThread" -let any_thread = "AnyThread" -let for_ui_thread = "ForUiThread" -let for_non_ui_thread = "ForNonUiThread" -let thread_confined = "ThreadConfined" - let ia_is_not_thread_safe ia = ia_ends_with ia not_thread_safe diff --git a/infer/src/checkers/annotations.mli b/infer/src/checkers/annotations.mli index 727a6e525..c5db34caa 100644 --- a/infer/src/checkers/annotations.mli +++ b/infer/src/checkers/annotations.mli @@ -11,16 +11,18 @@ open! IStd (** Annotations. *) -val suppressLint : string - +val any_thread : string val expensive : string -val performance_critical : string val no_allocation : string +val nullable : string val on_bind : string -val ui_thread : string -val any_thread : string -val for_ui_thread : string +val performance_critical : string val for_non_ui_thread : string +val for_ui_thread : string +val guarded_by : string +val suppress_lint : string +val ui_thread : string +val visibleForTesting : string type annotation = | Nullable @@ -56,8 +58,6 @@ val annotated_signature_mark_return_strict : (** Get a method signature with annotations from a proc_attributes. *) val get_annotated_signature : ProcAttributes.t -> annotated_signature -val nullable : string - (** [annot_ends_with annot ann_name] returns true if the class name of [annot], without the package, is equal to [ann_name] *) val annot_ends_with : Annot.t -> string -> bool @@ -127,7 +127,3 @@ val method_annotation_mark_return : val mk_ia : annotation -> Annot.Item.t -> Annot.Item.t val pp_annotated_signature : Procname.t -> Format.formatter -> annotated_signature -> unit - -val visibleForTesting : string -val guarded_by : string -val suppress_lint : string diff --git a/infer/src/checkers/checkers.ml b/infer/src/checkers/checkers.ml index 3fa8b0cc9..c884a498b 100644 --- a/infer/src/checkers/checkers.ml +++ b/infer/src/checkers/checkers.ml @@ -98,7 +98,7 @@ module ST = struct String.equal (normalize s1) (normalize s2) in let is_parameter_suppressed = - IList.mem String.equal a.class_name [Annotations.suppressLint] && + String.is_suffix a.class_name ~suffix:Annotations.suppress_lint && IList.mem normalized_equal kind a.parameters in let is_annotation_suppressed = String.is_suffix ~suffix:(normalize (drop_prefix kind)) (normalize a.class_name) in