Prohibit creating collections from stream.collect(...) using Structural Search inspection
- Dominant language
- Java
- Stars
- 14.1k
- Forks
- 3.8k
- Avg merge
- 2d 58m
- Merged PRs (30d)
- 233
Description
1.
```
new $Coll$($stream$.collect($collector$))
```
The whole match filter: type=java.util.Collection, check "Within type hierarchy".
2. The same about `Map`
3.
```
$Colls$.$factory$($stream$.collect($collector$))
```
Filter on `Colls`: regex `Lists|Sets|Maps` - this is to catch Guava's factory methods like `Sets.newHashSet()`.
There are violations of these rules in the codebase. See the instruction about how to add a rule [here](https://github.com/apache/incubator-druid/blob/ac856fe4c179093c0a5e309a2e988c54a86e89c5/dev/teamcity.md#creating-a-custom-inspection-from-a-structural-search-pattern).
Contributor guide
Research direction
Start with the custom-inspection instructions in dev/teamcity.md and inspect existing structural-search inspection definitions. Add rules for collection and map constructors and for Lists, Sets, and Maps factory calls around stream.collect(...), then verify that the existing violations are reported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100