You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using npm-groovy-lint with my Spock tests that have a data provider for several test cases.
def"Test: #testCaseTitle"() {
when:
def result = testedMethod(json)
then:
result !=nullwhere:
testCaseTitle | json || errorMessage
'missing image' | """{ "view": "available", "options": ["empty"] }"""||"""JSON is missing image"""'missing options' | """{ "view": "available", "image": "${placeholder}" }"""||"""JSON is missing options"""'missing view' | """{ "image": "${placeholder}", "options": ["empty"] }"""||"""JSON is missing view"""'all missing' | """{ }"""||"""JSON is missing image, JSON is missing options, JSON is missing view"""
}
After auto-fixing the code using npm-groovy-lint the source code got uncompilable because of wrongly replaced GString quotes.
def"Test: #testCaseTitle"() {
when:
def result = testedMethod(json)
then:
result !=nullwhere:
testCaseTitle | json || errorMessage
'missing image' | '''{ "view": "available", "options": ["empty"] }""" || ""'JSON is missing image'"" 'missing options' | '''{ "view": "available", "image": "${placeholder}" }""" || ""'JSON is missing options'"" 'missing view' | """{ "image": "${placeholder}", "options": ["empty"] }""" || ""'JSON is missing view'"" 'all missing' | ""'{ }'"" || ""'JSON is missing image, JSON is missing options, JSON is missing view'""}
npm-groovy-lint does not detect the end of the GStrings correctly and therefore replaces the the quotes at the wrong place leaving the source code uncompilable.
sdoeringNew
changed the title
UnnecessaryGString leaves invalid code in data provider of Spock tests
Autofix of UnnecessaryGString leaves invalid code in data provider of Spock tests
Nov 20, 2024
Hi,
I'm using npm-groovy-lint with my Spock tests that have a data provider for several test cases.
After auto-fixing the code using npm-groovy-lint the source code got uncompilable because of wrongly replaced GString quotes.
npm-groovy-lint does not detect the end of the GStrings correctly and therefore replaces the the quotes at the wrong place leaving the source code uncompilable.
This:
"""{ "view": "available", "options": ["empty"] }"""
Becomes that:
'''{ "view": "available", "options": ["empty"] }"""
This:
"""JSON is missing image"""
Becomes that:
That behaviour is not good.
Kind regards
The text was updated successfully, but these errors were encountered: