[PATCH] sbin/compare: Fix undefined method for false in sort_stats

when doing lkp compare, it complains: /home/lkp-tests/sbin/compare:826:in `block in sort_stats': undefined method `=~' for false:FalseClass (NoMethodError) from /home/lkp-tests/sbin/compare:814:in `each' from /home/lkp-tests/sbin/compare:814:in `sort_by' from /home/lkp-tests/sbin/compare:814:in `sort_by!' from /home/lkp-tests/sbin/compare:814:in `sort_stats' from /home/lkp-tests/sbin/compare:860:in `<main>' After checking the code and operator priority in ruby, since the 'Logical NOT operator !' has a higher priority than the 'Regex match operator =~', there is a mistake introduced by the commit 8fa05e8aae9f ("cleanup rubpcop issue Style/AndOr"). Add Parentheses to fix it. Fixes: 8fa05e8aae9f ("cleanup rubpcop issue Style/AndOr") Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com> --- sbin/compare | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/compare b/sbin/compare index 11c4fbb05..f5db5ef33 100755 --- a/sbin/compare +++ b/sbin/compare @@ -823,7 +823,7 @@ def sort_stats(stats) if x =~ ABS_CHANGE_STATS_RE [stat_priority(fields[0]), fields[1], abs_change] - elsif fields.size >= 3 && !fields[1] =~ /^node\d+$/ + elsif fields.size >= 3 && !(fields[1] =~ /^node\d+$/) # when a monitor can be broken into sub-groups of stats # under which values can be logically compared [stat_priority(fields[0]), fields[1], rel_change] -- 2.20.1
participants (1)
-
Zheng Zengkai