-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
XXX-XXX Prefer jOOQs fetch().stream() over directly .stream()'ing
- Loading branch information
1 parent
844ef84
commit 1489ec5
Showing
6 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/JooqRules.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package tech.picnic.errorprone.refasterrules; | ||
|
||
import com.google.errorprone.refaster.annotation.AfterTemplate; | ||
import com.google.errorprone.refaster.annotation.BeforeTemplate; | ||
import java.util.stream.Stream; | ||
import org.jooq.Record; | ||
import org.jooq.ResultQuery; | ||
import tech.picnic.errorprone.refaster.annotation.Description; | ||
import tech.picnic.errorprone.refaster.annotation.OnlineDocumentation; | ||
|
||
@OnlineDocumentation | ||
final class JooqRules { | ||
private JooqRules() {} | ||
|
||
/** Prefer eagerly fetching data over (lazy) streaming to avoid potentially leaking resources. */ | ||
@Description( | ||
"Prefer eagerly fetching data over (lazy) streaming to avoid potentially leaking resources.") | ||
static final class ResultQueryFetchStream { | ||
@BeforeTemplate | ||
Stream<?> before(ResultQuery<? extends Record> resultQuery) { | ||
return resultQuery.stream(); | ||
} | ||
|
||
@AfterTemplate | ||
Stream<?> after(ResultQuery<? extends Record> resultQuery) { | ||
return resultQuery.fetch().stream(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...e-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/JooqRulesTestInput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package tech.picnic.errorprone.refasterrules; | ||
|
||
import java.util.stream.Stream; | ||
import org.jooq.impl.DSL; | ||
import tech.picnic.errorprone.refaster.test.RefasterRuleCollectionTestCase; | ||
|
||
final class JooqRulesTest implements RefasterRuleCollectionTestCase { | ||
Stream<?> testResultQueryFetchStream() { | ||
return DSL.select().stream(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/JooqRulesTestOutput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package tech.picnic.errorprone.refasterrules; | ||
|
||
import java.util.stream.Stream; | ||
import org.jooq.impl.DSL; | ||
import tech.picnic.errorprone.refaster.test.RefasterRuleCollectionTestCase; | ||
|
||
final class JooqRulesTest implements RefasterRuleCollectionTestCase { | ||
Stream<?> testResultQueryFetchStream() { | ||
return DSL.select().fetch().stream(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters