diff --git a/Makefile b/Makefile index b9191bfe3..8e335ac64 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ BUILD_SYSTEMS_TESTS += \ annotation-reachability-sources-override \ assembly \ backtrack_level \ - ck_analytics ck_imports \ + ck_imports \ clang_compilation_db_escaped clang_compilation_db_relpath \ clang_multiple_files \ clang_translation \ @@ -42,7 +42,6 @@ BUILD_SYSTEMS_TESTS += \ project_root_rel \ reactive \ results_xml \ - run_hidden_linters \ tracebugs \ utf8_in_procname \ export_changed_functions \ diff --git a/infer/documentation/issues/COMPONENT_FACTORY_FUNCTION.md b/infer/documentation/issues/COMPONENT_FACTORY_FUNCTION.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/infer/documentation/issues/COMPONENT_WITH_UNCONVENTIONAL_SUPERCLASS.md b/infer/documentation/issues/COMPONENT_WITH_UNCONVENTIONAL_SUPERCLASS.md deleted file mode 100644 index 7852627d4..000000000 --- a/infer/documentation/issues/COMPONENT_WITH_UNCONVENTIONAL_SUPERCLASS.md +++ /dev/null @@ -1 +0,0 @@ -[Doc in ComponentKit page](http://componentkit.org/docs/never-subclass-components) diff --git a/infer/man/man1/infer-capture.txt b/infer/man/man1/infer-capture.txt index ad99f8e2f..ada78ae1c 100644 --- a/infer/man/man1/infer-capture.txt +++ b/infer/man/man1/infer-capture.txt @@ -228,11 +228,6 @@ CLANG OPTIONS escaped for the shell, eg coming from Xcode (can be specified multiple times) - --compute-analytics - Activates: Emit analytics as info-level issues, like component kit - line count and component kit file cyclomatic complexity - (Conversely: --no-compute-analytics) - --no-cxx Deactivates: Analyze C++ methods (Conversely: --cxx) diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index 25f3f484a..8f50b25fa 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -232,11 +232,6 @@ OPTIONS escaped for the shell, eg coming from Xcode (can be specified multiple times) See also infer-capture(1). - --compute-analytics - Activates: Emit analytics as info-level issues, like component kit - line count and component kit file cyclomatic complexity - (Conversely: --no-compute-analytics) See also infer-capture(1) and infer-run(1). - --config-checks-between-markers Activates: checker config-checks-between-markers: [EXPERIMENTAL] Collects config checks between marker start and end. (Conversely: @@ -383,12 +378,7 @@ OPTIONS CHECKERS_IMMUTABLE_CAST (enabled by default), CHECKERS_PRINTF_ARGS (enabled by default), CLASS_CAST_EXCEPTION (disabled by default), - COMPONENT_FACTORY_FUNCTION (enabled by default), - COMPONENT_FILE_CYCLOMATIC_COMPLEXITY (enabled by default), - COMPONENT_FILE_LINE_COUNT (disabled by default), - COMPONENT_INITIALIZER_WITH_SIDE_EFFECTS (enabled by default), COMPONENT_WITH_MULTIPLE_FACTORY_METHODS (enabled by default), - COMPONENT_WITH_UNCONVENTIONAL_SUPERCLASS (enabled by default), CONDITION_ALWAYS_FALSE (disabled by default), CONDITION_ALWAYS_TRUE (disabled by default), CONFIG_CHECKS_BETWEEN_MARKERS (disabled by default), diff --git a/infer/man/man1/infer-report.txt b/infer/man/man1/infer-report.txt index ab33ecf58..4173d4c6a 100644 --- a/infer/man/man1/infer-report.txt +++ b/infer/man/man1/infer-report.txt @@ -108,12 +108,7 @@ OPTIONS CHECKERS_IMMUTABLE_CAST (enabled by default), CHECKERS_PRINTF_ARGS (enabled by default), CLASS_CAST_EXCEPTION (disabled by default), - COMPONENT_FACTORY_FUNCTION (enabled by default), - COMPONENT_FILE_CYCLOMATIC_COMPLEXITY (enabled by default), - COMPONENT_FILE_LINE_COUNT (disabled by default), - COMPONENT_INITIALIZER_WITH_SIDE_EFFECTS (enabled by default), COMPONENT_WITH_MULTIPLE_FACTORY_METHODS (enabled by default), - COMPONENT_WITH_UNCONVENTIONAL_SUPERCLASS (enabled by default), CONDITION_ALWAYS_FALSE (disabled by default), CONDITION_ALWAYS_TRUE (disabled by default), CONFIG_CHECKS_BETWEEN_MARKERS (disabled by default), diff --git a/infer/man/man1/infer-run.txt b/infer/man/man1/infer-run.txt index 477f14a7f..68d8f4ce3 100644 --- a/infer/man/man1/infer-run.txt +++ b/infer/man/man1/infer-run.txt @@ -160,11 +160,6 @@ BUCK OPTIONS --buck-targets-blacklist +regex Skip capture of buck targets matched by the specified regular expression. Only valid for --buck-compilation-database. -CLANG OPTIONS - --compute-analytics - Activates: Emit analytics as info-level issues, like component kit - line count and component kit file cyclomatic complexity - (Conversely: --no-compute-analytics) JAVA OPTIONS --capture-blacklist regex Skip capture of files matched by the specified OCaml regular diff --git a/infer/man/man1/infer.txt b/infer/man/man1/infer.txt index 5e2e113ec..e5d24ed04 100644 --- a/infer/man/man1/infer.txt +++ b/infer/man/man1/infer.txt @@ -232,11 +232,6 @@ OPTIONS escaped for the shell, eg coming from Xcode (can be specified multiple times) See also infer-capture(1). - --compute-analytics - Activates: Emit analytics as info-level issues, like component kit - line count and component kit file cyclomatic complexity - (Conversely: --no-compute-analytics) See also infer-capture(1) and infer-run(1). - --config-checks-between-markers Activates: checker config-checks-between-markers: [EXPERIMENTAL] Collects config checks between marker start and end. (Conversely: @@ -383,12 +378,7 @@ OPTIONS CHECKERS_IMMUTABLE_CAST (enabled by default), CHECKERS_PRINTF_ARGS (enabled by default), CLASS_CAST_EXCEPTION (disabled by default), - COMPONENT_FACTORY_FUNCTION (enabled by default), - COMPONENT_FILE_CYCLOMATIC_COMPLEXITY (enabled by default), - COMPONENT_FILE_LINE_COUNT (disabled by default), - COMPONENT_INITIALIZER_WITH_SIDE_EFFECTS (enabled by default), COMPONENT_WITH_MULTIPLE_FACTORY_METHODS (enabled by default), - COMPONENT_WITH_UNCONVENTIONAL_SUPERCLASS (enabled by default), CONDITION_ALWAYS_FALSE (disabled by default), CONDITION_ALWAYS_TRUE (disabled by default), CONFIG_CHECKS_BETWEEN_MARKERS (disabled by default), diff --git a/infer/src/al/ALIssues.ml b/infer/src/al/ALIssues.ml index 74cf0ca0f..9b2ae5e3a 100644 --- a/infer/src/al/ALIssues.ml +++ b/infer/src/al/ALIssues.ml @@ -77,28 +77,14 @@ let single_to_multi checker ctx an = (* List of checkers on decls *that return 0 or 1 issue* *) -let decl_single_checkers_list = - [ ComponentKit.component_with_unconventional_superclass_advice - ; ComponentKit.mutable_local_vars_advice - ; ComponentKit.component_factory_function_advice - ; ComponentKit.component_file_cyclomatic_complexity_info ] - +let decl_single_checkers_list = [ComponentKit.mutable_local_vars_advice] (* List of checkers on decls *) let decl_checkers_list = ComponentKit.component_with_multiple_factory_methods_advice - :: ComponentKit.component_file_line_count_info :: List.map ~f:single_to_multi decl_single_checkers_list -(* List of checkers on stmts *that return 0 or 1 issue* *) -let stmt_single_checkers_list = - [ ComponentKit.component_file_cyclomatic_complexity_info - ; ComponentKit.component_initializer_with_side_effects_advice ] - - -let stmt_checkers_list = List.map ~f:single_to_multi stmt_single_checkers_list - let evaluate_place_holder ph an = match ph with | "%ivar_name%" -> @@ -515,7 +501,7 @@ let fill_issue_desc_info_and_log context ~witness ~current_node (issue_desc : CI (* Calls the set of hard coded checkers (if any) *) let invoke_set_of_hard_coded_checkers_an context (an : Ctl_parser_types.ast_node) = - let checkers = match an with Decl _ -> decl_checkers_list | Stmt _ -> stmt_checkers_list in + let checkers = match an with Decl _ -> decl_checkers_list | Stmt _ -> [] in List.iter ~f:(fun checker -> let issue_desc_list = checker context an in diff --git a/infer/src/al/ALUtils.mli b/infer/src/al/ALUtils.mli index f4066fdae..23248a886 100644 --- a/infer/src/al/ALUtils.mli +++ b/infer/src/al/ALUtils.mli @@ -7,8 +7,6 @@ open! IStd -val location_from_stmt : CLintersContext.context -> Clang_ast_t.stmt -> Location.t - val location_from_dinfo : CLintersContext.context -> Clang_ast_t.decl_info -> Location.t val location_from_an : CLintersContext.context -> Ctl_parser_types.ast_node -> Location.t diff --git a/infer/src/al/ComponentKit.ml b/infer/src/al/ComponentKit.ml index f567cde9c..15411fe77 100644 --- a/infer/src/al/ComponentKit.ml +++ b/infer/src/al/ComponentKit.ml @@ -6,7 +6,6 @@ *) open! IStd -open PolyVariantEqual module MF = MarkupFormatter let get_source_range an = @@ -163,101 +162,6 @@ let mutable_local_vars_advice context an = with CFrontend_errors.IncorrectAssumption _ -> None -(* Should only be called with a VarDecl *) - -(** Catches functions that should be composite components. - http://componentkit.org/docs/break-out-composites.html - - Any static function that returns a subclass of CKComponent will be flagged. *) -let component_factory_function_advice context an = - let is_component_if decl = - CAst_utils.is_objc_if_descendant decl [CFrontend_config.ckcomponent_cl] - in - if is_ck_context context an then - match an with - | Ctl_parser_types.Decl - (Clang_ast_t.FunctionDecl (decl_info, _, (qual_type : Clang_ast_t.qual_type), _)) -> - let objc_interface = CAst_utils.qual_type_to_objc_interface qual_type in - if is_component_if objc_interface then - Some - { CIssue.issue_type= IssueType.component_factory_function - ; severity= Advice - ; mode= Off - ; description= "Break out composite components" - ; suggestion= - Some - "Prefer subclassing CKCompositeComponent to static helper functions that return \ - a CKComponent subclass." - ; loc= ALUtils.location_from_dinfo context decl_info } - else None - | _ -> - None - else None - - -(* Should only be called with FunctionDecl *) - -(** Components should not inherit from each other. They should instead inherit from CKComponent, - CKCompositeComponent, or CKStatefulViewComponent. (Similar rule applies to component - controllers.) *) -let component_with_unconventional_superclass_advice context an = - let check_interface if_decl = - match if_decl with - | Clang_ast_t.ObjCInterfaceDecl (_, _, _, _, _) -> - if is_component_or_controller_if (Some if_decl) then - let superclass_name = - match CAst_utils.get_super_if (Some if_decl) with - | Some (Clang_ast_t.ObjCInterfaceDecl (_, named_decl_info, _, _, _)) -> - Some named_decl_info.ni_name - | _ -> - None - in - let has_conventional_superclass = - let open CFrontend_config in - match superclass_name with - | Some name - when List.mem ~equal:String.equal - [ ckcomponent_cl - ; ckcomponentcontroller_cl - ; "CKCompositeComponent" - ; "CKLayoutComponent" - ; "CKRenderComponent" - ; "CKStatefulViewComponent" - ; "CKStatefulViewComponentController" - ; "NTNativeTemplateComponent" ] - name -> - true - | _ -> - false - in - let condition = - is_component_or_controller_if (Some if_decl) && not has_conventional_superclass - in - if condition then - Some - { CIssue.issue_type= IssueType.component_with_unconventional_superclass - ; severity= Advice - ; mode= On - ; description= "Never Subclass Components" - ; suggestion= Some "Instead, create a new subclass of CKCompositeComponent." - ; loc= ALUtils.location_from_decl context if_decl } - else None - else None - | _ -> - assert false - in - match an with - | Ctl_parser_types.Decl (Clang_ast_t.ObjCImplementationDecl (_, _, _, _, impl_decl_info)) -> - let if_decl_opt = - CAst_utils.get_decl_opt_with_decl_ref_opt impl_decl_info.oidi_class_interface - in - if Option.is_some if_decl_opt && is_ck_context context an then - check_interface (Option.value_exn if_decl_opt) - else None - | _ -> - None - - (** Components should only have one factory method. (They could technically have none if they re-use the parent class's factory method.) @@ -310,152 +214,3 @@ let component_with_multiple_factory_methods_advice context an = match if_decl_opt with Some d when is_ck_context context an -> check_interface d | _ -> [] ) | _ -> [] - - -let in_ck_class (context : CLintersContext.context) = - Option.value_map ~f:is_component_or_controller_descendant_impl ~default:false - context.current_objc_class - && CGeneral_utils.is_objc_extension context.translation_unit_context - - -let is_in_factory_method (context : CLintersContext.context) = - let interface_decl_opt = - match context.current_objc_class with - | Some (ObjCImplementationDecl (_, _, _, _, impl_decl_info)) -> - CAst_utils.get_decl_opt_with_decl_ref_opt impl_decl_info.oidi_class_interface - | _ -> - None - in - let methods_to_check = - match context.current_method with - | Some current_method -> - current_method :: context.parent_methods - | None -> - context.parent_methods - in - List.exists methods_to_check ~f:(fun method_decl -> - CAst_utils.is_objc_factory_method ~class_decl:interface_decl_opt - ~method_decl:(Some method_decl) ) - - -(** Components shouldn't have side-effects in its initializer. - - http://componentkit.org/docs/no-side-effects.html - - The only current way we look for side-effects is by looking for asynchronous execution - (dispatch_async, dispatch_after) and execution that relies on other threads (dispatch_sync). - Other side-effects, like reading of global variables, is not checked by this analyzer, although - still an infraction of the rule. *) -let rec component_initializer_with_side_effects_advice_ (context : CLintersContext.context) - call_stmt = - let condition = - in_ck_class context && is_in_factory_method context - && - match context.current_objc_class with - | Some d -> - is_in_main_file context.translation_unit_context (Ctl_parser_types.Decl d) - | None -> - false - in - if condition then - match call_stmt with - | Clang_ast_t.ImplicitCastExpr (_, stmt :: _, _, _) -> - component_initializer_with_side_effects_advice_ context stmt - | Clang_ast_t.DeclRefExpr (_, _, _, decl_ref_expr_info) -> ( - let refs = [decl_ref_expr_info.drti_decl_ref; decl_ref_expr_info.drti_found_decl_ref] in - match List.find_map ~f:CAst_utils.name_of_decl_ref_opt refs with - | Some "dispatch_after" | Some "dispatch_async" | Some "dispatch_sync" -> - Some - { CIssue.issue_type= IssueType.component_initializer_with_side_effects - ; severity= Advice - ; mode= On - ; description= "No Side-effects" - ; suggestion= - Some "Your +new method should not modify any global variables or global state." - ; loc= ALUtils.location_from_stmt context call_stmt } - | _ -> - None ) - | _ -> - None - else None - - -let component_initializer_with_side_effects_advice (context : CLintersContext.context) an = - match an with - | Ctl_parser_types.Stmt (CallExpr (_, called_func_stmt :: _, _)) -> - component_initializer_with_side_effects_advice_ context called_func_stmt - | _ -> - None - - -(* only to be called in CallExpr *) - -(** Returns one issue per line of code, with the column set to 0. - - This still needs to be in infer b/c only files that have a valid component kit class impl should - be analyzed. *) -let component_file_line_count_info (context : CLintersContext.context) dec = - let condition = Config.compute_analytics && context.is_ck_translation_unit in - match dec with - | Ctl_parser_types.Decl (Clang_ast_t.TranslationUnitDecl _) when condition -> - let source_file = context.translation_unit_context.CFrontend_config.source_file in - let line_count = SourceFile.line_count source_file in - List.map - ~f:(fun i -> - { CIssue.issue_type= IssueType.component_file_line_count - ; severity= Info - ; mode= Off - ; description= "Line count analytics" - ; suggestion= None - ; loc= {Location.line= i; Location.col= 0; Location.file= source_file} } ) - (List.range 1 line_count ~start:`inclusive ~stop:`inclusive) - | _ -> - [] - - -(** Computes a component file's cyclomatic complexity. - - Somewhat borrowed from - https://github.com/oclint/oclint/blob/5889b5ec168185513ba69ce83821ea1cc8e63fbe - /oclint-metrics/lib/CyclomaticComplexityMetric.cpp *) -let component_file_cyclomatic_complexity_info (context : CLintersContext.context) an = - let is_cyclo_stmt stmt = - match stmt with - | Clang_ast_t.IfStmt _ - | Clang_ast_t.ForStmt _ - | Clang_ast_t.ObjCForCollectionStmt _ - | Clang_ast_t.CXXForRangeStmt _ - | Clang_ast_t.WhileStmt _ - | Clang_ast_t.DoStmt _ - | Clang_ast_t.CaseStmt _ - | Clang_ast_t.ObjCAtCatchStmt _ - | Clang_ast_t.CXXCatchStmt _ - | Clang_ast_t.ConditionalOperator _ -> - true - | Clang_ast_t.BinaryOperator (_, _, _, boi) -> - List.mem ~equal:( = ) [`LAnd; `LOr] boi.Clang_ast_t.boi_kind - | _ -> - false - in - let cyclo_loc_opt an = - match an with - | Ctl_parser_types.Stmt stmt - when Config.compute_analytics && is_cyclo_stmt stmt && is_ck_context context an -> - Some (ALUtils.location_from_stmt context stmt) - | Ctl_parser_types.Decl (Clang_ast_t.TranslationUnitDecl _ as d) - when Config.compute_analytics && context.is_ck_translation_unit -> - Some (ALUtils.location_from_decl context d) - | _ -> - None - in - match cyclo_loc_opt an with - | Some loc -> - Some - { CIssue.issue_type= IssueType.component_file_cyclomatic_complexity - ; severity= Info - ; mode= Off - ; description= "Cyclomatic Complexity Incremental Marker" - ; suggestion= None - ; loc } - | _ -> - None diff --git a/infer/src/al/ComponentKit.mli b/infer/src/al/ComponentKit.mli index 87b290eef..59f76edf2 100644 --- a/infer/src/al/ComponentKit.mli +++ b/infer/src/al/ComponentKit.mli @@ -16,20 +16,5 @@ val contains_ck_impl : Clang_ast_t.decl list -> bool val mutable_local_vars_advice : CLintersContext.context -> Ctl_parser_types.ast_node -> CIssue.t option -val component_factory_function_advice : - CLintersContext.context -> Ctl_parser_types.ast_node -> CIssue.t option - -val component_with_unconventional_superclass_advice : - CLintersContext.context -> Ctl_parser_types.ast_node -> CIssue.t option - val component_with_multiple_factory_methods_advice : CLintersContext.context -> Ctl_parser_types.ast_node -> CIssue.t list - -val component_initializer_with_side_effects_advice : - CLintersContext.context -> Ctl_parser_types.ast_node -> CIssue.t option - -val component_file_line_count_info : - CLintersContext.context -> Ctl_parser_types.ast_node -> CIssue.t list - -val component_file_cyclomatic_complexity_info : - CLintersContext.context -> Ctl_parser_types.ast_node -> CIssue.t option diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 7dbccda96..14cdfc6c8 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -897,13 +897,6 @@ and compilation_database_escaped = from Xcode (can be specified multiple times)" -and compute_analytics = - CLOpt.mk_bool ~long:"compute-analytics" ~default:false - ~in_help:InferCommand.[(Capture, manual_clang); (Run, manual_clang)] - "Emit analytics as info-level issues, like component kit line count and component kit file \ - cyclomatic complexity" - - (** Continue the capture for reactive mode: If a procedure was changed beforehand, keep the changed marking. *) and continue = @@ -2675,8 +2668,6 @@ and clang_libcxx_include_to_override_regex = !clang_libcxx_include_to_override_r and classpath = !classpath -and compute_analytics = !compute_analytics - and continue_analysis = !continue_analysis and continue_capture = !continue diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index a52c6a505..0461d0b9f 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -222,8 +222,6 @@ val clang_libcxx_include_to_override_regex : string option val command : InferCommand.t -val compute_analytics : bool - val continue_analysis : bool val continue_capture : bool diff --git a/infer/src/base/IssueType.ml b/infer/src/base/IssueType.ml index 22fc9c946..bcea79b63 100644 --- a/infer/src/base/IssueType.ml +++ b/infer/src/base/IssueType.ml @@ -374,37 +374,12 @@ let class_cast_exception = register_hidden ~enabled:false ~id:"CLASS_CAST_EXCEPTION" Error Biabduction -let component_factory_function = - register ~id:"COMPONENT_FACTORY_FUNCTION" Advice Linters - ~user_documentation:[%blob "../../documentation/issues/COMPONENT_FACTORY_FUNCTION.md"] - - -let component_file_cyclomatic_complexity = - register ~id:"COMPONENT_FILE_CYCLOMATIC_COMPLEXITY" Info Linters ~user_documentation:"" - - -let component_file_line_count = - register ~enabled:false ~id:"COMPONENT_FILE_LINE_COUNT" Info Linters ~user_documentation:"" - - -let component_initializer_with_side_effects = - register ~id:"COMPONENT_INITIALIZER_WITH_SIDE_EFFECTS" Advice Linters - ~user_documentation: - [%blob "../../documentation/issues/COMPONENT_INITIALIZER_WITH_SIDE_EFFECTS.md"] - - let component_with_multiple_factory_methods = register ~id:"COMPONENT_WITH_MULTIPLE_FACTORY_METHODS" Advice Linters ~user_documentation: [%blob "../../documentation/issues/COMPONENT_WITH_MULTIPLE_FACTORY_METHODS.md"] -let component_with_unconventional_superclass = - register ~id:"COMPONENT_WITH_UNCONVENTIONAL_SUPERCLASS" Advice Linters - ~user_documentation: - [%blob "../../documentation/issues/COMPONENT_WITH_UNCONVENTIONAL_SUPERCLASS.md"] - - let condition_always_false = register ~enabled:false ~id:"CONDITION_ALWAYS_FALSE" Warning BufferOverrunChecker ~user_documentation:"A condition expression is **always** evaluated to false." diff --git a/infer/src/base/IssueType.mli b/infer/src/base/IssueType.mli index 4f52a24f2..145efca64 100644 --- a/infer/src/base/IssueType.mli +++ b/infer/src/base/IssueType.mli @@ -125,18 +125,8 @@ val class_cast_exception : t val complexity_increase : kind:CostKind.t -> is_on_ui_thread:bool -> t -val component_factory_function : t - -val component_file_cyclomatic_complexity : t - -val component_file_line_count : t - -val component_initializer_with_side_effects : t - val component_with_multiple_factory_methods : t -val component_with_unconventional_superclass : t - val condition_always_false : t val condition_always_true : t diff --git a/infer/src/base/SourceFile.ml b/infer/src/base/SourceFile.ml index 4daff4193..de0c4d8f3 100644 --- a/infer/src/base/SourceFile.ml +++ b/infer/src/base/SourceFile.ml @@ -9,11 +9,6 @@ open! IStd open PolyVariantEqual module L = Logging -let count_newlines (path : string) : int = - let f file = In_channel.fold_lines file ~init:0 ~f:(fun i _ -> i + 1) in - In_channel.with_file path ~f - - type t = | Invalid of {ml_source_file: string} | Absolute of string @@ -93,11 +88,6 @@ let to_abs_path fname = path -let line_count source_file = - let abs_path = to_abs_path source_file in - count_newlines abs_path - - let to_rel_path fname = match fname with RelativeProjectRoot path -> path | _ -> to_abs_path fname let invalid ml_source_file = Invalid {ml_source_file} diff --git a/infer/src/base/SourceFile.mli b/infer/src/base/SourceFile.mli index 8e01d5ed3..1c174b1a2 100644 --- a/infer/src/base/SourceFile.mli +++ b/infer/src/base/SourceFile.mli @@ -44,9 +44,6 @@ val is_biabduction_model : t -> bool val is_under_project_root : t -> bool (** Returns true if the file is in project root *) -val line_count : t -> int -(** compute line count of a source file *) - val of_header : ?warn_on_error:bool -> t -> t option (** Return approximate source file corresponding to the parameter if it's header file and file exists. returns None otherwise. WARNING: If warn_on_error is false, no warning will be shown diff --git a/infer/src/clang/cAst_utils.ml b/infer/src/clang/cAst_utils.ml index 7bd78a88f..c70e701a3 100644 --- a/infer/src/clang/cAst_utils.ml +++ b/infer/src/clang/cAst_utils.ml @@ -449,14 +449,6 @@ let is_objc_factory_method ~class_decl:interface_decl ~method_decl:meth_decl_opt false -let name_of_decl_ref_opt (decl_ref_opt : Clang_ast_t.decl_ref option) = - match decl_ref_opt with - | Some decl_ref -> ( - match decl_ref.dr_name with Some named_decl_info -> Some named_decl_info.ni_name | _ -> None ) - | _ -> - None - - let type_of_decl decl = let open Clang_ast_t in match decl with diff --git a/infer/src/clang/cAst_utils.mli b/infer/src/clang/cAst_utils.mli index 98ee5f719..804e13254 100644 --- a/infer/src/clang/cAst_utils.mli +++ b/infer/src/clang/cAst_utils.mli @@ -124,8 +124,6 @@ val is_objc_factory_method : class_decl:Clang_ast_t.decl option -> method_decl:Clang_ast_t.decl option -> bool (** A class method that returns an instance of the class is a factory method. *) -val name_of_decl_ref_opt : Clang_ast_t.decl_ref option -> string option - val sil_annot_of_type : Clang_ast_t.qual_type -> Annot.Item.t val type_of_decl : Clang_ast_t.decl -> Clang_ast_t.type_ptr option diff --git a/infer/tests/build_systems/ck_analytics/Makefile b/infer/tests/build_systems/ck_analytics/Makefile deleted file mode 100644 index 4e8453ca5..000000000 --- a/infer/tests/build_systems/ck_analytics/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -TESTS_DIR = ../.. - -CODETOANALYZE_DIR = ../codetoanalyze/componentkit - -CLANG_OPTIONS = -x objective-c++ -std=c++11 -c -fblocks -INFER_OPTIONS = --no-capture --linters-only --no-filtering --compute-analytics --project-root $(CODETOANALYZE_DIR) -INFERPRINT_OPTIONS = --issues-tests - -SOURCES = $(CODETOANALYZE_DIR)/TestComponentKitAnalytics.mm - -include $(TESTS_DIR)/clang.make diff --git a/infer/tests/build_systems/ck_analytics/issues.exp b/infer/tests/build_systems/ck_analytics/issues.exp deleted file mode 100644 index 0ff1d40db..000000000 --- a/infer/tests/build_systems/ck_analytics/issues.exp +++ /dev/null @@ -1,25 +0,0 @@ -TestComponentKitAnalytics.mm, Linters_dummy_method, -1, COMPONENT_FILE_CYCLOMATIC_COMPLEXITY, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 1, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 2, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 3, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 4, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 5, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 6, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 7, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 8, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 9, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 10, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 11, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 12, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 13, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 14, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 15, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 16, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 17, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 18, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 19, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 20, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 21, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, Linters_dummy_method, 22, COMPONENT_FILE_LINE_COUNT, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, SomeClass.new, 14, COMPONENT_FILE_CYCLOMATIC_COMPLEXITY, no_bucket, INFO, [] -TestComponentKitAnalytics.mm, SomeClass.new, 16, COMPONENT_FILE_CYCLOMATIC_COMPLEXITY, no_bucket, INFO, [] diff --git a/infer/tests/build_systems/run_hidden_linters/Makefile b/infer/tests/build_systems/run_hidden_linters/Makefile deleted file mode 100644 index 8a3419753..000000000 --- a/infer/tests/build_systems/run_hidden_linters/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -# this test checks that hidden linters do not run without --no-filtering, -# regardless of what other flags are used to enable them (e.g. --compute-analytics) - -TESTS_DIR = ../.. - -CODETOANALYZE_DIR = ../codetoanalyze/componentkit - -CLANG_OPTIONS = -x objective-c++ -std=c++11 -c -fblocks -INFER_OPTIONS = --no-capture --linters-only --compute-analytics --project-root $(CODETOANALYZE_DIR) -INFERPRINT_OPTIONS = --issues-tests - -SOURCES = $(CODETOANALYZE_DIR)/TestComponentKitAnalytics.mm - -include $(TESTS_DIR)/clang.make diff --git a/infer/tests/build_systems/run_hidden_linters/issues.exp b/infer/tests/build_systems/run_hidden_linters/issues.exp deleted file mode 100644 index e69de29bb..000000000 diff --git a/infer/tests/codetoanalyze/objcpp/linters/componentkit/FactoryFunctionTest.mm b/infer/tests/codetoanalyze/objcpp/linters/componentkit/FactoryFunctionTest.mm deleted file mode 100644 index c219d6367..000000000 --- a/infer/tests/codetoanalyze/objcpp/linters/componentkit/FactoryFunctionTest.mm +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import - -#import "FakeComponentKitHeader.h" - -// Fake "component" (i.e. shouldn't fire for functions that return these) -@interface BarComponent : NSObject -@end - -@interface FooComponent : CKCompositeComponent -@end - -static FooComponent* ExampleFunctionBeforeImpl() { return nil; } - -static BarComponent* ExampleSkipFunctionBeforeImpl() { return nil; } - -@implementation FooComponent - -+ (instancetype)newWithObject:(NSObject*)obj { -} -static FooComponent* ExampleFunctionInsideImpl() { return nil; } - -static BarComponent* ExampleSkipFunctionInsideImpl() { return nil; } - -@end - -static FooComponent* ExampleFunctionAfterImpl() { return nil; } - -static BarComponent* ExampleSkipFunctionAfterImpl() { return nil; } diff --git a/infer/tests/codetoanalyze/objcpp/linters/componentkit/InitializerWithSideEffectTest.mm b/infer/tests/codetoanalyze/objcpp/linters/componentkit/InitializerWithSideEffectTest.mm deleted file mode 100644 index 44db6a515..000000000 --- a/infer/tests/codetoanalyze/objcpp/linters/componentkit/InitializerWithSideEffectTest.mm +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import - -#import "FakeComponentKitHeader.h" - -@interface FooComponent : CKCompositeComponent -@end - -@implementation FooComponent -+ (instancetype)newDerp { - dispatch_async( // error - dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), - ^{ - // do something - }); - dispatch_sync( // error - dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), - ^{ - // do something - }); - dispatch_after( // error - DISPATCH_TIME_NOW, - dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), - ^{ - // do something - }); - // make sure nested things are caught - ^{ - dispatch_sync( // error - dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), - ^{ - ^{ - dispatch_async( // error - dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), - ^{ - // do something - }); - }(); - }); - }(); - return nil; -} - -- (void)derp { - // not an error (only run on factory functions) - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), - ^{ - // do something - }); -} -@end - -@interface BarComponent : NSObject // not a real component -@end - -@implementation BarComponent -+ (instancetype)newDerp { - // not an error (only run on actual components) - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), - ^{ - // do something - }); - return nil; -} -@end diff --git a/infer/tests/codetoanalyze/objcpp/linters/componentkit/UnconventionalSuperclassTest.h b/infer/tests/codetoanalyze/objcpp/linters/componentkit/UnconventionalSuperclassTest.h deleted file mode 100644 index 6003db22b..000000000 --- a/infer/tests/codetoanalyze/objcpp/linters/componentkit/UnconventionalSuperclassTest.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import - -#import "FakeComponentKitHeader.h" - -@interface FooComponent : CKCompositeComponent // good -@end - -@interface BarComponent : FooComponent // bad -@end - -@interface NTNativeTemplateComponent : CKCompositeComponent // fake NT -@end - -@interface NativeTemplateComponent : NTNativeTemplateComponent // good -@end - -@interface RenderFooComponent : CKRenderComponent // good -@end - -@interface LayoutFooComponent : CKLayoutComponent // good -@end diff --git a/infer/tests/codetoanalyze/objcpp/linters/componentkit/UnconventionalSuperclassTest.mm b/infer/tests/codetoanalyze/objcpp/linters/componentkit/UnconventionalSuperclassTest.mm deleted file mode 100644 index f833628c9..000000000 --- a/infer/tests/codetoanalyze/objcpp/linters/componentkit/UnconventionalSuperclassTest.mm +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import - -#import "UnconventionalSuperclassTest.h" - -@implementation FooComponent -@end - -@implementation BarComponent -@end - -@implementation NativeTemplateComponent -@end - -@implementation RenderFooComponent -@end - -@implementation RenderWithChildrenFooComponent -@end - -@implementation RenderLayoutFooComponent -@end - -@implementation RenderLayoutWithChildrenFooComponent -@end diff --git a/infer/tests/codetoanalyze/objcpp/linters/issues.exp b/infer/tests/codetoanalyze/objcpp/linters/issues.exp index 7fd2b57de..97cd86abc 100644 --- a/infer/tests/codetoanalyze/objcpp/linters/issues.exp +++ b/infer/tests/codetoanalyze/objcpp/linters/issues.exp @@ -1,11 +1,3 @@ -codetoanalyze/objcpp/linters/componentkit/FactoryFunctionTest.mm, ExampleFunctionAfterImpl, 33, COMPONENT_FACTORY_FUNCTION, no_bucket, ADVICE, [] -codetoanalyze/objcpp/linters/componentkit/FactoryFunctionTest.mm, ExampleFunctionBeforeImpl, 19, COMPONENT_FACTORY_FUNCTION, no_bucket, ADVICE, [] -codetoanalyze/objcpp/linters/componentkit/FactoryFunctionTest.mm, ExampleFunctionInsideImpl, 27, COMPONENT_FACTORY_FUNCTION, no_bucket, ADVICE, [] -codetoanalyze/objcpp/linters/componentkit/InitializerWithSideEffectTest.mm, FooComponent.newDerp, 17, COMPONENT_INITIALIZER_WITH_SIDE_EFFECTS, no_bucket, ADVICE, [] -codetoanalyze/objcpp/linters/componentkit/InitializerWithSideEffectTest.mm, FooComponent.newDerp, 22, COMPONENT_INITIALIZER_WITH_SIDE_EFFECTS, no_bucket, ADVICE, [] -codetoanalyze/objcpp/linters/componentkit/InitializerWithSideEffectTest.mm, FooComponent.newDerp, 27, COMPONENT_INITIALIZER_WITH_SIDE_EFFECTS, no_bucket, ADVICE, [] -codetoanalyze/objcpp/linters/componentkit/InitializerWithSideEffectTest.mm, objc_block, 35, COMPONENT_INITIALIZER_WITH_SIDE_EFFECTS, no_bucket, ADVICE, [] -codetoanalyze/objcpp/linters/componentkit/InitializerWithSideEffectTest.mm, objc_block, 39, COMPONENT_INITIALIZER_WITH_SIDE_EFFECTS, no_bucket, ADVICE, [] codetoanalyze/objcpp/linters/componentkit/MultipleFactoryMethodsTest.h, Linters_dummy_method, 18, COMPONENT_WITH_MULTIPLE_FACTORY_METHODS, no_bucket, ADVICE, [] codetoanalyze/objcpp/linters/componentkit/MultipleFactoryMethodsTest.h, Linters_dummy_method, 30, COMPONENT_WITH_MULTIPLE_FACTORY_METHODS, no_bucket, ADVICE, [] codetoanalyze/objcpp/linters/componentkit/MultipleFactoryMethodsTest.h, Linters_dummy_method, 53, COMPONENT_WITH_MULTIPLE_FACTORY_METHODS, no_bucket, ADVICE, [] @@ -25,7 +17,6 @@ codetoanalyze/objcpp/linters/componentkit/MutableLocalVariablesTest.mm, FooCompo codetoanalyze/objcpp/linters/componentkit/MutableLocalVariablesTest.mm, FooComponent.newWithString, 62, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE, no_bucket, ADVICE, [] codetoanalyze/objcpp/linters/componentkit/MutableLocalVariablesTest.mm, FooComponent.newWithString, 67, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE, no_bucket, ADVICE, [] codetoanalyze/objcpp/linters/componentkit/MutableLocalVariablesTest.mm, SomeClass.init, 38, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE, no_bucket, ADVICE, [] -codetoanalyze/objcpp/linters/componentkit/UnconventionalSuperclassTest.h, Linters_dummy_method, 15, COMPONENT_WITH_UNCONVENTIONAL_SUPERCLASS, no_bucket, ADVICE, [] codetoanalyze/objcpp/linters/cxx_reference_in_block/block.mm, A.foo, 18, CXX_REFERENCE_CAPTURED_IN_OBJC_BLOCK, no_bucket, ERROR, [] codetoanalyze/objcpp/linters/cxx_reference_in_block/block.mm, A.foo3, 35, CXX_REFERENCE_CAPTURED_IN_OBJC_BLOCK, no_bucket, ERROR, [] codetoanalyze/objcpp/linters/cxx_reference_in_block/block2.mm, both_safe_and_unsafe, 40, CXX_REFERENCE_CAPTURED_IN_OBJC_BLOCK, no_bucket, ERROR, []