diff --git a/infer/man/man1/infer-analyze.txt b/infer/man/man1/infer-analyze.txt index 019df0480..2ac1d1add 100644 --- a/infer/man/man1/infer-analyze.txt +++ b/infer/man/man1/infer-analyze.txt @@ -176,14 +176,6 @@ OPTIONS Activates: Enable --linters and disable all other checkers (Conversely: --no-linters-only) - --litho-graphql-field-access - Activates: [EXPERIMENTAL] GraphQL field access check for Litho - (Conversely: --no-litho-graphql-field-access) - - --litho-graphql-field-access-only - Activates: Enable --litho-graphql-field-access and disable all - other checkers (Conversely: --no-litho-graphql-field-access-only) - --litho-required-props Activates: [EXPERIMENTAL] Required Prop check for Litho (Conversely: --no-litho-required-props) diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index b09939f87..36dfe2fe7 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -728,15 +728,6 @@ OPTIONS in JSON format to stdout (Conversely: --no-linters-validate-syntax-only) See also infer-capture(1). - --litho-graphql-field-access - Activates: [EXPERIMENTAL] GraphQL field access check for Litho - (Conversely: --no-litho-graphql-field-access) See also infer-analyze(1). - - --litho-graphql-field-access-only - Activates: Enable --litho-graphql-field-access and disable all - other checkers (Conversely: --no-litho-graphql-field-access-only) - See also infer-analyze(1). - --litho-required-props Activates: [EXPERIMENTAL] Required Prop check for Litho (Conversely: --no-litho-required-props) See also infer-analyze(1). diff --git a/infer/man/man1/infer.txt b/infer/man/man1/infer.txt index 563bd021d..ba7e467a8 100644 --- a/infer/man/man1/infer.txt +++ b/infer/man/man1/infer.txt @@ -728,15 +728,6 @@ OPTIONS in JSON format to stdout (Conversely: --no-linters-validate-syntax-only) See also infer-capture(1). - --litho-graphql-field-access - Activates: [EXPERIMENTAL] GraphQL field access check for Litho - (Conversely: --no-litho-graphql-field-access) See also infer-analyze(1). - - --litho-graphql-field-access-only - Activates: Enable --litho-graphql-field-access and disable all - other checkers (Conversely: --no-litho-graphql-field-access-only) - See also infer-analyze(1). - --litho-required-props Activates: [EXPERIMENTAL] Required Prop check for Litho (Conversely: --no-litho-required-props) See also infer-analyze(1). diff --git a/infer/src/backend/Payloads.ml b/infer/src/backend/Payloads.ml index 32c5e0e99..18221b6ab 100644 --- a/infer/src/backend/Payloads.ml +++ b/infer/src/backend/Payloads.ml @@ -16,7 +16,6 @@ type t = ; class_loads: ClassLoadsDomain.summary option ; cost: CostDomain.summary option ; lab_resource_leaks: ResourceLeakDomain.summary option - ; litho_graphql_field_access: LithoDomain.t option ; litho_required_props: LithoDomain.t option ; pulse: PulseSummary.t option ; purity: PurityDomain.summary option @@ -44,7 +43,6 @@ let fields = ~buffer_overrun_checker:(fun f -> mk f "BufferOverrunChecker" BufferOverrunCheckerSummary.pp) ~class_loads:(fun f -> mk f "ClassLoads" ClassLoadsDomain.pp_summary) ~cost:(fun f -> mk f "Cost" CostDomain.pp_summary) - ~litho_graphql_field_access:(fun f -> mk f "Litho GraphQL Field Access" LithoDomain.pp) ~litho_required_props:(fun f -> mk f "Litho Required Props" LithoDomain.pp) ~pulse:(fun f -> mk f "Pulse" PulseSummary.pp) ~purity:(fun f -> mk f "Purity" PurityDomain.pp_summary) @@ -71,7 +69,6 @@ let empty = ; class_loads= None ; cost= None ; lab_resource_leaks= None - ; litho_graphql_field_access= None ; litho_required_props= None ; pulse= None ; purity= None diff --git a/infer/src/backend/Payloads.mli b/infer/src/backend/Payloads.mli index aeb579b34..f5fd509af 100644 --- a/infer/src/backend/Payloads.mli +++ b/infer/src/backend/Payloads.mli @@ -20,7 +20,6 @@ include sig ; class_loads: ClassLoadsDomain.summary option ; cost: CostDomain.summary option ; lab_resource_leaks: ResourceLeakDomain.summary option - ; litho_graphql_field_access: LithoDomain.t option ; litho_required_props: LithoDomain.t option ; pulse: PulseSummary.t option ; purity: PurityDomain.summary option diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 4a592c9d2..dd33c3774 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -30,7 +30,6 @@ type checkers = ; impurity: bool ref ; inefficient_keyset_iterator: bool ref ; linters: bool ref - ; litho_graphql_field_access: bool ref ; litho_required_props: bool ref ; liveness: bool ref ; loop_hoisting: bool ref @@ -638,7 +637,6 @@ and { annotation_reachability ; impurity ; inefficient_keyset_iterator ; linters - ; litho_graphql_field_access ; litho_required_props ; liveness ; loop_hoisting @@ -687,9 +685,6 @@ and { annotation_reachability mk_checker ~long:"inefficient-keyset-iterator" ~default:true "Check for inefficient uses of keySet iterator that access both the key and the value." and linters = mk_checker ~long:"linters" ~default:true "syntactic linters" - and litho_graphql_field_access = - mk_checker ~long:"litho-graphql-field-access" - "[EXPERIMENTAL] GraphQL field access check for Litho" and litho_required_props = mk_checker ~long:"litho-required-props" "[EXPERIMENTAL] Required Prop check for Litho" and liveness = @@ -769,7 +764,6 @@ and { annotation_reachability ; impurity ; inefficient_keyset_iterator ; linters - ; litho_graphql_field_access ; litho_required_props ; liveness ; loop_hoisting @@ -2985,8 +2979,6 @@ and linters_ignore_clang_failures = !linters_ignore_clang_failures and linters_validate_syntax_only = !linters_validate_syntax_only -and litho_graphql_field_access = !litho_graphql_field_access - and litho_required_props = !litho_required_props and liveness = !liveness diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 88cafaab1..5cb09b507 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -461,8 +461,6 @@ val linters_ignore_clang_failures : bool val linters_validate_syntax_only : bool -val litho_graphql_field_access : bool - val litho_required_props : bool val liveness : bool diff --git a/infer/src/checkers/GraphQLFieldAccess.ml b/infer/src/checkers/GraphQLFieldAccess.ml deleted file mode 100644 index 056d3ddf0..000000000 --- a/infer/src/checkers/GraphQLFieldAccess.ml +++ /dev/null @@ -1,66 +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. - *) - -open! IStd -module F = Format -module Domain = LithoDomain - -(* return true if this is a graphql getter *) -let is_graphql_function procname summary = - Option.is_none summary - (* we skip analysis of all GraphQL procs *) - && - match procname with - | Typ.Procname.Java java_procname -> ( - PatternMatch.is_getter java_procname - && - match Typ.Procname.Java.get_package java_procname with - | Some package -> - String.is_prefix ~prefix:"com.facebook.graphql.model" package - | None -> - false ) - | _ -> - false - - -module LithoContext = struct - type t = Domain.t - - let check_callee ~callee_pname ~tenv:_ = is_graphql_function callee_pname - - let satisfies_heuristic ~callee_pname:_ ~callee_summary_opt:_ _ = true - - let field = Payloads.Fields.litho_graphql_field_access - - let should_report proc_desc _tenv = - LithoFramework.is_on_create_layout (Procdesc.get_proc_name proc_desc) - - - let report astate _tenv summary = - let report_graphql_getter access_path call_chain = - let call_strings = - List.map - ~f:(fun Domain.MethodCall.{procname} -> - Typ.Procname.to_simplified_string ~withclass:false procname ) - call_chain - in - let call_string = String.concat ~sep:"." call_strings in - let message = F.asprintf "%a.%s" AccessPath.pp access_path call_string in - let loc = Summary.get_loc summary in - let ltr = [Errlog.make_trace_element 0 loc message []] in - Reporting.log_error summary ~loc ~ltr IssueType.graphql_field_access message - in - Domain.iter_call_chains ~f:report_graphql_getter astate ; - astate - - - let session_name = "litho graphql field access" -end - -module Analyzer = LithoFramework.MakeAnalyzer (LithoContext) - -let checker callback = Analyzer.checker callback diff --git a/infer/src/checkers/registerCheckers.ml b/infer/src/checkers/registerCheckers.ml index 53e2fea48..e2369feaa 100644 --- a/infer/src/checkers/registerCheckers.ml +++ b/infer/src/checkers/registerCheckers.ml @@ -109,9 +109,6 @@ let all_checkers = ; { name= "litho-required-props" ; active= Config.litho_required_props ; callbacks= [(Procedure RequiredProps.checker, Language.Java)] } - ; { name= "litho-graphql-field-access" - ; active= Config.litho_graphql_field_access - ; callbacks= [(Procedure GraphQLFieldAccess.checker, Language.Java)] } ; {name= "SIOF"; active= Config.siof; callbacks= [(Procedure Siof.checker, Language.Clang)]} ; { name= "uninitialized variables" ; active= Config.uninit diff --git a/infer/tests/codetoanalyze/java/litho/Makefile b/infer/tests/codetoanalyze/java/litho/Makefile index 1001ecaf5..f9dc69635 100644 --- a/infer/tests/codetoanalyze/java/litho/Makefile +++ b/infer/tests/codetoanalyze/java/litho/Makefile @@ -5,7 +5,7 @@ TESTS_DIR = ../../.. -INFER_OPTIONS = --litho-graphql-field-access-only --litho-required-props --debug-exceptions +INFER_OPTIONS = --litho-required-props-only --debug-exceptions INFERPRINT_OPTIONS = --issues-tests SOURCES = $(wildcard *.java) diff --git a/infer/tests/codetoanalyze/java/litho/ShouldUpdate.java b/infer/tests/codetoanalyze/java/litho/ShouldUpdate.java deleted file mode 100644 index c499f60c2..000000000 --- a/infer/tests/codetoanalyze/java/litho/ShouldUpdate.java +++ /dev/null @@ -1,97 +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. - */ -// makes it easier to mock graphql types -package com.facebook.graphql.model; - -import java.util.List; - -abstract class A { - abstract A getA(); - - abstract B getB(); - - abstract C getC(); -} - -abstract class B { - abstract C getC(); -} - -abstract class C { - abstract D getD(); -} - -class D {} - -abstract class GraphQLStory { - - public abstract List getActors(); -} - -class LithoTest { - - void /*basic chain*/ onCreateLayout(A a) { - a.getB().getC().getD(); - } - - void /*sibling chain*/ onCreateLayout(A a, int i) { - a.getB().getC().getD(); - a.getC().getD(); - } - - void /*split chain*/ onCreateLayout(A a, int i1, int i2) { - B b = a.getB(); - C c = b.getC(); - c.getD(); - } - - void chainFromActual1(B b) { - b.getC().getD(); - } - - void chainFromActual2(C c) { - c.getD(); - } - - void /*chain rooted in actual*/ onCreateLayout(A a, boolean b) { - chainFromActual1(a.getB()); - } - - void /*local chain + interproc chain*/ onCreateLayout(A a, char ch) { - C c = a.getB().getC(); - chainFromActual2(c); - } - - // conditional getters - static GraphQLStory getPrimaryActor(GraphQLStory story) { - List actors = story.getActors(); - return actors != null && actors.size() > 0 ? (GraphQLStory) actors.get(0) : null; - } - - void /*conditional getters on formal*/ onCreateLayout(GraphQLStory story) { - getPrimaryActor(story).toString(); - } - - static native GraphQLStory getStory(); - - void /*conditional getters on local*/ onCreateLayout() { - GraphQLStory story = getStory(); - getPrimaryActor(story).toString(); - } - - void /*cycle*/ onCreateLayout(A a, float f) { - a = a.getA(); - } - - void cycle(A a) { - a = a.getA(); - } - - void /*interprocedural cycle*/ onCreateLayout(A a, double d) { - cycle(a); - } -} diff --git a/infer/tests/codetoanalyze/java/litho/issues.exp b/infer/tests/codetoanalyze/java/litho/issues.exp index 125c25e85..5cc6b67e9 100644 --- a/infer/tests/codetoanalyze/java/litho/issues.exp +++ b/infer/tests/codetoanalyze/java/litho/issues.exp @@ -33,30 +33,3 @@ codetoanalyze/java/litho/RequiredProps.java, codetoanalyze.java.litho.RequiredPr codetoanalyze/java/litho/RequiredProps.java, codetoanalyze.java.litho.RequiredProps.setRequiredOnOneBothBranchesWithCreateOk_FP(boolean):com.facebook.litho.Component, 0, MISSING_REQUIRED_PROP, no_bucket, ERROR, [@Prop prop1 is required for component codetoanalyze.java.litho.MyComponent, but is not set before the call to build(),calls MyComponent$Builder MyComponent.create(),calls MyComponent$Builder MyComponent$Builder.prop2(Object),calls MyComponent$Builder MyComponent$Builder.prop3(Object),calls MyComponent MyComponent$Builder.build()] codetoanalyze/java/litho/RequiredProps.java, codetoanalyze.java.litho.RequiredProps.setRequiredOnOneBranchBad(boolean):com.facebook.litho.Component, 0, MISSING_REQUIRED_PROP, no_bucket, ERROR, [@Prop prop1 is required for component codetoanalyze.java.litho.MyComponent, but is not set before the call to build(),calls MyComponent$Builder MyComponent.create(),calls MyComponent$Builder MyComponent$Builder.prop2(Object),calls MyComponent$Builder MyComponent$Builder.prop3(Object),calls MyComponent MyComponent$Builder.build()] codetoanalyze/java/litho/RequiredProps.java, codetoanalyze.java.litho.RequiredProps.setRequiredOnOneBranchEffectfulBad(boolean):com.facebook.litho.Component, 0, MISSING_REQUIRED_PROP, no_bucket, ERROR, [@Prop prop1 is required for component codetoanalyze.java.litho.MyComponent, but is not set before the call to build(),calls MyComponent$Builder MyComponent.create(),calls MyComponent$Builder MyComponent$Builder.prop2(Object),calls MyComponent$Builder MyComponent$Builder.prop3(Object),calls MyComponent MyComponent$Builder.build()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout():void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [story.getActors()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout():void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [story.getActors().get(...).toString()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout():void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [story.getActors().get(...)] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout():void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [story.getActors().size()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.A):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [a.getB().getC().getD()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.A):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [a.getB()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.A):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [a.getB().getC()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.A,boolean):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [a.getB().getC().getD()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.A,boolean):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [a.getB()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.A,boolean):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [a.getB().getC()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.A,char):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [a.getB().getC().getD()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.A,char):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [a.getB()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.A,char):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [a.getB().getC()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.A,double):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [a.getA()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.A,float):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [a.getA()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.A,int):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [a.getC()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.A,int):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [a.getC().getD()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.A,int):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [a.getB().getC().getD()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.A,int):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [a.getB()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.A,int):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [a.getB().getC()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.A,int,int):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [a.getB().getC().getD()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.A,int,int):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [a.getB()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.A,int,int):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [a.getB().getC()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.GraphQLStory):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [story.getActors()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.GraphQLStory):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [story.getActors().get(...).toString()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.GraphQLStory):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [story.getActors().size()] -codetoanalyze/java/litho/ShouldUpdate.java, com.facebook.graphql.model.LithoTest.onCreateLayout(com.facebook.graphql.model.GraphQLStory):void, 0, GRAPHQL_FIELD_ACCESS, no_bucket, ERROR, [story.getActors().get(...)]