Details
-
Sub-task
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
HADOOP-12111
-
None
-
None
Description
1. rubocop.sh counts only lines which have at least five fields separated by a colon:
calcdiffs "${PATCH_DIR}/branch-rubocop-result.txt" "${PATCH_DIR}/patch-rubocop-result.txt" > "${PATCH_DIR}/diff-patch-rubocop.txt" diffPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/diff-patch-rubocop.txt") if [[ ${diffPostpatch} -gt 0 ]] ; then # shellcheck disable=SC2016 numPrepatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/branch-rubocop-result.txt") # shellcheck disable=SC2016 numPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/patch-rubocop-result.txt")
This is because the diff result can contain multiple lines for one issue. For example:
[sekikn@mobile hadoop]$ cat /private/tmp/test-patch-hbase/25821/diff-patch-rubocop.txt
bin/draining_servers.rb:165:1: C: Do not introduce global variables.
$foo
^^^^
Checking the number of fields is intended to skip the second and third lines in the above diff file. But four or more colons can appear in the source code itself, for example:
| Vote | Subsystem | Runtime | Comment ============================================================================ | -1 | rubocop | 0m 02s | The applied patch generated 4 new | | | | rubocop issues (total was 77, now 81). || Subsystem || Report/Notes || ============================================================================ | rubocop | v0.32.1 | | rubocop | /private/tmp/test-patch-hbase/5632/diff-patch-rubocop.txt | [sekikn@mobile hadoop]$ cat /private/tmp/test-patch-hbase/5632/diff-patch-rubocop.txt bin/draining_servers.rb:165:4: C: Do not use :: for method calls. foo::bar::baz ^^ bin/draining_servers.rb:165:9: C: Do not use :: for method calls. foo::bar::baz ^^ [sekikn@mobile hadoop]$
In this case, new rubocop issues should be 2, but counted as 4 incorrectly. More reliable way to count is needed.
2. pylint.sh has the same problem. In addition, I removed awk's '-F:' option by mistake on HADOOP-12286. It can report a wrong number for now.