Bram-Hub / LEGUP

Logic Engine for Grid-Using Puzzles - a better way to learn formal logic
GNU General Public License v3.0
33 stars 82 forks source link

[ENHANCEMENT] Add JetBrains Annotations #731

Open FisherLuba opened 8 months ago

FisherLuba commented 8 months ago

Describe the current behavior of what you're trying to improve. If your enhancement request related to a problem, please also describe the problem.

It can be hard to tell what objects can be null and what shouldn't be.

Describe the improvement you'd like

I think adding JetBrains Annotations could be helpful to make some things in the code more clear. Some nice ones are @Nullable, @NotNull, and @Contract, especially for classes that are meant to be used in more than just one puzzle. @Contract can be used to specify whether a method is pure and whether it mutates method parameters, along with describing other behaviors of a method. Another benefit is that IntelliJ can generate warnings based on the annotations, for example if you pass a nullable object to a method parameter marked @NotNull without checking if it's null first.

Using both @Nullable and @NotNull isn't necessary, if this request is approved I think one or the other should be used and added to the developer guidelines. I think using @Nullable and assuming @NotNull is good, but either way works.

Describe alternatives you've considered

Commenting code is another way to show what can be null and describe method behaviors, but I think annotations are more clear and they can also generate warnings in IntelliJ.

Additional Context

This wouldn't change any behavior of the code, it would just add some nice documentation and help prevent errors and bugs.