adding the ensure compiler plugin #657
Labels
No labels
Area-Assets
Area-Backend
Area-Conduits
Area-Datapacks
Area-Lang
Area-Mod Compat
Area-Parity
Area-Rendering
Good first issue
MC-1.19.2
MC-1.20.1
MC-1.20.4
MC-1.20.6
MC-1.21
MC-1.21.1
Modtoberfest
P-0-High
P-1-Medium
P-2-Low
Status-Awaiting Response
Status-Behind-Flag
Status-Blocked
Status-Cannot Reproduce
Status-Duplicate
Status-Help Wanted
Status-Incomplete Report
Status-Invalid
Status-Needs LTS Backport
Status-Needs Updating
Status-Stale
Status-To Implement
Status-Triage
Status-Wontfix
Status-Wontmerge
Type-Backport
Type-Bug
Type-Documentation
Type-Enhancement
Type-Question
Type-RFC
Type-Suggestion
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Team-EnderIO/EnderIO#657
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/ensureplugin"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
This PR adds the Ensure Compiler Plugin, it allows the usage of Ensure[XYZ] Annotations to add bytecode to check certain things. Currently added are null checks, range checks and Side Checks.
How to add checks
New checks can be added by creating a new Transformer, adding it to the Service, let it Target a new Ensure Annotation using the Target Annotation and then add the code checks in Transformer#transform.
TODO
Checklist
@ -0,0 +1,57 @@package me.liliandev.ensure;🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck> reported by reviewdog 🐶
Missing package-info.java file.
@ -0,0 +1,52 @@package me.liliandev.ensure.ensures;🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck> reported by reviewdog 🐶
'if' construct must use '{}'s.
@ -0,0 +1,46 @@package me.liliandev.ensure.ensures;🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck> reported by reviewdog 🐶
Missing package-info.java file.
🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck> reported by reviewdog 🐶
'if' construct must use '{}'s.
@ -0,0 +1,54 @@package me.liliandev.ensure.setup;🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck> reported by reviewdog 🐶
Name 'expectedPackages' must match pattern '^[A-Z][A-Z0-9](_[A-Z0-9]+)$'.
@ -0,0 +1,9 @@package me.liliandev.ensure.setup.jdkdummy;🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck> reported by reviewdog 🐶
Missing package-info.java file.
@ -0,0 +1,12 @@package me.liliandev.ensure.setup.jdkdummy;🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck> reported by reviewdog 🐶
Name 'staticObj' must match pattern '^[A-Z][A-Z0-9](_[A-Z0-9]+)$'.
@ -0,0 +1,13 @@package me.liliandev.ensure.transformerutils;🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck> reported by reviewdog 🐶
Missing package-info.java file.
@ -0,0 +1,112 @@package me.liliandev.ensure.transformerutils;🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck> reported by reviewdog 🐶
Name 'transformers' must match pattern '^[A-Z][A-Z0-9](_[A-Z0-9]+)$'.
🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck> reported by reviewdog 🐶
'if' construct must use '{}'s.
Looks good to me - just one EnsureSide that needs double checking! Thank you
@ -106,7 +109,8 @@ public class ConduitBlockEntity extends EnderBlockEntity {updateConnectionToData(conduitType);Changed from Server to Client - is that right?
@ -106,7 +109,8 @@ public class ConduitBlockEntity extends EnderBlockEntity {updateConnectionToData(conduitType);probably not, I'll double check it
Would you like me to re-review this, or were you hoping for review from another team member? Cheers!
a review from another maintainer would be appreciated
So this looks good to me, just some small style things and a question
@ -91,7 +94,7 @@ public class ConduitBlockEntity extends EnderBlockEntity {/**I think it adds an extra whitespace?
@ -0,0 +1,57 @@package me.liliandev.ensure;this comment can be removed now?
@ -0,0 +14,4 @@* min is inclusive* max is exclusive*/public @interface EnsureInRange {This isn't currently used right?
@ -0,0 +12,4 @@/*** Adds a null check to non primitive parameters*/public @interface EnsureNotNull {This isn't currently used right?
@ -0,0 +14,4 @@* min is inclusive* max is exclusive*/public @interface EnsureInRange {yes, I wanted to have it just in case. this can ensure nonnegativity with 0 and long max value and a spot in conduit code
@ -0,0 +12,4 @@/*** Adds a null check to non primitive parameters*/public @interface EnsureNotNull {yes, but I had a few ideas where it makes sense so I added it without checking all potential spots and using it atm
@ -0,0 +12,4 @@/*** Adds a null check to non primitive parameters*/public @interface EnsureNotNull {Yeah makes sense
@ -0,0 +1,57 @@package me.liliandev.ensure;reversed was a newer feature and I wanted to make sure the first parameter check is added last because each check is added to the front so the first ensure on a parameter will be the first one to be checked, but it doesn't really matter
@ -91,7 +94,7 @@ public class ConduitBlockEntity extends EnderBlockEntity {/**I think it did it everywhere where the annotation is used? Does our style guide not catch that?
@ -91,7 +94,7 @@ public class ConduitBlockEntity extends EnderBlockEntity {/**yeah, happened when I've pasted the new annotations in, I'm surprised the style checker didn't catch that. I've fixed them now