-
Notifications
You must be signed in to change notification settings - Fork 3
SED-4340 find-usages-of-keyword-and-plan-referenced-by-attribute-is-b… #579
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
base: 29
Are you sure you want to change the base?
SED-4340 find-usages-of-keyword-and-plan-referenced-by-attribute-is-b… #579
Conversation
Summary of ChangesHello @david-stephan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a defect in the 'find usages' functionality, specifically targeting issues where keywords and plans referenced by attributes were not correctly identified. The changes involve a significant refactoring of the reference finding mechanism, moving the core logic into a new, dedicated class and enhancing the underlying entity dependency traversal. This ensures that the system can now accurately and comprehensively resolve all potential references, improving the reliability of usage analysis for dynamically referenced entities. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces a significant and well-executed refactoring of the reference finding logic to address an issue with locating usages of keywords and plans referenced by attributes. The key improvements include extracting the core logic into a dedicated ReferenceFinder class, introducing a more flexible VISIT_MODE for dependency traversal, and enhancing the PlanLocator and FunctionLocator to support a non-strict resolution mode. This non-strict mode is crucial for finding all potential references without a full execution context. The addition of a comprehensive test suite for the new ReferenceFinder is also a great enhancement.
My review includes a high-severity bug fix for a potential NullPointerException and a couple of medium-severity suggestions to further improve code maintainability and test quality. Overall, these are excellent changes that effectively solve the underlying problem.
step-controller/step-controller-server/src/main/java/step/core/references/ReferenceFinder.java
Show resolved
Hide resolved
| List<Object> referencedObjects = getReferencedObjects(entityType, object).stream().filter(o -> (o != null && !o.equals(object))).collect(Collectors.toList()); | ||
| //System.err.println("objects referenced from plan: " + planToString(plan) + ": "+ referencedObjects.stream().map(ReferenceFinderServices::objectToString).collect(Collectors.toList())); | ||
| return referencedObjects.stream().filter(o -> doesRequestMatch(request, o)).collect(Collectors.toList()); |
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.
This method can be simplified into a single, more efficient stream pipeline that avoids creating an intermediate list. Additionally, there's a commented-out debug line that should be removed as it's no longer relevant and references code that has been moved.
return getReferencedObjects(entityType, object).stream()
.filter(o -> o != null && !o.equals(object))
.filter(o -> doesRequestMatch(request, o))
.collect(Collectors.toList());
...ontroller/step-controller-server/src/test/java/step/core/references/ReferenceFinderTest.java
Show resolved
Hide resolved
jeromecomte
left a comment
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.
The changes look good but I indeed see a risk in the changes related to the FunctionLocator and PlanLocator. The new JUnit test ReferenceFinderTest looks good but I'm not sure if it covers all the aspects of the Locators, especially the ones related to versions. In order to merge this to 29, we should ensure that we cover this properly and add some tests if required
| // TODO declare it as non-static to avoid potential leaks | ||
| private static final Map<Class<?>, BeanInfo> beanInfoCache = new ConcurrentHashMap<>(); | ||
|
|
||
| public enum VISIT_MODE { |
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.
Please add a javadoc to document the exact purpose of these 3 modes
step-controller/step-controller-server/src/main/java/step/core/references/ReferenceFinder.java
Outdated
Show resolved
Hide resolved
step-controller/step-controller-server/src/main/java/step/core/references/ReferenceFinder.java
Outdated
Show resolved
Hide resolved
step-controller/step-controller-server/src/main/java/step/core/references/ReferenceFinder.java
Outdated
Show resolved
Hide resolved
| } else { | ||
| // No active versions defined. Return the first function | ||
| function = orderedFunctions.stream().findFirst().orElseThrow(() -> new NoSuchElementException("Unable to find keyword with attributes " + selectionAttributesJson)); | ||
| //No version defined with simply return the ordered function by priorities |
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.
COmment seems not correct
david-stephan
left a comment
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.
Thanks for the review, all points should be addressed with my last commits.
step-controller/step-controller-server/src/main/java/step/core/references/ReferenceFinder.java
Outdated
Show resolved
Hide resolved
step-controller/step-controller-server/src/main/java/step/core/references/ReferenceFinder.java
Outdated
Show resolved
Hide resolved
step-controller/step-controller-server/src/main/java/step/core/references/ReferenceFinder.java
Outdated
Show resolved
Hide resolved
| results.add(new FindReferencesResponse(function)); | ||
| } | ||
| } catch (Exception e) { | ||
| logger.error("Unable to find references for function {}", function.getId(), e); |
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.
SHouldn't we rethrow this or add the error to the response?
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.
Not sure how relevant that is. The implementation will browse all plans and all composite keywords to see if they use the searched reference, if an exception is raised because the context could not be rebuilt for one of them, I don't think this should break the operation, adding it as a warning would be doable (with quite some effort) but I also don't think this warning would be relevant for the user doing the request.
| results.add(new FindReferencesResponse(plan)); | ||
| } | ||
| } catch (Exception e) { | ||
| logger.error("Unable to find references for plan {}", plan.getId(), e); |
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.
Idem
…roken