[
https://issues.apache.org/jira/browse/IMPALA-14930?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18087130#comment-18087130
]
ASF subversion and git services commented on IMPALA-14930:
----------------------------------------------------------
Commit 9e56ed29e7442f35da5444ee617fc1485d6b32a7 in impala's branch
refs/heads/master from stiga-huang
[ https://gitbox.apache.org/repos/asf?p=impala.git;h=9e56ed29e ]
IMPALA-14930: Auto comments on unused imports in Java
This patch improves critique-gerrit-review.py to add comments on unused
imports in Java changes.
Different to the existing Python unused import check that depends on
flake8 (F401), the script simply uses string parsing to extract imported
class/method names and check if they are used in non-comment codes. Note
that wildcard imports like "import java.util.*" are not allowed unless
for test codes or explicitly added in the allow list. E.g. we allow
"import static org.junit.Assert.*" in test codes for simplicity.
Another difference to the Python check is the whole Java file is checked
instead of just checking the changed codes. This makes it possible to
find unused imports that are caused by removed codes.
This patch also removes the existing unused imports in Java files so
they won't trigger Gerrit comments on unrelated patches. Expands "import
java.util.*" in Graph.java to what it actually needs.
Tests:
- Used the logic in critique-gerrit-review.py to remove all unused
imports in Java files.
- Compiled Impala locally after removing the unused imports.
- Verified the script in some commits that have unused imports.
Assisted-by: Composer 2
Change-Id: I5a260c05e02e96aaf1331bc31ed92b0e368403bd
Reviewed-on: http://gerrit.cloudera.org:8080/24259
Reviewed-by: Michael Smith <[email protected]>
Tested-by: Impala Public Jenkins <[email protected]>
> Auto comments on unused imports in Java
> ---------------------------------------
>
> Key: IMPALA-14930
> URL: https://issues.apache.org/jira/browse/IMPALA-14930
> Project: IMPALA
> Issue Type: Task
> Components: Infrastructure
> Reporter: Quanlong Huang
> Assignee: Quanlong Huang
> Priority: Major
>
> It's common that when moving/removing some codes, some imports become unused
> in the Java file and we forget to remove them. We can improve
> critique-gerrit-review.py to add a simple check on that and automatically add
> comments in Gerrit.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]