Skip to content
This repository has been archived by the owner on Apr 16, 2022. It is now read-only.

Clean up unused members and functions #745

Merged
merged 15 commits into from
Jul 17, 2019

Conversation

acj
Copy link
Contributor

@acj acj commented Jun 25, 2019

Makes incremental progress on #214. I'm trying to become familiar with Briefcase by doing this work, so please let me know if anything is misplaced or inappropriate. If this is too broad, I can break it into multiple PRs.

What has been done to verify that this works as intended?

I've run the tests and done a bit of manual testing.

Why is this the best possible solution? Were any other approaches considered?

Straightforward cleanup task.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

I've limited this PR to removing unused code, so risk should be minimal. However, it's possible that subtle bugs could have been introduced.

Does this change require updates to documentation? If so, please file an issue at https://github.com/opendatakit/docs/issues/new and include the link below.

No.

@codecov-io
Copy link

codecov-io commented Jun 25, 2019

Codecov Report

Merging #745 into master will increase coverage by 0.2%.
The diff coverage is 50%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master     #745     +/-   ##
===========================================
+ Coverage     47.26%   47.46%   +0.2%     
+ Complexity     1468     1464      -4     
===========================================
  Files           178      177      -1     
  Lines          9703     9651     -52     
  Branches        673      672      -1     
===========================================
- Hits           4586     4581      -5     
+ Misses         4826     4779     -47     
  Partials        291      291
Impacted Files Coverage Δ Complexity Δ
...g/opendatakit/briefcase/reused/job/JobsRunner.java 64.28% <ø> (ø) 11 <0> (ø) ⬇️
...atakit/briefcase/pull/central/PullFromCentral.java 65.32% <ø> (-0.28%) 20 <0> (-1)
...kit/briefcase/reused/transfer/AggregateServer.java 85.78% <ø> (+2.62%) 65 <0> (ø) ⬇️
...g/opendatakit/briefcase/reused/UncheckedFiles.java 44.53% <ø> (+5.56%) 31 <0> (ø) ⬇️
...eused/transfer/sourcetarget/source/PullSource.java 0% <ø> (ø) 0 <0> (ø) ⬇️
...eused/transfer/sourcetarget/target/PushTarget.java 0% <ø> (ø) 0 <0> (ø) ⬇️
.../transfer/sourcetarget/ShowSourceOrTargetForm.java 0% <ø> (ø) 0 <0> (ø) ⬇️
...endatakit/briefcase/reused/http/HttpException.java 50% <ø> (+25%) 1 <0> (ø) ⬇️
...endatakit/briefcase/export/SubmissionMetaData.java 89.47% <ø> (+6.54%) 14 <0> (ø) ⬇️
...e/ui/export/components/ConfigurationPanelForm.java 92.24% <ø> (+0.17%) 41 <0> (ø) ⬇️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5bc43ed...de61672. Read the comment docs.

@acj acj marked this pull request as ready for review June 25, 2019 00:44
@ggalmazor
Copy link
Contributor

Thanks, @acj, and welcome to the codebase! There is a lot of room for improvements and your help is very much appreciated.

I also wanted to make you aware of #736, which we will be merging probably today. Unfortunately, it will cause merge conflicts with this PR, but we can work them out together after that ;)

You mention that you're starting to familiarize with the codebase. That's great! If you are starting to think about potential changes, it would be great to hear about them! :D

You can hop into the Slack #briefcase-code channel or the forums. I'm currently on GMT+2.

@acj
Copy link
Contributor Author

acj commented Jun 25, 2019

I also wanted to make you aware of #736, which we will be merging probably today. Unfortunately, it will cause merge conflicts with this PR, but we can work them out together after that ;)

That's great to hear! Congrats. It shouldn't be too painful to rebase my changes once that PR lands.

If you are starting to think about potential changes, it would be great to hear about them! :D

Nothing specific yet, but I'd like to help improve Briefcase's performance (parsing, networking, etc) once I get my bearings.

You can hop into the Slack #briefcase-code channel or the forums. I'm currently on GMT+2.

Will do. I'm on GMT-4.

@acj
Copy link
Contributor Author

acj commented Jun 29, 2019

@ggalmazor This is ready for another look when you have time. I rebased onto master after #736 was merged.

Also, not sure how/where to report this: I tried to join the ODK Slack and got a token_revoked error.

@ggalmazor
Copy link
Contributor

Hey, @acj! Thanks for updating your PR.

I've had a quick look and there are a couple of things we should discuss to see how you feel about them first. I know that IntelliJ is telling you that all those refactors are safe and that all those things are unused but:

  • Some of the changes belong to an older/"legacy" part of Briefcase that will eventually be replaced by a new implementation.

    The strategy we've been trying to follow with these is a combination of Golden Master/Characterization Test and Parallel Refactoring, which requires to leave untouched the original implementation that's going to be replaced.

    What we do is to take for granted that current outputs and side-effects are correct and try to match them with a new implementation. If we make changes to the original implementation - even if they look safe, we risk of introducing unexpected changes in the original behavior, which would defeat the purpose of this strategy.

  • Some of the changes belong to a newer/"redesigned" parts of Briefcase where the design "hasn't set yet" i.e. we're not 100% sure the design is good and we want to revisit it under a wide cross-cutting perspective.

    For example, instead of removing the Model.forEach() method, we should ask ourselves if the Model class - as an abstraction over an XmlElement that can be mapped, filtered, and iterated - is working for us or not.

I know that this can be frustrating and even annoying, but we do it to produce a sturdier and more approachable design in a safe way. It would be exciting to discuss these things over at Slack, once you're able to join. It would also be super valuable to hear your take on the "newer" parts to know if the design makes it harder or easier for someone to make changes. @yanokwa @lognaturel, do you know why @acj could be getting that particular error when joining Slack?

OTOH, there are changes that I think it's safe to merge at this moment. How would you like me to proceed?

@acj
Copy link
Contributor Author

acj commented Jul 2, 2019

Hey, thanks for this context and explanation. That approach makes sense to me, and it explains some of the patterns that I was seeing -- e.g. older code that seems unused, and newer code that sometimes had comments explaining that it would be used in the near future. This has been a useful exercise in learning the code, so I don't mind the extra iterations.

If you wouldn't mind listing the changes that are safe to merge, and/or describing where the boundaries between the old and new implementations are, then I'll rework the branch so that it only includes the safe parts.

Copy link
Contributor

@ggalmazor ggalmazor left a comment

Choose a reason for hiding this comment

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

Alright, there you go :)

I tagged with new/revisit and old/legacy the ones I think we should avoid changing.

I've added some context and some questions. The questions are not directed at anyone in special (well, probably at me). They're there just to think about the context around that particular change.

@@ -65,18 +65,6 @@ public SubmissionMetaData(XmlElement root) {
return submissionDate;
}

/**
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch! This is done with Iso8601Helpers

@@ -160,16 +160,15 @@ public static BriefcaseFormDefinition resolveAgainstBriefcaseDefn(File tmpFormFi
// newDefn is considered identical to what we have locally...
result = DifferenceResult.XFORMS_IDENTICAL;
} else {
result = JavaRosaParserWrapper.compareXml(newDefn, existingXml, existingTitle, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

old/legacy

This class should be eventually replaced by FormDefinition

@@ -45,10 +45,6 @@ public void markAsCancelled(PullEvent.Cancel event) {
log.info("cancel requested: " + event.cause);
}

public void reset() {
Copy link
Contributor

Choose a reason for hiding this comment

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

old/legacy

This class should be eventually removed by the use of the JobsRunner class

@@ -17,9 +17,5 @@
package org.opendatakit.briefcase.model;

public class UpdatedBriefcaseFormDefinitionEvent {
public final BriefcaseFormDefinition definition;
Copy link
Contributor

Choose a reason for hiding this comment

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

old/legacy

This class is used by BriefcaseFormDefinition, which will be replaced by FromDefinition and doesn't publish this event.

src/org/opendatakit/briefcase/operations/Export.java Outdated Show resolved Hide resolved

public class JobsRunnerTest {
private static final Logger log = LoggerFactory.getLogger(JobsRunnerTest.class);
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -70,22 +70,6 @@ public static String buildAggregateSubmissionDownloadXml(String instanceId, int
"";
}

public static String buildAggregateSubmissionDownloadXml(String instanceId, List<AggregateAttachment> attachments) {
Copy link
Contributor

Choose a reason for hiding this comment

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

new/revisit

Why aren't we using this? Maybe missing a test somewhere?

@@ -67,23 +67,19 @@
}
}

private ExportConfiguration currentConf;
Copy link
Contributor

Choose a reason for hiding this comment

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

new/revisit

All the *PageObject classes have to be thoroughly reviewed.

UI component tests should be revisited to see how well they're helping us prevent bugs and see how we can add more tooling to have more of them.

@@ -49,7 +49,7 @@ protected void onSetUp() {
@Test
@Ignore
public void export_dir_button_opens_a_file_dialog() {
component = ConfigurationPanelPageObject.setUpDefaultPanel(robot(), empty().build(), true, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

I lost track of changes :D.

Adjust as needed depending on whether the setUpDefaultPanel has to lose the arg or not.

@@ -70,17 +70,4 @@ void set(TriStateBoolean value) {
component.set(value);
});
}

private JRadioButton getRadioButton(TriStateBoolean value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

new/revisit

Why aren't we using this? Maybe missing a test somewhere?

@acj
Copy link
Contributor Author

acj commented Jul 8, 2019

@ggalmazor Thanks for the careful review and suggestions. I'm not sure whether the last commit (removing CompletableFutureHelpers and DatePickerMatchers) is acceptable, but the rest feels pretty good now.

@ggalmazor
Copy link
Contributor

Awesome! Thanks for updating the PR, @acj!

It's OK to remove CompletableFutureHelpers and DatePickerMatchers too.

Copy link
Contributor

@ggalmazor ggalmazor left a comment

Choose a reason for hiding this comment

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

LGTM. Since this PR only has safe refactors, I think we could merge this directly and expect to catch any weird side-effect during manual testing for the next release

@ggalmazor ggalmazor added this to the v1.17.0 milestone Jul 8, 2019
@yanokwa yanokwa requested a review from dcbriccetti July 9, 2019 05:12
Copy link
Contributor

@dcbriccetti dcbriccetti left a comment

Choose a reason for hiding this comment

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

@ggalmazor
Copy link
Contributor

Great! We'll merge this as soon as we release v1.16.1 with a couple of bug fixes.

@ggalmazor ggalmazor merged commit 1c7eaf8 into getodk:master Jul 17, 2019
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

4 participants