Checks that all non-optional
@Props have been specified when constructing Litho components.
- C/C++/ObjC: No
- Java: Yes
- C#/.Net: Yes
In a nutshell, a Litho Component is essentially a class that defines immutable inputs, called prop (annotated with
@Prop) in component hierarchy methods. For each Component there is a corresponding spec class which defines the required props:. E.g:
MyComponentSpec defines two props: a String prop called
prop1 and an int prop named
prop2. For each prop defined on the spec, the annotation processor creates a builder pattern method that has the same name as the prop.
Developers pass down values for these props by calling the appropriate methods:
If the required props are not called, then annotation processor throws an exception in run time. This is really bad and that's where this checker comes into play to detect such cases statically.
E.g. the following is caught as MISSING_REQUIRED_PROP
The following is ok though since
prop1 is optional.
Note that, the functions
build() could be defined in different methods and there could be various function calls, aliasing, and control flow patterns in between. Hence, this checker is inter-procedural.
The following issue types are reported by this checker: