apache / apache/druid

Prohibit creating collections from stream.collect(...) using Structural Search inspection

Open
#8,241 0 comments 0 reactions 0 assignees View on GitHub
Area - Automation/Static Analysis Contributions Welcome
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.