diff --git a/infer/src/checkers/Litho.ml b/infer/src/checkers/Litho.ml index 45a676089..28f269e37 100644 --- a/infer/src/checkers/Litho.ml +++ b/infer/src/checkers/Litho.ml @@ -122,9 +122,10 @@ module RequiredProps = struct [] - let report_missing_required_prop summary prop_string loc = + let report_missing_required_prop summary prop_string parent_typename loc = let message = - F.asprintf "@Prop %s is required, but not set before the call to build()" prop_string + F.asprintf "@Prop %s is required for component %s, but is not set before the call to build()" + prop_string (Typ.Name.name parent_typename) in let exn = Exceptions.Checkers (IssueType.missing_required_prop, Localise.verbatim_desc message) @@ -178,7 +179,8 @@ module RequiredProps = struct List.iter ~f:(fun required_prop -> if not (has_prop prop_set required_prop) then - report_missing_required_prop summary required_prop (Specs.get_loc summary) ) + report_missing_required_prop summary required_prop parent_typename + (Specs.get_loc summary) ) required_props | _ -> () ) diff --git a/infer/tests/codetoanalyze/java/litho/issues.exp b/infer/tests/codetoanalyze/java/litho/issues.exp index c9d7866be..7b998f3ea 100644 --- a/infer/tests/codetoanalyze/java/litho/issues.exp +++ b/infer/tests/codetoanalyze/java/litho/issues.exp @@ -1,12 +1,12 @@ -codetoanalyze/java/litho/RequiredProps.java, MyComponent RequiredProps.FP_setRequiredOnBothBranchesOk(boolean), 0, MISSING_REQUIRED_PROP, [@Prop prop1 is required, but not set before the call to build()] -codetoanalyze/java/litho/RequiredProps.java, MyComponent RequiredProps.buildWithout1Bad(), 0, MISSING_REQUIRED_PROP, [@Prop prop1 is required, but not set before the call to build()] -codetoanalyze/java/litho/RequiredProps.java, MyComponent RequiredProps.buildWithout3Bad(), 0, MISSING_REQUIRED_PROP, [@Prop prop3 is required, but not set before the call to build()] -codetoanalyze/java/litho/RequiredProps.java, MyComponent RequiredProps.callBuildSuffixWithoutRequiredBad(), 0, MISSING_REQUIRED_PROP, [@Prop prop1 is required, but not set before the call to build()] -codetoanalyze/java/litho/RequiredProps.java, MyComponent RequiredProps.setProp3InCalleeButForgetProp1Bad(), 0, MISSING_REQUIRED_PROP, [@Prop prop1 is required, but not set before the call to build()] -codetoanalyze/java/litho/RequiredProps.java, MyComponent RequiredProps.setRequiredOnOneBranchBad(boolean), 0, MISSING_REQUIRED_PROP, [@Prop prop1 is required, but not set before the call to build()] -codetoanalyze/java/litho/RequiredProps.java, Object RequiredProps.generalTypeForgot3Bad(), 0, MISSING_REQUIRED_PROP, [@Prop prop3 is required, but not set before the call to build()] -codetoanalyze/java/litho/RequiredProps.java, void RequiredProps.buildPropResMissingBad(), 0, MISSING_REQUIRED_PROP, [@Prop prop is required, but not set before the call to build()] -codetoanalyze/java/litho/RequiredProps.java, void RequiredProps.buildWithColumnChildBad(), 0, MISSING_REQUIRED_PROP, [@Prop prop3 is required, but not set before the call to build()] +codetoanalyze/java/litho/RequiredProps.java, MyComponent RequiredProps.FP_setRequiredOnBothBranchesOk(boolean), 0, MISSING_REQUIRED_PROP, [@Prop prop1 is required for component codetoanalyze.java.litho.MyComponent, but is not set before the call to build()] +codetoanalyze/java/litho/RequiredProps.java, MyComponent RequiredProps.buildWithout1Bad(), 0, MISSING_REQUIRED_PROP, [@Prop prop1 is required for component codetoanalyze.java.litho.MyComponent, but is not set before the call to build()] +codetoanalyze/java/litho/RequiredProps.java, MyComponent RequiredProps.buildWithout3Bad(), 0, MISSING_REQUIRED_PROP, [@Prop prop3 is required for component codetoanalyze.java.litho.MyComponent, but is not set before the call to build()] +codetoanalyze/java/litho/RequiredProps.java, MyComponent RequiredProps.callBuildSuffixWithoutRequiredBad(), 0, MISSING_REQUIRED_PROP, [@Prop prop1 is required for component codetoanalyze.java.litho.MyComponent, but is not set before the call to build()] +codetoanalyze/java/litho/RequiredProps.java, MyComponent RequiredProps.setProp3InCalleeButForgetProp1Bad(), 0, MISSING_REQUIRED_PROP, [@Prop prop1 is required for component codetoanalyze.java.litho.MyComponent, but is not set before the call to build()] +codetoanalyze/java/litho/RequiredProps.java, MyComponent RequiredProps.setRequiredOnOneBranchBad(boolean), 0, MISSING_REQUIRED_PROP, [@Prop prop1 is required for component codetoanalyze.java.litho.MyComponent, but is not set before the call to build()] +codetoanalyze/java/litho/RequiredProps.java, Object RequiredProps.generalTypeForgot3Bad(), 0, MISSING_REQUIRED_PROP, [@Prop prop3 is required for component codetoanalyze.java.litho.MyComponent, but is not set before the call to build()] +codetoanalyze/java/litho/RequiredProps.java, void RequiredProps.buildPropResMissingBad(), 0, MISSING_REQUIRED_PROP, [@Prop prop is required for component codetoanalyze.java.litho.ResPropComponent, but is not set before the call to build()] +codetoanalyze/java/litho/RequiredProps.java, void RequiredProps.buildWithColumnChildBad(), 0, MISSING_REQUIRED_PROP, [@Prop prop3 is required for component codetoanalyze.java.litho.MyComponent, but is not set before the call to build()] codetoanalyze/java/litho/ShouldUpdate.java, void LithoTest.onCreateLayout(), 0, GRAPHQL_FIELD_ACCESS, [&story.getActors().get(...)] codetoanalyze/java/litho/ShouldUpdate.java, void LithoTest.onCreateLayout(), 0, GRAPHQL_FIELD_ACCESS, [&story.getActors().get(...).toString()] codetoanalyze/java/litho/ShouldUpdate.java, void LithoTest.onCreateLayout(), 0, GRAPHQL_FIELD_ACCESS, [&story.getActors().size()]