Skip to content

Commit

Permalink
refactor: add @nullable to methods who may return null (#127)
Browse files Browse the repository at this point in the history
Use this link to re-run the recipe: https://app.moderne.io/builder/ji8mLIdUI?organizationId=T3BlblJld3JpdGU%3D

Co-authored-by: Moderne <[email protected]>
  • Loading branch information
nielsdebruin and TeamModerne authored Oct 28, 2024
1 parent eedf3ad commit 33da18a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public Map<ResolvedGroupArtifactVersion, Set<MinimumDepthVulnerability>> upgrade
public static class Vulnerabilities {
Map<ResolvedGroupArtifactVersion, Set<MinimumDepthVulnerability>> gavToVulnerabilities;

public Set<MinimumDepthVulnerability> computeIfAbsent(ResolvedGroupArtifactVersion gav, Function<ResolvedGroupArtifactVersion, Set<MinimumDepthVulnerability>> mappingFunction) {
public @Nullable Set<MinimumDepthVulnerability> computeIfAbsent(ResolvedGroupArtifactVersion gav, Function<ResolvedGroupArtifactVersion, Set<MinimumDepthVulnerability>> mappingFunction) {
return gavToVulnerabilities.computeIfAbsent(gav, mappingFunction);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.openrewrite.java.dependencies;

import org.jspecify.annotations.Nullable;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Recipe;
import org.openrewrite.TreeVisitor;
Expand All @@ -41,8 +42,9 @@ public String getDescription() {
@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
return new XmlIsoVisitor<ExecutionContext>() {

@Override
public Xml.Tag visitTag(Xml.Tag tag, ExecutionContext ctx) {
public Xml.@Nullable Tag visitTag(Xml.Tag tag, ExecutionContext ctx) {
Xml.Tag t = super.visitTag(tag, ctx);
if (X_PATH_MATCHER.matches(getCursor())) {
Optional<Xml.Attribute> untilAttribute = t.getAttributes().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.openrewrite.java.dependencies.internal;

import org.jspecify.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand All @@ -27,7 +29,7 @@ public class VersionParser {
public VersionParser() {
}

public Version transform(String original) {
public @Nullable Version transform(String original) {
return cache.computeIfAbsent(original, this::parse);
}

Expand Down

0 comments on commit 33da18a

Please sign in to comment.