-
Notifications
You must be signed in to change notification settings - Fork 7
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 AST functionality with excludeMain() #369
base: master
Are you sure you want to change the base?
Improve AST functionality with excludeMain() #369
Conversation
…n a java file, given different classes etc.
Why exclude main? Could you describe a use case here? Why not any other method? Or just just specific issues? This potentially weakens security (or maybe better called reliability, accuracy here). What are the thoughts on that and the rationale? |
I believe the idea here is to allow students restriction-free local testing of their own solution using the main method. But I'm not sure if just excluding the main method is the best approach for this. Consider a student submission like this: public static void main(String[] args) {
testCase1();
testCase2();
} Even though the Edit: I just noticed that your other PR implements a |
.filter(method -> method.isStatic() && method.getNameAsString().equals("main") | ||
&& method.getParameters().size() == 1 && method.getType().isVoidType() | ||
&& method.getParameter(0).getTypeAsString().equals("String[]")) | ||
.forEach(Node::remove); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We modify the AST here, it seems. Are we absolutely sure this has no unintended side effects?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or put differently: what does the removal do? Both according to the documentation and the actual implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removal removes the node from the tree and it's child nodes. This seems to be working as intented in the documentation and the actual implementation.
If we are going in that direction, a boolean flag is not a sustainable solution (this is quite common). |
I will take a look in to those APIs thank you for your review! |
For this we need to use the MethodCallGraph which is again not in scope of this PR. Will take this to Markus further! |
Improved the current AST functionality to allow instructors to exclude the Main method from AST checks.
excludeMain()
, to avoid AST checking of the Main method, as it is removed from the AST.