You are viewing a plain text version of this content. The canonical link for it is here.
Posted to geb-notifications@groovy.apache.org by cm...@apache.org on 2026/02/15 22:13:16 UTC
(groovy-geb) 02/03: fix codenarc violations.
This is an automated email from the ASF dual-hosted git repository.
cmarcum pushed a commit to branch task/geb-testcontainers
in repository https://gitbox.apache.org/repos/asf/groovy-geb.git
commit 43c6f2fc62473719c3a9000106b49f1d7c626944
Author: Carl Marcum <ca...@codebuilders.net>
AuthorDate: Sun Feb 15 10:36:11 2026 -0500
fix codenarc violations.
---
.../groovy/org/demo/spock/BaseUrlConfigFromClassSpec.groovy | 3 ---
.../demo/spock/ContainerFileDetectorAnnotationSpec.groovy | 3 +--
.../org/demo/spock/ContainerFileDetectorDefaultSpec.groovy | 1 -
.../org/demo/spock/ContainerFileDetectorSpockSpec.groovy | 5 ++---
.../groovy/org/demo/spock/ContainerGebSpecWithServer.groovy | 4 ----
.../groovy/org/demo/spock/DownloadSupportSpec.groovy | 2 --
.../groovy/org/demo/spock/GebConfigSpec.groovy | 4 ----
.../groovy/org/demo/spock/HostNameConfigurationSpec.groovy | 1 -
.../groovy/org/demo/spock/InheritedConfigSpec.groovy | 1 -
.../groovy/org/demo/spock/PageDelegateSpec.groovy | 6 +-----
.../groovy/org/demo/spock/PerTestRecordingSpec.groovy | 12 ++++--------
.../groovy/org/demo/spock/PortConfigFromClassSpec.groovy | 2 --
.../groovy/org/demo/spock/RootPageSpec.groovy | 1 -
.../groovy/org/demo/spock/TestFileServer.groovy | 5 -----
.../groovy/org/demo/spock/TestFileServerSpec.groovy | 5 -----
.../integration-test/groovy/org/demo/spock/UploadSpec.groovy | 4 ----
.../groovy/org/demo/spock/pages/HomePage.groovy | 1 -
.../groovy/org/demo/spock/pages/UploadPage.groovy | 4 ----
.../groovy/org/demo/spock/pages/UploadSuccessPage.groovy | 1 -
19 files changed, 8 insertions(+), 57 deletions(-)
diff --git a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/BaseUrlConfigFromClassSpec.groovy b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/BaseUrlConfigFromClassSpec.groovy
index fbaf4483..0c11e4e9 100644
--- a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/BaseUrlConfigFromClassSpec.groovy
+++ b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/BaseUrlConfigFromClassSpec.groovy
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.demo.spock
import grails.plugin.geb.ContainerGebSpec
@@ -28,11 +27,9 @@ import spock.lang.Narrative
@Narrative("To verify that class field overrides config file.")
class BaseUrlConfigFromClassSpec extends ContainerGebSpec {
-
String baseUrl = "http://groovy.apache.org"
def "should use the class field value"() {
-
when: "go to geb sub-page of groovy"
go "/geb"
diff --git a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/ContainerFileDetectorAnnotationSpec.groovy b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/ContainerFileDetectorAnnotationSpec.groovy
index 50f713b8..195f66db 100644
--- a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/ContainerFileDetectorAnnotationSpec.groovy
+++ b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/ContainerFileDetectorAnnotationSpec.groovy
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.demo.spock
import grails.plugin.geb.ContainerGebConfiguration
@@ -25,7 +24,7 @@ import org.demo.spock.pages.UploadPage
import org.openqa.selenium.WebDriverException
/**
- * Altered copy of {@link ContainerFileDetectorDefaultSpec}
+ * Altered copy of {@link ContainerFileDetectorDefaultSpec}
* that throws {@link org.openqa.selenium.InvalidArgumentException}
*/
@ContainerGebConfiguration(fileDetector = UselessContainerFileDetector)
diff --git a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/ContainerFileDetectorDefaultSpec.groovy b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/ContainerFileDetectorDefaultSpec.groovy
index d07001eb..e23b3942 100644
--- a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/ContainerFileDetectorDefaultSpec.groovy
+++ b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/ContainerFileDetectorDefaultSpec.groovy
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.demo.spock
import org.demo.spock.pages.UploadSuccessPage
diff --git a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/ContainerFileDetectorSpockSpec.groovy b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/ContainerFileDetectorSpockSpec.groovy
index d9975fa9..af93dea8 100644
--- a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/ContainerFileDetectorSpockSpec.groovy
+++ b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/ContainerFileDetectorSpockSpec.groovy
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.demo.spock
import grails.plugin.geb.ContainerFileDetector
@@ -31,11 +30,11 @@ import spock.lang.PendingFeature
*/
class ContainerFileDetectorSpockSpec extends ContainerGebSpecWithServer {
- def setupSpec(){
+ def setupSpec() {
ServiceRegistry.setInstance(ContainerFileDetector, new UselessContainerFileDetector())
}
- def cleanupSpec(){
+ def cleanupSpec() {
ServiceRegistry.setInstance(ContainerFileDetector, null)
}
diff --git a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/ContainerGebSpecWithServer.groovy b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/ContainerGebSpecWithServer.groovy
index 5dfeefaa..4381c82b 100644
--- a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/ContainerGebSpecWithServer.groovy
+++ b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/ContainerGebSpecWithServer.groovy
@@ -16,10 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.demo.spock
-
import grails.plugin.geb.ContainerGebSpec
/**
@@ -38,6 +36,4 @@ class ContainerGebSpecWithServer extends ContainerGebSpec {
server.stop(0)
}
-
-
}
diff --git a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/DownloadSupportSpec.groovy b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/DownloadSupportSpec.groovy
index 3ede798e..cafb8762 100644
--- a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/DownloadSupportSpec.groovy
+++ b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/DownloadSupportSpec.groovy
@@ -16,13 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.demo.spock
import org.demo.spock.pages.HomePage
import spock.lang.Title
-
@Title("should be able to use download methods")
class DownloadSupportSpec extends ContainerGebSpecWithServer {
diff --git a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/GebConfigSpec.groovy b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/GebConfigSpec.groovy
index 5009c589..d57d23bf 100644
--- a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/GebConfigSpec.groovy
+++ b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/GebConfigSpec.groovy
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.demo.spock
import org.demo.spock.pages.HomePage
@@ -29,8 +28,6 @@ import org.openqa.selenium.remote.RemoteWebDriver
class GebConfigSpec extends ContainerGebSpecWithServer {
def "should use custom RemoteWebDriver from GebConfig.groovy"() {
- // reportInfo "the config file should use environment blocks with browser names"
-
expect: 'the driver to be a RemoteWebDriver'
driver instanceof RemoteWebDriver
@@ -63,7 +60,6 @@ class GebConfigSpec extends ContainerGebSpecWithServer {
$("h1").text() == "Welcome to the Geb/Spock Test"
}
-
def cleanup() {
sleep(1000) // give the last video time to copy
}
diff --git a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/HostNameConfigurationSpec.groovy b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/HostNameConfigurationSpec.groovy
index 7530dccc..16d202ad 100644
--- a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/HostNameConfigurationSpec.groovy
+++ b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/HostNameConfigurationSpec.groovy
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.demo.spock
import org.demo.spock.pages.HomePage
diff --git a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/InheritedConfigSpec.groovy b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/InheritedConfigSpec.groovy
index 5edbb392..a9977a01 100644
--- a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/InheritedConfigSpec.groovy
+++ b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/InheritedConfigSpec.groovy
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.demo.spock
import org.demo.spock.pages.HomePage
diff --git a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/PageDelegateSpec.groovy b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/PageDelegateSpec.groovy
index 6bc2c67f..ee21ed05 100644
--- a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/PageDelegateSpec.groovy
+++ b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/PageDelegateSpec.groovy
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.demo.spock
import org.demo.spock.pages.UploadPage
@@ -24,11 +23,8 @@ import org.demo.spock.pages.UploadPage
class PageDelegateSpec extends ContainerGebSpecWithServer {
def "should delegate to page object"() {
- given:
- to(UploadPage)
-
when:
- nop()
+ to(UploadPage)
then:
title == 'Upload Test'
diff --git a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/PerTestRecordingSpec.groovy b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/PerTestRecordingSpec.groovy
index 7995a3b1..1eb0bce2 100644
--- a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/PerTestRecordingSpec.groovy
+++ b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/PerTestRecordingSpec.groovy
@@ -16,19 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.demo.spock
import grails.plugin.geb.ContainerGebSpec
-import spock.lang.Shared
import spock.lang.Stepwise
@Stepwise // execute feature methods in declared order
class PerTestRecordingSpec extends ContainerGebSpec {
- // @Shared
- // serverPort = 8080 // TODO: this needs to be a configuration
-
void '(setup) running a test to create a recording'() {
when: 'visiting the grails home page'
go('https://grails.apache.org/')
@@ -83,9 +78,10 @@ class PerTestRecordingSpec extends ContainerGebSpec {
and: 'the recording files should have different content (different sizes)'
// Sort by last modified time to get the most recent files
- def sortedFiles = recordingFiles.sort { it.lastModified() }
- def secondLastFile = sortedFiles[sortedFiles.length - 2]
- def lastFile = sortedFiles[sortedFiles.length - 1]
+ recordingFiles.sort { it.lastModified() }
+ // recordedFiles in now sorted by modified date
+ def secondLastFile = recordingFiles[recordingFiles.length - 2]
+ def lastFile = recordingFiles.last()
// Files should have different sizes (allowing for small variations due to timing)
long sizeDifference = Math.abs(lastFile.length() - secondLastFile.length())
diff --git a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/PortConfigFromClassSpec.groovy b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/PortConfigFromClassSpec.groovy
index 25168b95..3947d077 100644
--- a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/PortConfigFromClassSpec.groovy
+++ b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/PortConfigFromClassSpec.groovy
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.demo.spock
import grails.plugin.geb.ContainerGebSpec
@@ -50,7 +49,6 @@ class PortConfigFromClassSpec extends ContainerGebSpec {
and: "the welcome header should be displayed"
$("h1").text() == "Welcome to the Geb/Spock Test"
-
}
def cleanup() {
diff --git a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/RootPageSpec.groovy b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/RootPageSpec.groovy
index aadc5a1c..2f5a053b 100644
--- a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/RootPageSpec.groovy
+++ b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/RootPageSpec.groovy
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.demo.spock
import geb.report.CompositeReporter
diff --git a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/TestFileServer.groovy b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/TestFileServer.groovy
index 211c9be7..f291320a 100644
--- a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/TestFileServer.groovy
+++ b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/TestFileServer.groovy
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.demo.spock
import com.sun.net.httpserver.HttpServer
@@ -30,8 +29,6 @@ class TestFileServer {
static HttpServer server
- TestFileServer() {}
-
void start() {
start(8080)
}
@@ -55,8 +52,6 @@ class TestFileServer {
stop(0)
}
-
-
void stop(int delay) {
println "Stopping TestFileServer..."
if (server) {
diff --git a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/TestFileServerSpec.groovy b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/TestFileServerSpec.groovy
index a0df3cf4..696788f1 100644
--- a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/TestFileServerSpec.groovy
+++ b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/TestFileServerSpec.groovy
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.demo.spock
import grails.plugin.geb.ContainerGebSpec
@@ -34,7 +33,6 @@ class TestFileServerSpec extends ContainerGebSpec {
server = new TestFileServer()
}
-
// the config file should contain a 'hostPort = 8090' setting
def "should use the hostPort con GebConfig.groovy"() {
given: "a server listening on port 8090"
@@ -49,7 +47,6 @@ class TestFileServerSpec extends ContainerGebSpec {
and: "the welcome header should be displayed"
$("h1").text() == "Welcome to the Geb/Spock Test"
-
}
def cleanup() {
@@ -57,6 +54,4 @@ class TestFileServerSpec extends ContainerGebSpec {
server.stop(0)
}
-
-
}
diff --git a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/UploadSpec.groovy b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/UploadSpec.groovy
index 674c9263..d4fa6fc3 100644
--- a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/UploadSpec.groovy
+++ b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/UploadSpec.groovy
@@ -16,13 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.demo.spock
import geb.module.FileInput
import org.demo.spock.pages.UploadSuccessPage
-import grails.plugin.geb.ContainerGebSpec
import org.demo.spock.pages.UploadPage
import spock.lang.IgnoreIf
import spock.lang.Requires
@@ -103,7 +101,6 @@ class UploadSpec extends ContainerGebSpecWithServer {
then:
$("div.example").$("h3").text() == "File Uploaded!"
$("div.example").$("div", id: "uploaded-files").text() == "upload-test.txt"
-
}
def cleanup() {
@@ -111,5 +108,4 @@ class UploadSpec extends ContainerGebSpecWithServer {
container.execInContainer("rm /tmp/upload-test.txt")
}
-
}
\ No newline at end of file
diff --git a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/pages/HomePage.groovy b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/pages/HomePage.groovy
index 7fd3d999..418ab81a 100644
--- a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/pages/HomePage.groovy
+++ b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/pages/HomePage.groovy
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.demo.spock.pages
import geb.Page
diff --git a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/pages/UploadPage.groovy b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/pages/UploadPage.groovy
index 610e9a6d..6fcea215 100644
--- a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/pages/UploadPage.groovy
+++ b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/pages/UploadPage.groovy
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.demo.spock.pages
import geb.Page
@@ -32,7 +31,4 @@ class UploadPage extends Page {
submitBtn { $('button', type: 'submit') }
}
- void nop() {
- // no-op
- }
}
\ No newline at end of file
diff --git a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/pages/UploadSuccessPage.groovy b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/pages/UploadSuccessPage.groovy
index 3f53dd5a..cde7f5f5 100644
--- a/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/pages/UploadSuccessPage.groovy
+++ b/integration/geb-testcontainers/src/integration-test/groovy/org/demo/spock/pages/UploadSuccessPage.groovy
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.demo.spock.pages
import geb.Page