Copilot commented on code in PR #1177:
URL: 
https://github.com/apache/grails-spring-security/pull/1177#discussion_r2404714400


##########
plugin-core/plugin/grails-app/commands/grails.plugin.springsecurity/S2QuickstartCommand.groovy:
##########
@@ -301,5 +310,39 @@ Example: ./grailsw s2-quickstart --uiOnly
         }
     }
 
+    private void addBeansToPlugin(List<Map<String, String>> beans, File 
pluginClassFile) {
+        List<String> lines = []
+        if (pluginClassFile.exists()) {
+            pluginClassFile.eachLine { line, nb ->
+                lines << line
+                if(line.contains('package')) {
+                     beans.forEach(bean -> lines.add(bean.import))
+                }
+                if (line.contains('doWithSpring()')) {
+                    beans.each { Map bean ->
+                        lines << '        ' + bean.definition
+                    }
+                }

Review Comment:
   Bean definitions are being added immediately after the doWithSpring() method 
declaration line, which will place them outside the method body. The logic 
should identify the opening brace of the doWithSpring method and add beans 
inside the method body.



##########
plugin-core/docs/src/docs/introduction/gettingStarted.adoc:
##########
@@ -40,6 +40,9 @@ After installation, execute the `s2-quickstart` 
initialization script. This sets
 ./gradlew runCommand -Pargs="s2-quickstart com.yourapp User Role"
 ----
 
+If you are installing into a Grails plugin instead of an application, you must 
make sure you are using  the `web-plugin` profile. Otherwise dependncies will 
not be met.

Review Comment:
   Corrected spelling of 'dependncies' to 'dependencies'.
   ```suggestion
   If you are installing into a Grails plugin instead of an application, you 
must make sure you are using  the `web-plugin` profile. Otherwise dependencies 
will not be met.
   ```



##########
plugin-core/plugin/grails-app/commands/grails.plugin.springsecurity/S2QuickstartCommand.groovy:
##########
@@ -301,5 +310,39 @@ Example: ./grailsw s2-quickstart --uiOnly
         }
     }
 
+    private void addBeansToPlugin(List<Map<String, String>> beans, File 
pluginClassFile) {
+        List<String> lines = []
+        if (pluginClassFile.exists()) {
+            pluginClassFile.eachLine { line, nb ->
+                lines << line
+                if(line.contains('package')) {

Review Comment:
   The import statements are being added immediately after any line containing 
'package', which could result in imports being placed in the wrong location. 
This should check for the specific package declaration line and add imports 
after it, not after any line containing the word 'package'.
   ```suggestion
                   if(line.trim().startsWith('package ')) {
   ```



##########
plugin-core/docs/src/docs/introduction/gettingStarted.adoc:
##########
@@ -40,6 +40,9 @@ After installation, execute the `s2-quickstart` 
initialization script. This sets
 ./gradlew runCommand -Pargs="s2-quickstart com.yourapp User Role"
 ----
 
+If you are installing into a Grails plugin instead of an application, you must 
make sure you are using  the `web-plugin` profile. Otherwise dependncies will 
not be met.
+Running the same command will inject the spring beans into  your 
`GrailsPlugin` classes `doWithSpring` method.

Review Comment:
   Extra space between 'into' and 'your' should be removed.
   ```suggestion
   Running the same command will inject the spring beans into your 
`GrailsPlugin` classes `doWithSpring` method.
   ```



-- 
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]

Reply via email to