dlwldnjs1009 opened a new issue, #6665:
URL: https://github.com/apache/jmeter/issues/6665
### Use case
In #6658, @vlsi noted that the current `NestedForDepth` restriction leads to
awkward code in tests:
> "This is ugly, and I am gravitating towards lifting NestedForDepth
requirements. It can be in a separate PR though."
In the HTTP sampler tests, some parameter-generation methods use
`Arrays.stream().forEach()` around nested loops. Examples include
`TestDecompression` and `TestRedirects`.
For example, test argument generation currently uses code like this:
```java
Arrays.stream(HTTPSamplerFactory.getImplementations()).forEach(httpImpl -> {
for (ClientGzip clientGzip : ClientGzip.values()) {
for (ServerGzip serverGzip : ServerGzip.values()) {
res.add(Arguments.of(httpImpl, clientGzip, serverGzip));
}
}
});
```
Using forEach() for the outer iteration sidesteps the nested-for
restriction, but it also makes the code less direct than a plain loop.
With the restriction relaxed, the same logic can be written more clearly:
```java
for (String httpImpl : HTTPSamplerFactory.getImplementations()) {
for (ClientGzip clientGzip : ClientGzip.values()) {
for (ServerGzip serverGzip : ServerGzip.values()) {
res.add(Arguments.of(httpImpl, clientGzip, serverGzip));
}
}
}
```
This is not a current Checkstyle failure. The issue is that the current
restriction seems to encourage a less readable style in places where nested
iteration is natural.
### Possible solution
1. Relax or remove <module name="NestedForDepth"/> from
config/checkstyle/checkstyle.xml
2. Clean up the stale NestedForDepth comment in TestDecompression
3. Optionally convert affected stream().forEach() wrappers back to plain for
loops
### Possible workarounds
Keep using Arrays.stream().forEach() for the outer iteration, although it
makes the test setup less straightforward.
### JMeter Version
5.6.3
### Java Version
_No response_
### OS Version
_No response_
--
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]