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

Update code from the internal repo. #1

Merged
merged 3 commits into from
Nov 4, 2019

Conversation

lazaroclapp
Copy link
Contributor

  • This open sources the PluginCleaner checker
  • Batch pulls a number of changes from our internal repo
  • Gets us generally ready to making Piranha OSS the source of truth
    overall (including internally).

* This open sources the PluginCleaner checker
* Batch pulls a number of changes from our internal repo
* Gets us generally ready to making Piranha OSS the source of truth
  overall (including internally).
@lazaroclapp lazaroclapp requested a review from mkr-plse October 31, 2019 17:58
@lazaroclapp
Copy link
Contributor Author

I did my best to check for references to internal stuff and add the licenses (and the tests run :) ). But a second pair of eyes is always helpful, @mkruber

Copy link
Contributor

@mkr-plse mkr-plse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we skip open sourcing PluginCleaner for now

@lazaroclapp
Copy link
Contributor Author

Can we skip open sourcing PluginCleaner for now

Done.

*/
package com.uber.piranha;

public class PiranhaUtils {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class also needs to be deleted as it is used for internally diff processing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not exactly practical, though. This class is used by Piranha to mark code for file deletion, so we need to reference it from the EP check. We are not (yet?) providing the scripts to remove files marked with these comments, but we probably should.

We could make the comment text a parameter to Piranha (maybe in a follow up PR?), but I am not sure that would be any cleaner than this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

providing a script to delete the files with this comment addresses my concern.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will do in a follow up diff, opening an issue for now.

/**
* Originally from com.uber.errorprone.checker.dagger.UsageCounter
*/
public final class UsageCounter {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EP was already planning on a usage checker for Dagger. However, no harm in releasing this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They do have a checker, but it's not implemented with a modular usage counter we can easily call, for now it's better to keep this class around, if not the corresponding UsageChecker :)

private boolean countsCollected = false;
private ImmutableMap<Symbol, UsageCounter.CounterData> usageCounts = null;
private Map<Symbol, Integer> deletedUsages = null;

/**
* Copied from NullAway comment. Error Prone requires us to have an empty constructor for each
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can be deleted :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems useful for documenting why we have that constructor, though. I can remove the reference from NullAway if you want, but the comment itself seems useful.

}

@Override
public Description matchClass(ClassTree classTree, VisitorState visitorState) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will work well internally, not sure how this is appropriate for external use. We need to think of a better flow here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I agree, although I am also not sure the external flow needs to be too different (except for using gradle instead of buck and integrations with whatever the users' CI is). For now, I think moving the development to the open can be done first and then we can improve the UX for external adopters :)

private BugCheckerRefactoringTestHelper addHelperClasses(BugCheckerRefactoringTestHelper bcr)
throws IOException {
return bcr.addInputLines(
"XPTest.java",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we place them as part of the refactoring files? It is hard to parse them manually and also putting them as part of the refactoring files will ensure consistency and list the respective use cases.

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