-
Notifications
You must be signed in to change notification settings - Fork 320
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
Make CreateFileVisitor less opaque by returning if it changed the value #4476
base: main
Are you sure you want to change the base?
Make CreateFileVisitor less opaque by returning if it changed the value #4476
Conversation
Hi @ajturnerora ; welcome back! Would you mind describing the use case you're looking to use I'm mostly wondering if
Typically we try to avoid having two ways to do one thing, so I'm mostly wondering if your use case is sufficiently different. |
Hi @timtebeek , I am creating a file if a condition is met (matching maven property) so I was making a recipe similar to My initial though was something like this:
The precondition cannot match, but the scanner still runs as
This behavior seems a little odd as the precondition failed in both cases but the file contents differ.
However, the scanner visitors aren't really preconditions so returning a |
What's changed?
Changed
CreateFileVisitor
to returnSearchResult.found(sourceFile)
rather thansourceFile
if it updates theshouldCreate
boolean.What's your motivation?
To allow the visitor to be more easily used in precondition checks - it is currently used as a type of precondition in scanner recipes but is currently alway alone - e.g., when doing an
.and
it will return if any visitor returns thetree
unchanged which this visitor always does. Currently you don't know if the visitor found the file or not without checking an external variable.Have you considered any alternatives or workarounds?
Yes, I could wrap the visitor, but I don't see any downside to the visitor exposing if it made a change or not.
Checklist