Skip to content

Commit

Permalink
Add immaculate rule that forbits @NotNull in patches (#1785)
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n authored Dec 18, 2024
1 parent b13ec03 commit f64d2c7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ immaculate {
return sb.toString()
}

// Disallow explicit not null in patches, it's always implied.
custom 'noNotNull', { String fileContents ->
fileContents.eachLine {
if (!it.startsWith("+")) return
if (it.contains('@NotNull') || it.contains('@Nonnull')
|| it.contains('@org.jetbrains.annotations.NotNull')
|| it.contains('@javax.annotation.Nonnull')) {
throw new GradleException('@NotNull and @Nonnull are disallowed.')
}
}
}

//Replace any FQN versions of javax.annotation.Nullable with the jetbrains variant
custom 'jetbrainsNullablePatches', { String fileContents ->
fileContents.replace('@javax.annotation.Nullable', '@org.jetbrains.annotations.Nullable')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
+ }
+
+ @Override // FORGE: Get render types based on the selectors matched by the given block state
+ 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) {
+ public net.neoforged.neoforge.client.ChunkRenderTypeSet getRenderTypes(BlockState state, RandomSource rand, net.neoforged.neoforge.client.model.data.ModelData data) {
+ var renderTypeSets = new java.util.LinkedList<net.neoforged.neoforge.client.ChunkRenderTypeSet>();
+ var selectors = getSelectors(state);
+ for (int i = 0; i < selectors.length(); i++)
Expand Down

0 comments on commit f64d2c7

Please sign in to comment.