|
|
|
@ -27,6 +27,10 @@ let activate_field_over_annotated = Config.from_env_variable "ERADICATE_FIELD_OV
|
|
|
|
|
(* activate the return over annotated warning *)
|
|
|
|
|
let activate_return_over_annotated = Config.from_env_variable "ERADICATE_RETURN_OVER_ANNOTATED"
|
|
|
|
|
|
|
|
|
|
(* activate the propagation of nullable to the return value *)
|
|
|
|
|
let activate_propagate_return_nullable =
|
|
|
|
|
Config.from_env_variable "ERADICATE_PROPAGATE_RETURN_NULLABLE"
|
|
|
|
|
|
|
|
|
|
(* do not report RETURN_NOT_NULLABLE if the return is annotated @Nonnull *)
|
|
|
|
|
let return_nonnull_silent = true
|
|
|
|
|
|
|
|
|
@ -325,6 +329,23 @@ let check_constructor_initialization
|
|
|
|
|
| _ -> ()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
(** Make the return type @Nullable by modifying the spec. *)
|
|
|
|
|
let spec_make_return_nullable curr_pname =
|
|
|
|
|
match Specs.get_summary curr_pname with
|
|
|
|
|
| Some summary ->
|
|
|
|
|
let proc_attributes = Specs.get_attributes summary in
|
|
|
|
|
let method_annotation = proc_attributes.ProcAttributes.method_annotation in
|
|
|
|
|
let method_annotation' = Annotations.method_annotation_mark_return
|
|
|
|
|
Annotations.Nullable method_annotation in
|
|
|
|
|
let proc_attributes' =
|
|
|
|
|
{ proc_attributes with
|
|
|
|
|
ProcAttributes.method_annotation = method_annotation' } in
|
|
|
|
|
let summary' =
|
|
|
|
|
{ summary with
|
|
|
|
|
Specs.attributes = proc_attributes' } in
|
|
|
|
|
Specs.add_summary curr_pname summary'
|
|
|
|
|
| None -> ()
|
|
|
|
|
|
|
|
|
|
(** Check the annotations when returning from a method. *)
|
|
|
|
|
let check_return_annotation
|
|
|
|
|
find_canonical_duplicate curr_pname curr_pdesc exit_node ret_range
|
|
|
|
@ -352,10 +373,13 @@ let check_return_annotation
|
|
|
|
|
activate_return_over_annotated in
|
|
|
|
|
|
|
|
|
|
if return_not_nullable && Models.Inference.enabled then
|
|
|
|
|
Models.Inference.proc_add_return_nullable curr_pname;
|
|
|
|
|
Models.Inference.proc_mark_return_nullable curr_pname;
|
|
|
|
|
|
|
|
|
|
if return_not_nullable && !Config.ondemand_enabled then
|
|
|
|
|
Ondemand.proc_add_return_nullable curr_pname;
|
|
|
|
|
if return_not_nullable &&
|
|
|
|
|
!Config.ondemand_enabled &&
|
|
|
|
|
activate_propagate_return_nullable
|
|
|
|
|
then
|
|
|
|
|
spec_make_return_nullable curr_pname;
|
|
|
|
|
|
|
|
|
|
if return_not_nullable || return_value_not_present then
|
|
|
|
|
begin
|
|
|
|
|