- InefficientWeight - NestedScrollingWidgets - TooManyChildren Change-Id: Ic8fe0b36e0a7cac523d223e5f8d96d7959919da6
21 lines
915 B
Plaintext
21 lines
915 B
Plaintext
// Rule: UselessLayout
|
|
//
|
|
// Description: Checks whether current node can be removed.
|
|
//
|
|
// Conditions:
|
|
// - The node has children
|
|
// - The node does not have siblings
|
|
// - The node's parent is not a scroll view (horizontal or vertical)
|
|
// - The node does not have a background or its parent does not have a
|
|
// background or neither the node and its parent have a background
|
|
// - The parent is not a <merge/>
|
|
|
|
if (!xml.isRoot() && !(xml['..'].name() in ["ScrollView", "HorizontalScrollView"]) &&
|
|
xml['..']['*'].size() == 1 && xml['*'].size() > 0 && ((xml.'@android:background' ||
|
|
xml['..'].'@android:background') || (!xml.'@android:background' &&
|
|
!xml['..'].'@android:background'))) {
|
|
analysis << [node: node, description: "This ${xml.name()} layout or " +
|
|
"its ${xml['..'].name()} parent is " +
|
|
"${xml['..'].'@android:id' ? "possibly useless" : "useless"}"]
|
|
}
|