-
Notifications
You must be signed in to change notification settings - Fork 68
Fixing several spotbugs warnings #1030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.