You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by nm...@apache.org on 2025/10/10 09:34:51 UTC
(ofbiz-framework) branch trunk updated: Improved: Codenarc Set max priority violations to 0 for all level (OFBIZ-13302)
This is an automated email from the ASF dual-hosted git repository.
nmalin pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/trunk by this push:
new 1e47b60452 Improved: Codenarc Set max priority violations to 0 for all level (OFBIZ-13302)
1e47b60452 is described below
commit 1e47b604527ab98258bbaf236be343f6b5e9cda2
Author: Nicolas Malin <ni...@nereide.fr>
AuthorDate: Fri Oct 10 11:24:45 2025 +0200
Improved: Codenarc Set max priority violations to 0 for all level (OFBIZ-13302)
After OFBIZ-13228 and OFBIZ-11167 we can move the value of max priority violations to 0 for all level.
By the way, codenarc detected some regression on groovy test file so we fixed it on same time
---
build.gradle | 4 +--
.../FlexibleStringExpanderBaseCodeTests.groovy | 20 ++++++++-----
.../apache/ofbiz/service/ModelServiceTest.groovy | 35 +++++++++++-----------
3 files changed, 31 insertions(+), 28 deletions(-)
diff --git a/build.gradle b/build.gradle
index 4a8a489e7b..cb1eec5747 100644
--- a/build.gradle
+++ b/build.gradle
@@ -348,8 +348,8 @@ gitHooks {
codenarc {
setConfigFile(new File('config/codenarc/codenarc.groovy'))
setMaxPriority1Violations(0)
- setMaxPriority2Violations(403)
- setMaxPriority3Violations(3920)
+ setMaxPriority2Violations(0)
+ setMaxPriority3Violations(0)
}
// Eclipse plugin settings
diff --git a/framework/base/src/test/groovy/org/apache/ofbiz/base/util/string/FlexibleStringExpanderBaseCodeTests.groovy b/framework/base/src/test/groovy/org/apache/ofbiz/base/util/string/FlexibleStringExpanderBaseCodeTests.groovy
index 7dac90818b..bc79a3613b 100644
--- a/framework/base/src/test/groovy/org/apache/ofbiz/base/util/string/FlexibleStringExpanderBaseCodeTests.groovy
+++ b/framework/base/src/test/groovy/org/apache/ofbiz/base/util/string/FlexibleStringExpanderBaseCodeTests.groovy
@@ -19,6 +19,7 @@
package org.apache.ofbiz.base.util.string
import groovy.io.FileType
+import org.apache.ofbiz.base.util.Debug
import org.apache.ofbiz.base.util.ScriptUtil
import org.junit.Test
@@ -28,11 +29,13 @@ import java.util.regex.Pattern
class FlexibleStringExpanderBaseCodeTests {
- Pattern pattern = Pattern.compile('\\$\\{groovy:.*}')
+ private static final String MODULE = FlexibleStringExpanderBaseCodeTests.getName()
+ private final Pattern pattern = Pattern.compile('\\$\\{groovy:.*}')
+
@Test
void testEveryGroovyScriptletFromXmlFiles() {
- def filterWidgetXmlFiles = ~/\.\/(framework|application|plugins).*\/widget\/.*(Screens|Menus|Forms)\.xml$/
- new File(".").traverse(type: FileType.FILES, filter: filterWidgetXmlFiles) {it ->
+ Pattern filterWidgetXmlFiles = ~/\.\/(framework|application|plugins).*\/widget\/.*(Screens|Menus|Forms)\.xml$/
+ new File('.').traverse(type: FileType.FILES, filter: filterWidgetXmlFiles) { it ->
assert parseXmlFile(it).isEmpty()
}
}
@@ -42,7 +45,7 @@ class FlexibleStringExpanderBaseCodeTests {
* @param file
* @return List unsafe scriptlet
*/
- List parseXmlFile(File file) {
+ private List parseXmlFile(File file) {
String text = file.getText()
Matcher matcher = pattern.matcher(text)
List matchedScriptlet = []
@@ -53,11 +56,12 @@ class FlexibleStringExpanderBaseCodeTests {
}
}
if (matchedScriptlet) {
- println "Unsafe scriptlet found on file ${file.getName()} : "
- println '*************************************'
- println '* ' + matchedScriptlet.join('\n* ')
- println '*************************************'
+ Debug.logInfo("Unsafe scriptlet found on file ${file.getName()} : ", MODULE)
+ Debug.logInfo('*************************************', MODULE)
+ Debug.logInfo('* ' + matchedScriptlet.join('\n* '), MODULE)
+ Debug.logInfo('*************************************', MODULE)
}
return matchedScriptlet
}
+
}
diff --git a/framework/service/src/test/groovy/org/apache/ofbiz/service/ModelServiceTest.groovy b/framework/service/src/test/groovy/org/apache/ofbiz/service/ModelServiceTest.groovy
index 9fa8de9d6d..b53764ed0b 100644
--- a/framework/service/src/test/groovy/org/apache/ofbiz/service/ModelServiceTest.groovy
+++ b/framework/service/src/test/groovy/org/apache/ofbiz/service/ModelServiceTest.groovy
@@ -18,18 +18,16 @@
*******************************************************************************/
package org.apache.ofbiz.service
-
-import org.apache.ofbiz.entity.DelegatorFactory
-import org.junit.Before
-
import static org.mockito.ArgumentMatchers.any
import static org.mockito.Mockito.eq
import org.apache.ofbiz.base.util.UtilProperties
-import org.apache.ofbiz.base.util.UtilURL;
+import org.apache.ofbiz.base.util.UtilURL
import org.apache.ofbiz.base.util.UtilXml
import org.apache.ofbiz.base.util.cache.UtilCache
+import org.apache.ofbiz.entity.DelegatorFactory
import org.junit.Assert
+import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
@@ -47,10 +45,10 @@ class ModelServiceTest {
@Before
void initialize() {
- System.setProperty("ofbiz.home", System.getProperty("user.dir"))
- System.setProperty("derby.system.home", "./runtime/data/derby")
- dispatcher = Mockito.mock(LocalDispatcher.class)
- Mockito.when(dispatcher.getDelegator()).thenReturn(DelegatorFactory.getDelegator("default"))
+ System.setProperty('ofbiz.home', System.getProperty('user.dir'))
+ System.setProperty('derby.system.home', './runtime/data/derby')
+ dispatcher = Mockito.mock(LocalDispatcher)
+ Mockito.when(dispatcher.getDelegator()).thenReturn(DelegatorFactory.getDelegator('default'))
}
@BeforeEach
@@ -328,8 +326,8 @@ class ModelServiceTest {
</service>'''
createModelService(serviceXml)
.validate(dispatcher, [header: [[headerParam: 'line1', otherParam: 'Good'],
- [headerParam: 'line2', otherParam: 'Good',
- unwanted: 'Bad']]],
+ [headerParam: 'line2', otherParam: 'Good',
+ unwanted: 'Bad']]],
'IN', Locale.default)
}
@@ -414,12 +412,6 @@ class ModelServiceTest {
assert sanitizedContext.someList[0].quantity instanceof BigDecimal
}
- private static ModelService createModelService(String serviceXml) {
- Element serviceElement = UtilXml.readXmlDocument(serviceXml, false).getDocumentElement()
- return new ModelServiceReader(true, UtilURL.fromUrlString('http://ofbiz.apache.org'), null, null)
- .createModelService(serviceElement, 'TEST')
- }
-
@Test
void callValidatorCreationWithDelegator() {
String serviceXml = '''<service name="testParam" engine="java"
@@ -433,6 +425,13 @@ class ModelServiceTest {
ModelService fo = createModelService(serviceXml)
ModelParam.ModelParamValidator validator = fo.getParam('fileNameToTest').getValidators().first()
assert validator
- assert ModelService.typeValidate(dispatcher, validator, "myFileName")
+ assert ModelService.typeValidate(dispatcher, validator, 'myFileName')
}
+
+ private static ModelService createModelService(String serviceXml) {
+ Element serviceElement = UtilXml.readXmlDocument(serviceXml, false).getDocumentElement()
+ return new ModelServiceReader(true, UtilURL.fromUrlString('http://ofbiz.apache.org'), null, null)
+ .createModelService(serviceElement, 'TEST')
+ }
+
}