Fix Nullwarnings - B#14802
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||
|
capturing current state null warnings here for reference Details |
I think nullaway only prints the first ~100 warnings. |
|
JBang error was: That dependency was introduced at #14287 Interestingly, the line before works: |
…es/jablib/src/main/resources/csl-locales-50e46eb * upstream/main: (119 commits) chore(sbom): update CycloneDX SBOM files (#14813) Add "preferences" constant to ServiceLocator initialization (#14810) adjust bom generation to only use runtime (#14809) Remove (nearly) obsolete hint in ghprcomment.yml Update dependency org.apache.commons:commons-lang3 to v3.20.0 (#14808) Fix Nullwarnings - B (#14802) Add https Add ouput Fix stale (again) Fix output Fix re-downloading of ltwa file Chore(deps): Bump jablib/src/main/resources/csl-styles from `9bb1fc1` to `0201999` (#14796) Chore(deps): Bump org.ow2.asm:asm from 9.9 to 9.9.1 in /versions (#14799) Chore(deps): Bump org.controlsfx:controlsfx in /versions (#14800) Chore(deps): Bump org.postgresql:postgresql in /versions (#14798) Chore(deps): Bump jablib/src/main/abbrv.jabref.org (#14795) Chore(deps): Bump org.apache.logging.log4j:log4j-to-slf4j in /versions (#14797) Chore(deps): Bump org.apache.commons:commons-text from 1.14.0 to 1.15.0 in /versions (#14801) fix postgres for arm (#14792) Docs: minor grammar and clarity fixes in privacy policy (#14786) ...
User description
Follow up to #14116
Steps to test
Run JabRef
Mandatory checks
CHANGELOG.mdin a way that is understandable for the average user (if change is visible to the user)PR Type
Enhancement
Description
Add nullability annotations to improve null-safety across multiple model classes
Replace manual null checks with Optional-based patterns for cleaner code
Update JavaDoc comments to use JSpecify format (/// instead of /** */)
Mark classes and methods with @NullMarked and @Nullable/@nonnull annotations
Diagram Walkthrough
File Walkthrough
StringUtil.java
Add nullability annotations to string utility methodsjablib/src/main/java/org/jabref/logic/util/strings/StringUtil.java
@NonNulland@Nullableannotations from jspecifyisNullOrEmpty()parameter with@NullableisBlank()string parameter with@NullableisBlank(Optional)parameter with@NonNullFieldChange.java
Apply @NullMarked and mark nullable field valuesjablib/src/main/java/org/jabref/model/FieldChange.java
@NonNullimport with@NullMarkedand@Nullableimports@NullMarkedannotationoldValueandnewValuefields with@Nullable@NonNullannotations from constructor parameters (implicit via@NullMarked)
@NullableBibDatabase.java
Refactor null handling with Optional patternsjablib/src/main/java/org/jabref/model/database/BibDatabase.java
preambleandsharedDatabaseIDfields with@NullablegetPreamble()to useOptional.ofNullable().filter()pattern@NonNullreturn type annotation togetPreamble()setPreamble()parameter with@NullableresolveString()return type fromStringtoOptionalresolveContent()to handleOptionalfromresolveString()BibEntry.java
Refactor getCitationKey to use Optional patternjablib/src/main/java/org/jabref/model/entry/BibEntry.java
@NonNullreturn type annotation togetCitationKey()Optional.ofNullable().filter()patternFieldChangedEvent.java
Add nullability annotations to event methodjablib/src/main/java/org/jabref/model/entry/event/FieldChangedEvent.java
@NullableannotationcomputeMajorCharacterChange()parameters with@NullableMetaData.java
Mark metadata fields as nullablejablib/src/main/java/org/jabref/model/metadata/MetaData.java
@Nullableannotation@Nullable:encoding,saveOrder,defaultCiteKeyPattern,saveActions,mode,librarySpecificFileDirectory,versionDBStructure