You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "Kengo Seki (JIRA)" <ji...@apache.org> on 2015/08/05 08:25:04 UTC

[jira] [Updated] (HADOOP-12301) Fix some test-patch plugins to count the diff lines correctly

     [ https://issues.apache.org/jira/browse/HADOOP-12301?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kengo Seki updated HADOOP-12301:
--------------------------------
    Description: 
Some test-patch plugins have problems about counting the diff lines.

1. ruby-lint.sh counts only lines which have five or more fields:

{code}
  diffPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/diff-patch-ruby-lint.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-ruby-lint-result.txt")

    # shellcheck disable=SC2016
    numPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/patch-ruby-lint-result.txt")
{code}

This is because the diff result can contain multiple lines for one issue. For example:

{code}
[sekikn@mobile hadoop]$ cat /tmp/test-patch-hbase/1149/diff-patch-rubocop.txt 
bin/draining_servers.rb:165:1: C: Do not introduce global variables.
$FOO
^^^^
bin/draining_servers.rb:166:1: C: Do not introduce global variables.
$BAR
^^^^
{code}

Checking the number of fields is intended to skip the second, third, fifth and sixth lines above. But four or more colons can appear in the source code itself, so more reliable way is needed.

2. pylint.sh has the same problem. In addition, I removed awk's '-F:' option by mistake on HADOOP-12286. It must report a wrong number for now.

3. On the other hand, rubocop.sh counts the lines in the same way as ruby-lint.sh, but rubocop seems to report one issue by one line. So it'd better to count by 'wc -l', in the same as perlcritic.sh.

  was:
Some test-patch plugins have problems about counting the diff lines.

1. ruby-lint.sh counts only lines which have four or more fields:

{code}
  diffPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/diff-patch-ruby-lint.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-ruby-lint-result.txt")

    # shellcheck disable=SC2016
    numPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/patch-ruby-lint-result.txt")
{code}

This is because the diff result can contain multiple lines for one issue. For example:

{code}
[sekikn@mobile hadoop]$ cat /tmp/test-patch-hbase/1149/diff-patch-rubocop.txt 
bin/draining_servers.rb:165:1: C: Do not introduce global variables.
$FOO
^^^^
bin/draining_servers.rb:166:1: C: Do not introduce global variables.
$BAR
^^^^
{code}

Checking the number of fields is intended to skip the second, third, fifth and sixth lines above. But four or more colons can appear in the source code itself, so more reliable way is needed.

2. pylint.sh has the same problem. In addition, I removed awk's '-F:' option by mistake on HADOOP-12286. It must report a wrong number for now.

3. On the other hand, rubocop.sh counts the lines in the same way as ruby-lint.sh, but rubocop seems to report one issue by one line. So it'd better to count by 'wc -l', in the same as perlcritic.sh.


> Fix some test-patch plugins to count the diff lines correctly
> -------------------------------------------------------------
>
>                 Key: HADOOP-12301
>                 URL: https://issues.apache.org/jira/browse/HADOOP-12301
>             Project: Hadoop Common
>          Issue Type: Sub-task
>          Components: yetus
>    Affects Versions: HADOOP-12111
>            Reporter: Kengo Seki
>
> Some test-patch plugins have problems about counting the diff lines.
> 1. ruby-lint.sh counts only lines which have five or more fields:
> {code}
>   diffPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/diff-patch-ruby-lint.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-ruby-lint-result.txt")
>     # shellcheck disable=SC2016
>     numPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/patch-ruby-lint-result.txt")
> {code}
> This is because the diff result can contain multiple lines for one issue. For example:
> {code}
> [sekikn@mobile hadoop]$ cat /tmp/test-patch-hbase/1149/diff-patch-rubocop.txt 
> bin/draining_servers.rb:165:1: C: Do not introduce global variables.
> $FOO
> ^^^^
> bin/draining_servers.rb:166:1: C: Do not introduce global variables.
> $BAR
> ^^^^
> {code}
> Checking the number of fields is intended to skip the second, third, fifth and sixth lines above. But four or more colons can appear in the source code itself, so more reliable way is needed.
> 2. pylint.sh has the same problem. In addition, I removed awk's '-F:' option by mistake on HADOOP-12286. It must report a wrong number for now.
> 3. On the other hand, rubocop.sh counts the lines in the same way as ruby-lint.sh, but rubocop seems to report one issue by one line. So it'd better to count by 'wc -l', in the same as perlcritic.sh.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)