Skip to content
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.

Adding error for fake complete=false module #371

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Adding error for fake complete=false module #371

wants to merge 1 commit into from

Conversation

pyricau
Copy link
Member

@pyricau pyricau commented Dec 31, 2013

It does not make sense to use "complete = false" on a module if there is no missing binding. This can happen after refactorings, or copy pasting. While you can't beat manual review, it also helps to have the compiler let you know that you have it wrong.

I've used this branch to chase our "fake incomplete" modules. Turns out we had more then a few, so I think it might be worth making that a feature.

This commit is not done yet: I can't build, I have mysterious "java.io package not allowed" errors and also apparently I need to upgrade Maven for Android to build. I'll try to fix that done or steal Jake's laptop.

I should also add some tests.

In the meantime, let me know if that sounds like the right way to do it. I wonder if it should live in GraphAnalysisProcessor or not.

It does not make sense to use "complete = false" on a module if there is no missing binding. This can happen after refactorings, or copy pasting. While you can't beat manual review, it also helps to have the compiler let you know that you have it wrong.

I've used this branch to chase our "fake incomplete" modules. Turns out we had more then a few, so I think it might be worth making that a feature.

This commit is not done yet: I can't build, I have mysterious "java.io package not allowed" errors and also apparently I need to upgrade Maven for Android to build. I'll try to fix that done or steal Jake's laptop.

I should also add some tests.

In the meantime, let me know if that sounds like the right way to do it. I wonder if it should live in GraphAnalysisProcessor or not.
try {
processCompleteModule(moduleType, errorHandler);
} catch (RuntimeException e) {
// Any error here is fine, we're not supposed to process real incomplete modules.
Copy link
Member

Choose a reason for hiding this comment

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

This is pretty loose. I suspect there's a better way.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep. That's mostly me not knowing what can jump out of there. I guess we don't like checked exceptions for some reason :) .

@swankjesse
Copy link
Member

That's clever. I like where you're going with this.

Should complete=false on a complete module be an error? CC: @cgruber @gk5885

private boolean shouldBeComplete = true;

@Override public void handleErrors(List<String> errors) {
if (errors.size() > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

This can be shortened to:

shouldBeComplete &= errors.isEmpty();

Copy link
Member Author

Choose a reason for hiding this comment

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

Because it's so much easier to understand this way :) ?

Copy link
Member

Choose a reason for hiding this comment

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

At the very least you should be using isEmpty() in the conditional here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants