[infer][differential] remove the option to prevent the conflicts between Eradicate and Biabduction

Reviewed By: martinoluca

Differential Revision: D5516126

fbshipit-source-id: 5b0052a
master
Jeremy Dubreil 7 years ago committed by Facebook Github Bot
parent f2cb85e3ab
commit e0ad3a9d75

@ -60,7 +60,6 @@ endif # BUILD_C_ANALYZERS
ifeq ($(BUILD_JAVA_ANALYZERS),yes)
BUILD_SYSTEMS_TESTS += \
differential_interesting_paths_filter \
differential_resolve_infer_eradicate_conflict \
differential_skip_anonymous_class_renamings \
differential_skip_duplicated_types_on_filenames \
differential_skip_duplicated_types_on_filenames_with_renamings \

@ -206,26 +206,6 @@ let skip_anonymous_class_renamings (diff: Differential.t) : Differential.t =
in
{introduced; fixed; preexisting= preexisting @ diff.preexisting}
(* Filter out null dereferences reported by infer if file has eradicate
enabled, to avoid double reporting. *)
let resolve_infer_eradicate_conflict (analyzer: Config.analyzer)
(filters_of_analyzer: Config.analyzer -> Inferconfig.filters) (diff: Differential.t)
: Differential.t =
let should_discard_issue (issue: Jsonbug_t.jsonbug) =
let file_is_whitelisted () =
let source_file = SourceFile.UNSAFE.from_string issue.file in
let filters = filters_of_analyzer Config.Eradicate in
filters.path_filter source_file
in
Config.equal_analyzer analyzer Config.BiAbduction
&& String.equal issue.bug_type (Localise.to_issue_id Localise.null_dereference)
&& file_is_whitelisted ()
in
let filter issues = List.filter ~f:(Fn.non should_discard_issue) issues in
{ introduced= filter diff.introduced
; fixed= filter diff.fixed
; preexisting= filter diff.preexisting }
(* Strip issues whose paths are not among those we're interested in *)
let interesting_paths_filter (interesting_paths: SourceFile.t list option) =
match interesting_paths with
@ -259,10 +239,7 @@ let do_filter (diff: Differential.t) (renamings: FileRenamings.t) ~(skip_duplica
skip_anonymous_class_renamings
else Fn.id )
|> (if skip_duplicated_types then skip_duplicated_types_on_filenames renamings else Fn.id)
|>
if Config.resolve_infer_eradicate_conflict then
resolve_infer_eradicate_conflict Config.analyzer Inferconfig.create_filters
else Fn.id
|> Fn.id
in
{ introduced= apply_paths_filter_if_needed `Introduced diff'.introduced
; fixed= apply_paths_filter_if_needed `Fixed diff'.fixed
@ -279,7 +256,5 @@ module VISIBLE_FOR_TESTING_DO_NOT_USE_DIRECTLY = struct
let skip_anonymous_class_renamings = skip_anonymous_class_renamings
let resolve_infer_eradicate_conflict = resolve_infer_eradicate_conflict
let interesting_paths_filter = interesting_paths_filter
end

@ -48,9 +48,6 @@ module VISIBLE_FOR_TESTING_DO_NOT_USE_DIRECTLY : sig
val skip_anonymous_class_renamings : Differential.t -> Differential.t
val resolve_infer_eradicate_conflict :
Config.analyzer -> (Config.analyzer -> Inferconfig.filters) -> Differential.t -> Differential.t
val interesting_paths_filter :
SourceFile.t list option -> Jsonbug_t.jsonbug list -> Jsonbug_t.jsonbug list
end

@ -1442,11 +1442,6 @@ and report_previous =
and resource_leak =
CLOpt.mk_bool ~long:"resource-leak" ~default:false "the resource leak analysis (experimental)"
and resolve_infer_eradicate_conflict =
CLOpt.mk_bool ~long:"resolve-infer-eradicate-conflict" ~default:false
~in_help:CLOpt.([(ReportDiff, manual_generic)])
"Filter out Null Dereferences reported by Infer if Eradicate is enabled"
and rest =
CLOpt.mk_rest_actions ~in_help:CLOpt.([(Capture, manual_generic); (Run, manual_generic)])
"Stop argument processing, use remaining arguments as a build command" ~usage:exe_usage
@ -2122,8 +2117,6 @@ and report_previous = !report_previous
and reports_include_ml_loc = !reports_include_ml_loc
and resolve_infer_eradicate_conflict = !resolve_infer_eradicate_conflict
and resource_leak = !resource_leak
and results_dir = !results_dir

@ -554,8 +554,6 @@ val tracing : bool
val reports_include_ml_loc : bool
val resolve_infer_eradicate_conflict : bool
val resource_leak : bool
val results_dir : string

@ -321,54 +321,6 @@ let test_skip_anonymous_class_renamings =
, ([1], [2], []) ) ]
|> List.map ~f:(fun (name, diff, expected_output) -> name >:: create_test diff expected_output)
let test_resolve_infer_eradicate_conflict =
let fake_filters_factory analyzer =
match analyzer with
| Config.Eradicate
-> { Inferconfig.path_filter= (function _ -> true)
; (* all paths are whitelisted *)
error_filter= (function _ -> failwith "error_filter is not needed")
; proc_filter= (function _ -> failwith "proc_filter is not needed") }
| _
-> failwith "This mock only supports Eradicate"
in
let create_test analyzer (exp_introduced, exp_fixed, exp_preexisting) _ =
let null_dereference = Localise.to_issue_id Localise.null_dereference in
let current_report =
[ create_fake_jsonbug ~bug_type:"bug_type_1" ~file:"file_1.java" ~hash:1 ()
; create_fake_jsonbug ~bug_type:null_dereference ~file:"file_2.java" ~hash:2 ()
; create_fake_jsonbug ~bug_type:"bug_type_1" ~file:"file_4.java" ~hash:4 () ]
in
let previous_report =
[ create_fake_jsonbug ~bug_type:"bug_type_1" ~file:"file_1.java" ~hash:11 ()
; create_fake_jsonbug ~bug_type:null_dereference ~file:"file_3.java" ~hash:3 ()
; create_fake_jsonbug ~bug_type:"bug_type_1" ~file:"file_4.java" ~hash:4 () ]
in
let diff = Differential.of_reports ~current_report ~previous_report in
let diff' =
DifferentialFilters.VISIBLE_FOR_TESTING_DO_NOT_USE_DIRECTLY.resolve_infer_eradicate_conflict
analyzer fake_filters_factory diff
in
assert_equal ~pp_diff:(pp_diff_of_int_list "Hashes of introduced") exp_introduced
(sorted_hashes_of_issues diff'.introduced) ;
assert_equal ~pp_diff:(pp_diff_of_int_list "Hashes of fixed") exp_fixed
(sorted_hashes_of_issues diff'.fixed) ;
assert_equal ~pp_diff:(pp_diff_of_int_list "Hashes of preexisting") exp_preexisting
(sorted_hashes_of_issues diff'.preexisting)
in
(* [(test_name, analyzer, expected_hashes); ...] *)
[ ( "test_resolve_infer_eradicate_conflict_runs_with_infer_analyzer"
, Config.BiAbduction
, ([1], [11], [4]) )
; ( "test_resolve_infer_eradicate_conflict_skips_with_checkers_analyzer"
, Config.Checkers
, ([1; 2], [3; 11], [4]) )
; ( "test_resolve_infer_eradicate_conflict_skips_with_linters_analyzer"
, Config.Linters
, ([1; 2], [3; 11], [4]) ) ]
|> List.map ~f:(fun (name, analyzer, expected_output) ->
name >:: create_test analyzer expected_output )
let test_interesting_paths_filter =
let report =
[ create_fake_jsonbug ~bug_type:"bug_type_1" ~file:"file_1.java" ~hash:1 ()
@ -403,5 +355,5 @@ let tests =
"differential_filters_suite"
>::: test_file_renamings_from_json @ test_file_renamings_find_previous
@ test_relative_complements @ test_skip_anonymous_class_renamings
@ test_resolve_infer_eradicate_conflict @ test_interesting_paths_filter
@ test_interesting_paths_filter
@ [test_skip_duplicated_types_on_filenames; test_value_of_qualifier_tag]

@ -1,6 +0,0 @@
{
"eradicate-whitelist-path-regex": [
"src/com"
],
"resolve-infer-eradicate-conflict": true
}

@ -1,26 +0,0 @@
# Copyright (c) 2017 - present Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
# E2E test involving the resolve_infer_eradicate_conflict filter
TESTS_DIR = ../..
DIFFERENTIAL_ARGS =
CLEAN_EXTRA = src/com/example/Diff*.java src/Diff*.java *.class com/
include ../../differential.make
$(CURRENT_REPORT): .inferconfig
$(QUIET)$(COPY) src/com/example/DiffExample.java.current src/com/example/DiffExample.java
$(QUIET)$(COPY) src/DiffExampleTwo.java.current src/DiffExampleTwo.java
$(QUIET)$(call silent_on_success,Testing Differential resolves Infer/Eradicate conflicts: current,\
$(INFER_BIN) \
-o $(CURRENT_DIR) -- $(JAVAC) src/com/example/DiffExample.java src/DiffExampleTwo.java)
$(PREVIOUS_REPORT): .inferconfig
$(QUIET)$(COPY) src/com/example/DiffExample.java.previous src/com/example/DiffExample.java
$(QUIET)$(call silent_on_success,Testing Differential resolves Infer/Eradicate conflicts: previous,\
$(INFER_BIN) -o $(PREVIOUS_DIR) -- $(JAVAC) src/com/example/DiffExample.java)

@ -1,2 +0,0 @@
NULL_DEREFERENCE, src/DiffExampleTwo.java, void DiffExampleTwo.doSomethingTwo(), 1, DiffExampleTwo.doSomethingTwo():void.d8149869686ac2ef26a75ac4829094a7, DiffExampleTwo.doSomethingTwo():void
RESOURCE_LEAK, src/com/example/DiffExample.java, void DiffExample.openResource(), 5, com.example.DiffExample.openResource():void.75390f44594cb95db15fe8db9d07c4be, com.example.DiffExample.openResource():void

@ -1,19 +0,0 @@
/*
* Copyright (c) 2017 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
// This example tests the resolve_infer_eradicate_conflict filter
class DiffExampleTwo {
private String genString() {
return null;
}
private void doSomethingTwo() {
int i = this.genString().length();
}
}

@ -1,35 +0,0 @@
/*
* Copyright (c) 2017 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.example;
import java.io.FileInputStream;
// This example tests the resolve_infer_eradicate_conflict filter
class DiffExample {
private String genString() {
return null;
}
private int triggerNpe() {
return this.genString().length();
}
private void openResource() {
try {
FileInputStream fis = new FileInputStream("AAA");
fis.read();
fis.close();
} catch (Exception exc) {
// do nothing
}
}
}

@ -1,24 +0,0 @@
/*
* Copyright (c) 2017 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.example;
import java.io.FileInputStream;
// This example tests the resolve_infer_eradicate_conflict filter
class DiffExample {
private String genString() {
return null;
}
private int triggerNpe() {
return this.genString().length();
}
}
Loading…
Cancel
Save