casid / jte

Secure and speedy templates for Java and Kotlin.
https://jte.gg
Apache License 2.0
737 stars 54 forks source link

Give TemplateDescriptions proper equals() and hashCode() #312

Closed MariusVolkhart closed 6 months ago

MariusVolkhart commented 6 months ago

These types are frequently used in Sets. Accordingly, they'll be hashed, and so should have proper hashCode() and equals() implementations.

The implementations I chose were a best-effort guess as to the identity of the models. ClassInfo was particularly challenging as it has a mutable field and I found it challenging to figure out the difference between the various types of names.

codecov[bot] commented 6 months ago

Codecov Report

Attention: 13 lines in your changes are missing coverage. Please review.

Comparison is base (0c83398) 91.20% compared to head (f03d977) 90.83%. Report is 2 commits behind head on main.

:exclamation: Current head f03d977 differs from pull request most recent head 85c2f6c. Consider uploading reports for the commit 85c2f6c to get more accurate results

Files Patch % Lines
...extensionsupport/ExtensionTemplateDescription.java 0.00% 8 Missing :warning:
...untime/src/main/java/gg/jte/runtime/ClassInfo.java 0.00% 5 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #312 +/- ## ============================================ - Coverage 91.20% 90.83% -0.38% Complexity 1204 1204 ============================================ Files 76 76 Lines 3139 3152 +13 Branches 489 492 +3 ============================================ Hits 2863 2863 - Misses 167 180 +13 Partials 109 109 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

casid commented 6 months ago

Thanks!

Looks good, but could you add small tests to make the codecov report happy?

MariusVolkhart commented 6 months ago

@marcospereira Thanks for the review, and sorry for making you go through such rookie stuff. I've updated my IDE config for this project to hopefully avoid code style issues in the future. Applied Objects.hash() as you suggested. @casid tests added.

casid commented 6 months ago

Thank you!