hadoop-common-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kai Zheng (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HADOOP-12859) Disable hidding field style checks in class setters
Date Wed, 02 Mar 2016 10:54:18 GMT

    [ https://issues.apache.org/jira/browse/HADOOP-12859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15175428#comment-15175428
] 

Kai Zheng commented on HADOOP-12859:
------------------------------------

Hi Andrew, below is my trying.

1. Given the current codes:
{noformat}
[root@zkdesk hadoop]# mvn checkstyle:checkstyle
[root@zkdesk hadoop]# grep -c 'hides a field' hadoop-common-project/hadoop-common/target/test/checkstyle-errors.xml

396
{noformat}

2. Added the following test codes to the codebase in the hadoop-common module:
{code}
+public class MyCheckstyleCheck {
+  private String test1;
+  private String test2;
+  private String test3;
+  private String test4;
+
+  public String getTest1() {
+    return test1;
+  }
+
+  public void setTest1(String test1) {
+    this.test1 = test1;
+  }
+
+  public String getTest2() {
+    return test2;
+  }
+
+  public void setTest2(String test2) {
+    this.test2 = test2;
+  }
+
+  public String getTest3() {
+    return test3;
+  }
+
+  public void setTest3(String test3) {
+    this.test3 = test3;
+  }
+
+  public String getTest4() {
+    return test4;
+  }
+
+  public void setTest4(String test4) {
+    this.test4 = test4;
+  }
+}
{code}
And run the above command again, it gives:
{noformat}
[root@zkdesk hadoop]# grep -c 'hides a field' hadoop-common-project/hadoop-common/target/test/checkstyle-errors.xml

400
{noformat}

3. Applied the patch here and tested again, it gave:
{noformat}
[root@zkdesk hadoop]# grep -c 'hides a field' hadoop-common-project/hadoop-common/target/test/checkstyle-errors.xml

297
{noformat}
In addition to {{mvn install}} as you mentioned in HADOOP-12713, I also ran {{mvn clean package}}
to ensure the patch to take effect.
Note this change shall not get rid of any {{hides a field}} warnings because in other cases
the checking does make sense.

> Disable hidding field style checks in class setters
> ---------------------------------------------------
>
>                 Key: HADOOP-12859
>                 URL: https://issues.apache.org/jira/browse/HADOOP-12859
>             Project: Hadoop Common
>          Issue Type: Improvement
>            Reporter: Kai Zheng
>            Assignee: Kai Zheng
>         Attachments: HADOOP-12859-v1.patch
>
>
> As discussed in mailing list, this will disable style checks in class setters like the
following:
> {noformat}
> void setBlockLocations(LocatedBlocks blockLocations) {:42: 'blockLocations' hides a field.
> void setTimeout(int timeout) {:25: 'timeout' hides a field.
> void setLocatedBlocks(List<LocatedBlock> locatedBlocks) {:46: 'locatedBlocks' hides
a field.
> void setRemaining(long remaining) {:28: 'remaining' hides a field.
> void setBytesPerCRC(int bytesPerCRC) {:29: 'bytesPerCRC' hides a field.
> void setCrcType(DataChecksum.Type crcType) {:39: 'crcType' hides a field.
> void setCrcPerBlock(long crcPerBlock) {:30: 'crcPerBlock' hides a field.
> void setRefetchBlocks(boolean refetchBlocks) {:35: 'refetchBlocks' hides a field.
> void setLastRetriedIndex(int lastRetriedIndex) {:34: 'lastRetriedIndex' hides a field.
> {noformat}



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

Mime
View raw message