Fixing several spotbugs warnings#1030
Conversation
| */ | ||
| @Parameter | ||
| private List<String> mojoDependencies = null; | ||
| private final List<String> mojoDependencies = new ArrayList<>(); |
There was a problem hiding this comment.
It can not be a final ... Maven need a possibility to set this filed during plugin configuration
|
@MateusJunior7 Hi, as every PR you created includes the previous commits I closed the older ones, as this here contains all things you changed. I changed the title, but not sure if you want to rename it. Also see the requested change by @slawekjaranowski |
| request.setPluginDescriptor(extendPluginDescriptor(request)); | ||
|
|
||
| outputDirectory.mkdirs(); | ||
| if (!outputDirectory.exists()) { |
There was a problem hiding this comment.
would https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#createDirectories-java.nio.file.Path-java.nio.file.attribute.FileAttribute be more sensible to use here? It handles the case that the directory already exists, throwing appropriate exceptions for any other kinds of issue, so will likely be more descriptive than handling this manually. There is use of java.nio.file.Path further down this file as well, so the NIO API appears to already be in use.
I believe the whole snippet here would just become:
Files.createDirectories(outputDirectory.toPath());In Maven 4, I believe the outputDirectories parameter could itself be replaced with a java.nio.file.Path, since the latest version of Sisu supports both the URI and nio Path APIs out of the box... that'd remove the need to convert back from the old APIs at all.
This PR fixes a SpotBugs warning (REC_CATCH_EXCEPTION) in
DescriptorGeneratorMojo.generateIndex(), where a generic catch (Exception)
block was used even though the code only throws IOException.
The catch block was narrowed to IOException, improving clarity and preventing
overly broad exception handling.
After the change, the REC warning no longer appears in SpotBugs.