Skip to content

Commit

Permalink
refactor: Move @Nullable method annotations to the return type
Browse files Browse the repository at this point in the history
  • Loading branch information
jkschneider and TeamModerne committed Jul 16, 2024
1 parent b8ff785 commit d950f96
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,7 @@ public ResultsContainer(Path projectRoot, Collection<Result> results) {
}
}

@Nullable
public RuntimeException getFirstException() {
public @Nullable RuntimeException getFirstException() {
for (Result result : generated) {
for (RuntimeException error : getRecipeErrors(result)) {
return error;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/openrewrite/maven/AbstractRewriteMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ private void collectBasePaths(MavenProject project, Set<Path> paths, Path localR
}
}

@Nullable
protected URLClassLoader getRecipeArtifactCoordinatesClassloader() throws MojoExecutionException {
protected @Nullable URLClassLoader getRecipeArtifactCoordinatesClassloader() throws MojoExecutionException {
if (getRecipeArtifactCoordinates().isEmpty()) {
return null;
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/openrewrite/maven/CycloneDxBomMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public void execute() throws MojoExecutionException {
}
}

@Nullable
private File buildCycloneDxBom(Xml.Document pomAst) {
private @Nullable File buildCycloneDxBom(Xml.Document pomAst) {
try {
File cycloneDxBom = new File(project.getBuild().getDirectory(),
project.getArtifactId() + "-" + project.getVersion() + "-cyclonedx.xml");
Expand Down
12 changes: 4 additions & 8 deletions src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,7 @@ private Stream<SourceFile> processTestSources(
.map(addProvenance(baseDir, markers, null));
}

@Nullable
private String getKotlinDirectory(@Nullable String sourceDirectory) {
private @Nullable String getKotlinDirectory(@Nullable String sourceDirectory) {
if (sourceDirectory == null) {
return null;
}
Expand All @@ -511,8 +510,7 @@ private static JavaSourceSet sourceSet(String name, List<Path> dependencies, Jav
return JavaSourceSet.build(name, dependencies, typeCache, false);
}

@Nullable
public Xml.Document parseMaven(MavenProject mavenProject, List<Marker> projectProvenance, ExecutionContext ctx) {
public @Nullable Xml.Document parseMaven(MavenProject mavenProject, List<Marker> projectProvenance, ExecutionContext ctx) {
return parseMaven(singletonList(mavenProject), singletonMap(mavenProject, projectProvenance), ctx).get(mavenProject);
}

Expand Down Expand Up @@ -708,8 +706,7 @@ public MavenSettings buildSettings() {
return new MavenSettings(mer.getLocalRepositoryPath().toString(), profiles, activeProfiles, mirrors, servers);
}

@Nullable
private static RawRepositories buildRawRepositories(@Nullable List<Repository> repositoriesToMap) {
private static @Nullable RawRepositories buildRawRepositories(@Nullable List<Repository> repositoriesToMap) {
if (repositoriesToMap == null) {
return null;
}
Expand Down Expand Up @@ -768,8 +765,7 @@ private static List<Path> listSources(Path sourceDirectory, String extension) th
}
}

@Nullable
private GitProvenance gitProvenance(Path baseDir, @Nullable BuildEnvironment buildEnvironment) {
private @Nullable GitProvenance gitProvenance(Path baseDir, @Nullable BuildEnvironment buildEnvironment) {
try {
return GitProvenance.fromProjectDirectory(baseDir, buildEnvironment);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public MavenPomCacheBuilder(Log logger) {
this.logger = logger;
}

@Nullable
public MavenPomCache build(@Nullable String pomCacheDirectory) {
public @Nullable MavenPomCache build(@Nullable String pomCacheDirectory) {
if (isJvm64Bit()) {
try {
if (pomCacheDirectory == null) {
Expand Down

0 comments on commit d950f96

Please sign in to comment.