diff --git a/Makefile b/Makefile index 96250f19c..962ec899d 100644 --- a/Makefile +++ b/Makefile @@ -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 \ diff --git a/infer/src/backend/DifferentialFilters.ml b/infer/src/backend/DifferentialFilters.ml index 032ff9595..a078c418a 100644 --- a/infer/src/backend/DifferentialFilters.ml +++ b/infer/src/backend/DifferentialFilters.ml @@ -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 diff --git a/infer/src/backend/DifferentialFilters.mli b/infer/src/backend/DifferentialFilters.mli index aff8fd90b..418850f85 100644 --- a/infer/src/backend/DifferentialFilters.mli +++ b/infer/src/backend/DifferentialFilters.mli @@ -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 diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index f4bf9ce86..4f1b76f02 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -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 diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index c166fea49..1e16721bc 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -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 diff --git a/infer/src/unit/DifferentialFiltersTests.ml b/infer/src/unit/DifferentialFiltersTests.ml index 4354f2f0e..267a3c566 100644 --- a/infer/src/unit/DifferentialFiltersTests.ml +++ b/infer/src/unit/DifferentialFiltersTests.ml @@ -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] diff --git a/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/.inferconfig b/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/.inferconfig deleted file mode 100644 index b74a84343..000000000 --- a/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/.inferconfig +++ /dev/null @@ -1,6 +0,0 @@ -{ - "eradicate-whitelist-path-regex": [ - "src/com" - ], - "resolve-infer-eradicate-conflict": true -} diff --git a/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/Makefile b/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/Makefile deleted file mode 100644 index 845244056..000000000 --- a/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/Makefile +++ /dev/null @@ -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) diff --git a/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/fixed.exp b/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/fixed.exp deleted file mode 100644 index e69de29bb..000000000 diff --git a/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/introduced.exp b/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/introduced.exp deleted file mode 100644 index 5c3f4d0fc..000000000 --- a/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/introduced.exp +++ /dev/null @@ -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 diff --git a/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/preexisting.exp b/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/preexisting.exp deleted file mode 100644 index e69de29bb..000000000 diff --git a/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/src/DiffExampleTwo.java.current b/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/src/DiffExampleTwo.java.current deleted file mode 100644 index ee716da18..000000000 --- a/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/src/DiffExampleTwo.java.current +++ /dev/null @@ -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(); - } -} diff --git a/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/src/com/example/DiffExample.java.current b/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/src/com/example/DiffExample.java.current deleted file mode 100644 index 5e9686458..000000000 --- a/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/src/com/example/DiffExample.java.current +++ /dev/null @@ -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 - } - } -} diff --git a/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/src/com/example/DiffExample.java.previous b/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/src/com/example/DiffExample.java.previous deleted file mode 100644 index b63a61fa0..000000000 --- a/infer/tests/build_systems/differential_resolve_infer_eradicate_conflict/src/com/example/DiffExample.java.previous +++ /dev/null @@ -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(); - } -}