• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Rule: UselessLayout
2//
3// Description: Checks whether current node can be removed.
4//
5// Conditions:
6// - The node has children
7// - The node does not have siblings
8// - The node's parent is not a scroll view (horizontal or vertical)
9// - The node does not have a background or its parent does not have a
10//   background or neither the node and its parent have a background
11// - The parent is not a <merge/>
12
13if (!node.isRoot() && !(node['..'].name() in ["ScrollView", "HorizontalScrollView"]) &&
14        node['..']['*'].size() == 1 && node['*'].size() > 0 && ((node.'@android:background' ||
15        node['..'].'@android:background') || (!node.'@android:background' &&
16        !node['..'].'@android:background'))) {
17    analysis << "This ${node.name()} layout or its ${node['..'].name()} parent is " +
18            "${node['..'].'@android:id' ? "possibly useless" : "useless"}"
19}
20