Skip to content

Commit

Permalink
enable nullaway on unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-manes committed Dec 16, 2024
1 parent e512b50 commit 2222e0a
Show file tree
Hide file tree
Showing 117 changed files with 903 additions and 419 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
if: steps.check_files.outputs.files_exists == 'true'
run: jq -c '.runs |= unique_by({tool, invocations, results})' < results.sarif > codacy.sarif
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
uses: github/codeql-action/upload-sarif@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
if: steps.check_files.outputs.files_exists == 'true'
continue-on-error: true
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ jobs:
java: ${{ env.JAVA_VERSION }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- name: Initialize CodeQL
uses: github/codeql-action/init@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
uses: github/codeql-action/init@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
with:
languages: java
- name: Autobuild
uses: github/codeql-action/autobuild@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
uses: github/codeql-action/autobuild@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
uses: github/codeql-action/analyze@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
2 changes: 1 addition & 1 deletion .github/workflows/dependency-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
with:
files: build/reports/dependency-check-report.sarif
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
uses: github/codeql-action/upload-sarif@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
if: steps.check_files.outputs.files_exists == 'true'
with:
sarif_file: build/reports/dependency-check-report.sarif
2 changes: 1 addition & 1 deletion .github/workflows/devskim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ jobs:
- name: Run DevSkim scanner
uses: microsoft/DevSkim-Action@914fa647b406c387000300b2f09bb28691be2b6d # v1.0.14
- name: Upload DevSkim scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
uses: github/codeql-action/upload-sarif@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
with:
sarif_file: devskim-results.sarif
4 changes: 2 additions & 2 deletions .github/workflows/qodana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ jobs:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: check -x test
- name: Qodana - Code Inspection
uses: JetBrains/qodana-action@31d6f3309b31c566758e1314a3d9ef0dff75ecbd # v2024.2.6
uses: JetBrains/qodana-action@b46847499776819f38aad1d4298e16e52f17c4c5 # v2024.3.2
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
with:
upload-result: true
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload SARIF file for GitHub Advanced Security Dashboard
uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
uses: github/codeql-action/upload-sarif@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
with:
sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json
2 changes: 1 addition & 1 deletion .github/workflows/scorecards-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ jobs:
path: results.sarif
retention-days: 5
- name: Upload to code-scanning
uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
uses: github/codeql-action/upload-sarif@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
with:
sarif_file: results.sarif
2 changes: 1 addition & 1 deletion .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
if: steps.check_files.outputs.files_exists == 'true'
run: jq -c '.runs[0].tool.driver.rules |= unique_by(.id)' < results.sarif > semgrep.sarif
- name: Upload SARIF file for GitHub Advanced Security Dashboard
uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
uses: github/codeql-action/upload-sarif@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
if: steps.check_files.outputs.files_exists == 'true'
continue-on-error: true
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/snyk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
with:
files: snyk.sarif
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
uses: github/codeql-action/upload-sarif@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
if: steps.check_files.outputs.files_exists == 'true'
with:
sarif_file: snyk.sarif
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spelling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
objects.githubusercontent.com:443
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Typos
uses: crate-ci/typos@2872c382bb9668d4baa5eade234dcbc0048ca2cf # v1.28.2
uses: crate-ci/typos@d1c850b2b5d502763520c25fb4a6a1128ad99bd9 # v1.28.3
2 changes: 1 addition & 1 deletion .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
with:
files: results.sarif
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
uses: github/codeql-action/upload-sarif@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
if: steps.check_files.outputs.files_exists == 'true'
with:
sarif_file: results.sarif
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jitwatch.out
.settings
.project
.gradle
.kotlin
.vscode
.idea
*.iml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3163,6 +3163,7 @@ <T> T expireAfterAccessOrder(boolean oldest, Function<@Nullable V, @Nullable V>
* @param mappingFunction the mapping function to compute a value
* @return the computed value
*/
@SuppressWarnings("NullAway")
<T> T snapshot(Iterable<Node<K, V>> iterable, Function<@Nullable V, @Nullable V> transformer,
Function<Stream<CacheEntry<K, V>>, T> mappingFunction) {
requireNonNull(mappingFunction);
Expand Down Expand Up @@ -3901,10 +3902,10 @@ public void run() {
*/
// public final void quietlyComplete() {}

@Override public void setRawResult(@Nullable Void v) {}
@Override public void complete(@Nullable Void value) {}
@Override public void completeExceptionally(Throwable ex) {}
@Override public void setRawResult(@Nullable Void value) {}
@Override public @Nullable Void getRawResult() { return null; }
@Override public void completeExceptionally(@Nullable Throwable t) {}
@Override public boolean cancel(boolean mayInterruptIfRunning) { return false; }
}

Expand Down Expand Up @@ -4009,6 +4010,7 @@ static final class BoundedPolicy<K, V> implements Policy<K, V> {
@Override public @Nullable V getIfPresentQuietly(K key) {
return transformer.apply(cache.getIfPresentQuietly(key));
}
@SuppressWarnings("NullAway")
@Override public @Nullable CacheEntry<K, V> getEntryIfPresentQuietly(K key) {
Node<K, V> node = cache.data.get(cache.nodeFactory.newLookupKey(key));
return (node == null) ? null : cache.nodeToCacheEntry(node, transformer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ interface LinkedDeque<E> extends Deque<E> {
*
* @param e the linked element
*/
boolean isFirst(E e);
boolean isFirst(@Nullable E e);

/**
* Returns if the element is at the back of the deque.
*
* @param e the linked element
*/
boolean isLast(E e);
boolean isLast(@Nullable E e);

/**
* Moves the element to the front of the deque so that it becomes the first element.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.collect.ImmutableMap.toImmutableMap;
import static com.google.common.truth.Truth.assertThat;
import static java.util.Objects.requireNonNull;
import static java.util.function.Function.identity;
import static org.junit.Assert.assertThrows;
import static org.mockito.ArgumentMatchers.any;
Expand Down Expand Up @@ -1841,7 +1842,9 @@ public void keySet_removeAll_partial(Map<Int, Int> map, CacheContext context) {
assertThat(map.keySet().removeAll(context.firstMiddleLastKeys())).isTrue();
assertThat(map).isEqualTo(expected);
assertThat(context).removalNotifications().withCause(EXPLICIT)
.contains(Maps.asMap(context.firstMiddleLastKeys(), context.original()::get)).exclusively();
.contains(Maps.toMap(context.firstMiddleLastKeys(),
key -> requireNonNull(context.original().get(key))))
.exclusively();
}

@CheckNoStats
Expand Down Expand Up @@ -2017,7 +2020,9 @@ public void keySet_retainAll_partial(Map<Int, Int> map, CacheContext context) {
assertThat(map.keySet().retainAll(expected.keySet())).isTrue();
assertThat(map).isEqualTo(expected);
assertThat(context).removalNotifications().withCause(EXPLICIT)
.contains(Maps.asMap(context.firstMiddleLastKeys(), context.original()::get)).exclusively();
.contains(Maps.toMap(context.firstMiddleLastKeys(),
key -> requireNonNull(context.original().get(key))))
.exclusively();
}

@CheckNoStats
Expand Down Expand Up @@ -2149,6 +2154,7 @@ public void keySpliterator_estimateSize(Map<Int, Int> map, CacheContext context)
/* --------------- Values --------------- */

@CheckNoStats
@SuppressWarnings("NullAway")
@Test(dataProvider = "caches")
@CacheSpec(removalListener = { Listener.DISABLED, Listener.REJECTING })
public void values_toArray_null(Map<Int, Int> map, CacheContext context) {
Expand Down Expand Up @@ -2249,7 +2255,8 @@ public void values_removeAll_none_populated(Map<Int, Int> map, CacheContext cont
public void values_removeAll_partial(Map<Int, Int> map, CacheContext context) {
var expected = new HashMap<>(context.original());
expected.keySet().removeAll(context.firstMiddleLastKeys());
var removed = Maps.asMap(context.firstMiddleLastKeys(), context.original()::get);
var removed = Maps.toMap(context.firstMiddleLastKeys(),
key -> requireNonNull(context.original().get(key)));

assertThat(map.values().removeAll(removed.values())).isTrue();
assertThat(map).isEqualTo(expected);
Expand Down Expand Up @@ -2418,7 +2425,8 @@ public void values_retainAll_none_populated(Map<Int, Int> map, CacheContext cont
public void values_retainAll_partial(Map<Int, Int> map, CacheContext context) {
var expected = new HashMap<>(context.original());
expected.keySet().removeAll(context.firstMiddleLastKeys());
var removed = Maps.asMap(context.firstMiddleLastKeys(), context.original()::get);
var removed = Maps.toMap(context.firstMiddleLastKeys(),
key -> requireNonNull(context.original().get(key)));

assertThat(map.values().retainAll(expected.values())).isTrue();
assertThat(map).isEqualTo(expected);
Expand Down Expand Up @@ -2678,7 +2686,8 @@ public void entrySet_removeAll_none_populated(Map<Int, Int> map, CacheContext co
@Test(dataProvider = "caches")
@CacheSpec(population = Population.FULL)
public void entrySet_removeAll_partial(Map<Int, Int> map, CacheContext context) {
var removed = Maps.asMap(context.firstMiddleLastKeys(), context.original()::get);
var removed = Maps.toMap(context.firstMiddleLastKeys(),
key -> requireNonNull(context.original().get(key)));
var expected = new HashMap<>(context.original());
expected.entrySet().removeAll(removed.entrySet());

Expand Down Expand Up @@ -2888,7 +2897,8 @@ public void entrySet_retainAll_none_populated(Map<Int, Int> map, CacheContext co
@Test(dataProvider = "caches")
@CacheSpec(population = Population.FULL)
public void entrySet_retainAll_partial(Map<Int, Int> map, CacheContext context) {
var removed = Maps.asMap(context.firstMiddleLastKeys(), context.original()::get);
var removed = Maps.toMap(context.firstMiddleLastKeys(),
key -> requireNonNull(context.original().get(key)));
var expected = new HashMap<>(context.original());
expected.entrySet().removeAll(removed.entrySet());

Expand Down
Loading

0 comments on commit 2222e0a

Please sign in to comment.