matrei commented on code in PR #15097:
URL: https://github.com/apache/grails-core/pull/15097#discussion_r2377977126
##########
grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/services/transform/ServiceTransformation.groovy:
##########
@@ -185,20 +185,20 @@ class ServiceTransformation extends
AbstractTraitApplyingGormASTTransformation i
List<FieldNode> propertiesFields = []
if (isAbstractClass) {
- List<PropertyNode> properties = classNode.getProperties()
+ List<PropertyNode> properties = classNode.getProperties().sort {
it.name }
Review Comment:
- Add comment why we are sorting?
- Simplify?
```groovy
// Sort to ensure consistent ordering for build reproducibility
def properties = classNode.properties.sort { it.name }
```
##########
grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/services/transform/ServiceTransformation.groovy:
##########
@@ -210,6 +210,8 @@ class ServiceTransformation extends
AbstractTraitApplyingGormASTTransformation i
}
+ propertiesFields.sort(true) { it.name } // ensure a consistent order
of processing fields
Review Comment:
Can be removed if we use a sorted set.
##########
grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/services/transform/ServiceTransformation.groovy:
##########
@@ -260,11 +262,14 @@ class ServiceTransformation extends
AbstractTraitApplyingGormASTTransformation i
weaveTraitWithGenerics(impl, getTraitClass(), targetDomainClass)
List<MethodNode> abstractMethods =
findAllUnimplementedAbstractMethods(classNode)
+ abstractMethods.sort(true) { it.name } // ensure a consistent
order of processing methods
+
Iterable<ServiceImplementer> implementers =
findServiceImplementors(annotationNode)
// first go through the existing implemented methods and just
enhance them
if (!isInterface) {
- for (MethodNode existing in classNode.methods) {
+ def sortedMethods = classNode.methods.sort(true) { it.name }
+ for (MethodNode existing in (sortedMethods)) {
Review Comment:
- Add comment why we are sorting?
- Why mutate?
- Simplify?
```groovy
// Sort to ensure consistent ordering for build reproducibility
def sortedMethods = classNode.methods.sort { it.name }
for (MethodNode existing in sortedMethods) {
```
##########
grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/services/transform/ServiceTransformation.groovy:
##########
@@ -260,11 +262,14 @@ class ServiceTransformation extends
AbstractTraitApplyingGormASTTransformation i
weaveTraitWithGenerics(impl, getTraitClass(), targetDomainClass)
List<MethodNode> abstractMethods =
findAllUnimplementedAbstractMethods(classNode)
+ abstractMethods.sort(true) { it.name } // ensure a consistent
order of processing methods
+
Review Comment:
Sort inline? Simplify?
```groovy
// Sort to ensure consistent ordering for build reproducibility
def abstractMethods = findAllUnimplementedAbstractMethods(classNode)
.sort { it.name }
```
##########
grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/services/transform/ServiceTransformation.groovy:
##########
@@ -185,20 +185,20 @@ class ServiceTransformation extends
AbstractTraitApplyingGormASTTransformation i
List<FieldNode> propertiesFields = []
Review Comment:
Use a sorted set from the start? Would clean up the sort after the loop.
```groovy
// Use sorted set to ensure consistent ordering for build reproducibility
def propertiesFields = new TreeSet<FieldNode>({ FieldNode field ->
field.name })
```
##########
grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/services/transform/ServiceTransformation.groovy:
##########
@@ -372,7 +376,7 @@ class ServiceTransformation extends
AbstractTraitApplyingGormASTTransformation i
loadAnnotationDefined(annotationNode, 'implementers',
finalImplementers, ServiceImplementer)
Iterable<ServiceImplementerAdapter> adapters =
load(ServiceImplementerAdapter)
- List<ServiceImplementerAdapter> finalAdapters = adapters.toList()
+ List<ServiceImplementerAdapter> finalAdapters =
adapters.toList().sort { it.class.name }
Review Comment:
- Add comment why we are sorting?
- Simplify?
```groovy
// Sort to ensure consistent ordering for build reproducibility
def finalAdapters = adapters.sort { it.class.name }
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]