[litho] Remove GraphQL ShouldUpdate analysis

Summary: It is not used anywhere and there are no plans to revive it. Kill it!

Reviewed By: skcho

Differential Revision: D18934719

fbshipit-source-id: b9b069b96
master
Ezgi Çiçek 5 years ago committed by Facebook Github Bot
parent 8ed2c77187
commit 47c89611a5

@ -176,14 +176,6 @@ OPTIONS
Activates: Enable --linters and disable all other checkers Activates: Enable --linters and disable all other checkers
(Conversely: --no-linters-only) (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 --litho-required-props
Activates: [EXPERIMENTAL] Required Prop check for Litho Activates: [EXPERIMENTAL] Required Prop check for Litho
(Conversely: --no-litho-required-props) (Conversely: --no-litho-required-props)

@ -728,15 +728,6 @@ OPTIONS
in JSON format to stdout (Conversely: in JSON format to stdout (Conversely:
--no-linters-validate-syntax-only) See also infer-capture(1). --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 --litho-required-props
Activates: [EXPERIMENTAL] Required Prop check for Litho Activates: [EXPERIMENTAL] Required Prop check for Litho
(Conversely: --no-litho-required-props) See also infer-analyze(1). (Conversely: --no-litho-required-props) See also infer-analyze(1).

@ -728,15 +728,6 @@ OPTIONS
in JSON format to stdout (Conversely: in JSON format to stdout (Conversely:
--no-linters-validate-syntax-only) See also infer-capture(1). --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 --litho-required-props
Activates: [EXPERIMENTAL] Required Prop check for Litho Activates: [EXPERIMENTAL] Required Prop check for Litho
(Conversely: --no-litho-required-props) See also infer-analyze(1). (Conversely: --no-litho-required-props) See also infer-analyze(1).

@ -16,7 +16,6 @@ type t =
; class_loads: ClassLoadsDomain.summary option ; class_loads: ClassLoadsDomain.summary option
; cost: CostDomain.summary option ; cost: CostDomain.summary option
; lab_resource_leaks: ResourceLeakDomain.summary option ; lab_resource_leaks: ResourceLeakDomain.summary option
; litho_graphql_field_access: LithoDomain.t option
; litho_required_props: LithoDomain.t option ; litho_required_props: LithoDomain.t option
; pulse: PulseSummary.t option ; pulse: PulseSummary.t option
; purity: PurityDomain.summary option ; purity: PurityDomain.summary option
@ -44,7 +43,6 @@ let fields =
~buffer_overrun_checker:(fun f -> mk f "BufferOverrunChecker" BufferOverrunCheckerSummary.pp) ~buffer_overrun_checker:(fun f -> mk f "BufferOverrunChecker" BufferOverrunCheckerSummary.pp)
~class_loads:(fun f -> mk f "ClassLoads" ClassLoadsDomain.pp_summary) ~class_loads:(fun f -> mk f "ClassLoads" ClassLoadsDomain.pp_summary)
~cost:(fun f -> mk f "Cost" CostDomain.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) ~litho_required_props:(fun f -> mk f "Litho Required Props" LithoDomain.pp)
~pulse:(fun f -> mk f "Pulse" PulseSummary.pp) ~pulse:(fun f -> mk f "Pulse" PulseSummary.pp)
~purity:(fun f -> mk f "Purity" PurityDomain.pp_summary) ~purity:(fun f -> mk f "Purity" PurityDomain.pp_summary)
@ -71,7 +69,6 @@ let empty =
; class_loads= None ; class_loads= None
; cost= None ; cost= None
; lab_resource_leaks= None ; lab_resource_leaks= None
; litho_graphql_field_access= None
; litho_required_props= None ; litho_required_props= None
; pulse= None ; pulse= None
; purity= None ; purity= None

@ -20,7 +20,6 @@ include sig
; class_loads: ClassLoadsDomain.summary option ; class_loads: ClassLoadsDomain.summary option
; cost: CostDomain.summary option ; cost: CostDomain.summary option
; lab_resource_leaks: ResourceLeakDomain.summary option ; lab_resource_leaks: ResourceLeakDomain.summary option
; litho_graphql_field_access: LithoDomain.t option
; litho_required_props: LithoDomain.t option ; litho_required_props: LithoDomain.t option
; pulse: PulseSummary.t option ; pulse: PulseSummary.t option
; purity: PurityDomain.summary option ; purity: PurityDomain.summary option

@ -30,7 +30,6 @@ type checkers =
; impurity: bool ref ; impurity: bool ref
; inefficient_keyset_iterator: bool ref ; inefficient_keyset_iterator: bool ref
; linters: bool ref ; linters: bool ref
; litho_graphql_field_access: bool ref
; litho_required_props: bool ref ; litho_required_props: bool ref
; liveness: bool ref ; liveness: bool ref
; loop_hoisting: bool ref ; loop_hoisting: bool ref
@ -638,7 +637,6 @@ and { annotation_reachability
; impurity ; impurity
; inefficient_keyset_iterator ; inefficient_keyset_iterator
; linters ; linters
; litho_graphql_field_access
; litho_required_props ; litho_required_props
; liveness ; liveness
; loop_hoisting ; loop_hoisting
@ -687,9 +685,6 @@ and { annotation_reachability
mk_checker ~long:"inefficient-keyset-iterator" ~default:true mk_checker ~long:"inefficient-keyset-iterator" ~default:true
"Check for inefficient uses of keySet iterator that access both the key and the value." "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 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 = and litho_required_props =
mk_checker ~long:"litho-required-props" "[EXPERIMENTAL] Required Prop check for Litho" mk_checker ~long:"litho-required-props" "[EXPERIMENTAL] Required Prop check for Litho"
and liveness = and liveness =
@ -769,7 +764,6 @@ and { annotation_reachability
; impurity ; impurity
; inefficient_keyset_iterator ; inefficient_keyset_iterator
; linters ; linters
; litho_graphql_field_access
; litho_required_props ; litho_required_props
; liveness ; liveness
; loop_hoisting ; 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 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 litho_required_props = !litho_required_props
and liveness = !liveness and liveness = !liveness

@ -461,8 +461,6 @@ val linters_ignore_clang_failures : bool
val linters_validate_syntax_only : bool val linters_validate_syntax_only : bool
val litho_graphql_field_access : bool
val litho_required_props : bool val litho_required_props : bool
val liveness : bool val liveness : bool

@ -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

@ -109,9 +109,6 @@ let all_checkers =
; { name= "litho-required-props" ; { name= "litho-required-props"
; active= Config.litho_required_props ; active= Config.litho_required_props
; callbacks= [(Procedure RequiredProps.checker, Language.Java)] } ; 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= "SIOF"; active= Config.siof; callbacks= [(Procedure Siof.checker, Language.Clang)]}
; { name= "uninitialized variables" ; { name= "uninitialized variables"
; active= Config.uninit ; active= Config.uninit

@ -5,7 +5,7 @@
TESTS_DIR = ../../.. 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 INFERPRINT_OPTIONS = --issues-tests
SOURCES = $(wildcard *.java) SOURCES = $(wildcard *.java)

@ -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);
}
}

@ -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.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.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/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(...)]

Loading…
Cancel
Save