Skip to content

Commit f64d2c7

Browse files
authored
Add immaculate rule that forbits @NotNull in patches (#1785)
1 parent b13ec03 commit f64d2c7

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

build.gradle

+12
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,18 @@ immaculate {
142142
return sb.toString()
143143
}
144144

145+
// Disallow explicit not null in patches, it's always implied.
146+
custom 'noNotNull', { String fileContents ->
147+
fileContents.eachLine {
148+
if (!it.startsWith("+")) return
149+
if (it.contains('@NotNull') || it.contains('@Nonnull')
150+
|| it.contains('@org.jetbrains.annotations.NotNull')
151+
|| it.contains('@javax.annotation.Nonnull')) {
152+
throw new GradleException('@NotNull and @Nonnull are disallowed.')
153+
}
154+
}
155+
}
156+
145157
//Replace any FQN versions of javax.annotation.Nullable with the jetbrains variant
146158
custom 'jetbrainsNullablePatches', { String fileContents ->
147159
fileContents.replace('@javax.annotation.Nullable', '@org.jetbrains.annotations.Nullable')

patches/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
+ }
5656
+
5757
+ @Override // FORGE: Get render types based on the selectors matched by the given block state
58-
+ public net.neoforged.neoforge.client.ChunkRenderTypeSet getRenderTypes(@org.jetbrains.annotations.NotNull BlockState state, @org.jetbrains.annotations.NotNull RandomSource rand, @org.jetbrains.annotations.NotNull net.neoforged.neoforge.client.model.data.ModelData data) {
58+
+ public net.neoforged.neoforge.client.ChunkRenderTypeSet getRenderTypes(BlockState state, RandomSource rand, net.neoforged.neoforge.client.model.data.ModelData data) {
5959
+ var renderTypeSets = new java.util.LinkedList<net.neoforged.neoforge.client.ChunkRenderTypeSet>();
6060
+ var selectors = getSelectors(state);
6161
+ for (int i = 0; i < selectors.length(); i++)

0 commit comments

Comments
 (0)