Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report unused import when parent reference is already present #437

Conversation

sowmyav24
Copy link
Contributor

@sowmyav24 sowmyav24 commented May 25, 2019

This PR fixes the issue #405

  • While traversing nodes and building ref, built a set of non redundant imports which omits the imports where parent reference is already present.
  • Imports with aliases should contain both name and alias in the importSet
  • Static function call and variable have been distinguised

@sowmyav24 sowmyav24 force-pushed the report-unsed-import-when-parent-reference-present branch 3 times, most recently from c9d28df to 27e54e6 Compare May 26, 2019 06:00
@sowmyav24 sowmyav24 changed the title Report used import when parent reference is already present Report unused import when parent reference is already present May 26, 2019
@sowmyav24 sowmyav24 force-pushed the report-unsed-import-when-parent-reference-present branch from 27e54e6 to 1085904 Compare May 26, 2019 09:20
@shashachu
Copy link
Contributor

@sowmyav24 thanks for the PR! A couple requests:

  1. would be great to add a few comments into the code - we're trying to slowly add comments into the standard ruleset since they make great examples for others trying to write their own custom rules
  2. I don't know why it wouldn't work, but can you add some tests to ensure auto-formatting works properly for these unused parent imports?

@sowmyav24 sowmyav24 force-pushed the report-unsed-import-when-parent-reference-present branch from 1085904 to bc3dd0f Compare May 31, 2019 02:52
@sowmyav24
Copy link
Contributor Author

@shashachu Thank you for the feedback.

  • Added a test to ensure auto formatting works for parent imports.
  • Added comments for the functions introduced. Let me know if needs to be more descriptive.

@shashachu
Copy link
Contributor

Thanks for the fixes!

@shashachu shashachu merged commit 238b774 into pinterest:master May 31, 2019
sowmyav24 added a commit to sowmyav24/ktlint that referenced this pull request Jun 9, 2019
sowmyav24 added a commit to sowmyav24/ktlint that referenced this pull request Jun 9, 2019
@sowmyav24 sowmyav24 deleted the report-unsed-import-when-parent-reference-present branch June 9, 2019 01:53
sowmyav24 added a commit to sowmyav24/ktlint that referenced this pull request Jun 9, 2019
sowmyav24 added a commit to sowmyav24/ktlint that referenced this pull request Jun 10, 2019
sowmyav24 added a commit to sowmyav24/ktlint that referenced this pull request Jun 10, 2019
sowmyav24 added a commit to sowmyav24/ktlint that referenced this pull request Jun 10, 2019
sowmyav24 added a commit to sowmyav24/ktlint that referenced this pull request Jun 10, 2019
sowmyav24 added a commit to sowmyav24/ktlint that referenced this pull request Jun 10, 2019
sowmyav24 added a commit to sowmyav24/ktlint that referenced this pull request Jun 10, 2019
sowmyav24 added a commit to sowmyav24/ktlint that referenced this pull request Jun 10, 2019
sowmyav24 added a commit to sowmyav24/ktlint that referenced this pull request Jun 10, 2019
shashachu added a commit to shashachu/ktlint that referenced this pull request Jul 17, 2019
shashachu added a commit that referenced this pull request Jul 17, 2019
…437)" (#532)

* Revert "Report used import when parent reference is already present (#437)"

This reverts commit 238b774.

Fixes #437, re-introduces #405

* fix build
sowmyav24 pushed a commit to sowmyav24/ktlint that referenced this pull request Jul 18, 2019
…interest#437)" (pinterest#532)

* Revert "Report used import when parent reference is already present (pinterest#437)"

This reverts commit 238b774.

Fixes pinterest#437, re-introduces pinterest#405

* fix build
orchestr7 pushed a commit to saveourtool/diktat that referenced this pull request Jun 29, 2020
…437)" (#532)

* Revert "Report used import when parent reference is already present (#437)"

This reverts commit 238b774b86cdf6c96dbb8a84d250e7c4a20ac7e7.

Fixes pinterest/ktlint#437, re-introduces pinterest/ktlint#405

* fix build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants