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

improve the backend tree validator #2832

Merged
merged 5 commits into from
Jul 9, 2018

Conversation

youri-k
Copy link
Contributor

@youri-k youri-k commented Jun 29, 2018

namely:

URL of deployed dev instance (used for testing):

  • https://___.webknossos.xyz

Steps to test:

  • try uploading a nml which contains one of the errors above
  • uploading should not work and an error toast should you what happened

Issues:


  • Ready for review

@youri-k youri-k self-assigned this Jun 29, 2018
Copy link
Contributor

@jstriebel jstriebel left a comment

Choose a reason for hiding this comment

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

Generally very nice! But I think some refactoring would help here, left some comments.

@@ -9,6 +9,14 @@ import scala.collection.mutable

object TreeValidator {

def validateAdditionalInformation(trees: Seq[Tree], branchPoints: Seq[BranchPoint], comments: Seq[Comment], treeGroups: Seq[TreeGroup]): Box[Unit] =
Copy link
Contributor

Choose a reason for hiding this comment

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

Tbh I think this function is a layer of indirection to much, as this is called exactly once. Please move those calls directly to the parse function.

}
}

private def checkAllNodesUsedInBranchPointsExist(trees: Seq[Tree], branchPoints: Seq[BranchPoint]): Box[Unit] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please make this and similar functions a bit more DRY. There are multiple functions checking that some nodes exist in the trees.

Copy link
Contributor

@jstriebel jstriebel left a comment

Choose a reason for hiding this comment

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

The refactoring helped a lot! Only one more thing left, that makes it more DRY

}
}

private def checkAllNodesUsedExist(trees: Seq[Tree], usedNodes: Seq[Int]) = {
Copy link
Contributor

Choose a reason for hiding this comment

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

As this is called check…, please include the actual check with the Failure message here. It justs needs the name of the nodes for the message.

Copy link
Contributor

@jstriebel jstriebel left a comment

Choose a reason for hiding this comment

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

👍 🚢

@youri-k youri-k merged commit 4dadc6e into backend-unit-tests Jul 9, 2018
youri-k added a commit that referenced this pull request Jul 9, 2018
* [WIP] backend unit test for nml parser

* [WIP] Unit Tests for Backend

* [WIP] backend unit test now work for serializing and parsing #2826

* nml tests now work similar to the frontend tests

* fix imports

* mark test as working to enable ci build #2829

* fix compiler errors and add some tests #2829

* enhance the backend tree validator with some functions the frontend already uses #2830

* add docker-compose service backend-tests

* CI: add backend tests

* e2e tests: move invariant config to End2EndSpec.scala

* implement pr advice #2829

* implement some of the pr advice #2832

* implement pr feedback #2832

* implement pr advice #2829

* fix merge errors and make code DRYer #2832

* Update CHANGELOG.md
@fm3 fm3 deleted the backend-nml-parser-improve-validation branch July 16, 2018 09:09
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