Skip to content
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

[Task] Clean up Spotbugs deficiencies or suppress #113

Closed
andrewazores opened this issue Oct 19, 2023 · 0 comments · Fixed by #120
Closed

[Task] Clean up Spotbugs deficiencies or suppress #113

andrewazores opened this issue Oct 19, 2023 · 0 comments · Fixed by #120
Assignees
Labels
chore Refactor, rename, cleanup, etc.

Comments

@andrewazores
Copy link
Member

andrewazores commented Oct 19, 2023

#112 turned on Spotbugs, which reveals that there are several potential problem areas identified already:

https://github.com/cryostatio/cryostat3/actions/runs/6579676143/job/17876067218#step:15:1595

[INFO] --- spotbugs:4.7.3.6:check (spotbugs) @ cryostat3 ---
[INFO] BugInstance size is 34
[INFO] Error size is 0
[INFO] Total bugs: 34
Error:  Medium: Dead store to pod in io.cryostat.discovery.ContainerDiscovery.handleContainerEvent(ContainerDiscovery$ContainerSpec, Target$EventKind) [io.cryostat.discovery.ContainerDiscovery] At ContainerDiscovery.java:[line 341] DLS_DEAD_LOCAL_STORE
Error:  High: io.cryostat.discovery.DiscoveryNode.NODE_TYPE isn't final but should be [io.cryostat.discovery.DiscoveryNode] At DiscoveryNode.java:[line 58] MS_SHOULD_BE_FINAL
Error:  High: io.cryostat.discovery.DiscoveryNode.POD isn't final but should be [io.cryostat.discovery.DiscoveryNode] At DiscoveryNode.java:[line 61] MS_SHOULD_BE_FINAL
Error:  High: io.cryostat.discovery.DiscoveryNode.REALM isn't final but should be [io.cryostat.discovery.DiscoveryNode] At DiscoveryNode.java:[line 60] MS_SHOULD_BE_FINAL
Error:  High: io.cryostat.discovery.DiscoveryNode.UNIVERSE isn't final but should be [io.cryostat.discovery.DiscoveryNode] At DiscoveryNode.java:[line 59] MS_SHOULD_BE_FINAL
Error:  High: Method io.cryostat.discovery.DiscoveryNode$Listener.onMessage(Target$TargetDiscovery) seems to be useless [io.cryostat.discovery.DiscoveryNode$Listener] At DiscoveryNode.java:[line 167] UC_USELESS_VOID_METHOD
Error:  High: Found reliance on default encoding in io.cryostat.discovery.DiscoveryPlugin$PluginCallback$AuthorizationFilter.filter(ClientRequestContext): String.getBytes() [io.cryostat.discovery.DiscoveryPlugin$PluginCallback$AuthorizationFilter] At DiscoveryPlugin.java:[line 145] DM_DEFAULT_ENCODING
Error:  High: Null pointer dereference of credential in io.cryostat.discovery.DiscoveryPlugin$PluginCallback$AuthorizationFilter.filter(ClientRequestContext) [io.cryostat.discovery.DiscoveryPlugin$PluginCallback$AuthorizationFilter] Dereferenced at DiscoveryPlugin.java:[line 140] NP_ALWAYS_NULL
Error:  Medium: io.cryostat.events.SerializableEventTypeInfo.category() may expose internal representation by returning SerializableEventTypeInfo.category [io.cryostat.events.SerializableEventTypeInfo] At SerializableEventTypeInfo.java:[line 26] EI_EXPOSE_REP
Error:  Medium: io.cryostat.events.SerializableEventTypeInfo.options() may expose internal representation by returning SerializableEventTypeInfo.options [io.cryostat.events.SerializableEventTypeInfo] At SerializableEventTypeInfo.java:[line 26] EI_EXPOSE_REP
Error:  Medium: io.cryostat.expressions.MatchExpression$ExpressionEvent.expression() may expose internal representation by returning MatchExpression$ExpressionEvent.expression [io.cryostat.expressions.MatchExpression$ExpressionEvent] At MatchExpression.java:[line 148] EI_EXPOSE_REP
Error:  Medium: new io.cryostat.expressions.MatchExpression$ExpressionEvent(MatchExpression$ExpressionEventCategory, MatchExpression) may expose internal representation by storing an externally mutable object into MatchExpression$ExpressionEvent.expression [io.cryostat.expressions.MatchExpression$ExpressionEvent] At MatchExpression.java:[line 149] EI_EXPOSE_REP2
Error:  Medium: io.cryostat.expressions.MatchExpression$MatchedExpression.targets() may expose internal representation by returning MatchExpression$MatchedExpression.targets [io.cryostat.expressions.MatchExpression$MatchedExpression] At MatchExpression.java:[line 92] EI_EXPOSE_REP
Error:  Medium: new io.cryostat.expressions.MatchExpression$MatchedExpression(Long, String, Collection) may expose internal representation by storing an externally mutable object into MatchExpression$MatchedExpression.targets [io.cryostat.expressions.MatchExpression$MatchedExpression] At MatchExpression.java:[line 94] EI_EXPOSE_REP2
Error:  Medium: Unread field: io.cryostat.expressions.MatchExpressionEvaluator$MatchExpressionAppliesEvent.matchExpression [io.cryostat.expressions.MatchExpressionEvaluator$MatchExpressionAppliesEvent] At MatchExpressionEvaluator.java:[line 183] URF_UNREAD_FIELD
Error:  Medium: io.cryostat.recordings.EventOptionsBuilder.build() may expose internal representation by returning EventOptionsBuilder.map [io.cryostat.recordings.EventOptionsBuilder] At EventOptionsBuilder.java:[line 90] EI_EXPOSE_REP
Error:  High: Found reliance on default encoding in io.cryostat.recordings.RecordingHelper.createMetadataTagging(Recordings$Metadata): String.getBytes() [io.cryostat.recordings.RecordingHelper] At RecordingHelper.java:[line 626] DM_DEFAULT_ENCODING
Error:  High: Found reliance on default encoding in io.cryostat.recordings.RecordingHelper.lambda$createMetadataTagging$9(Map$Entry): String.getBytes() [io.cryostat.recordings.RecordingHelper, io.cryostat.recordings.RecordingHelper] At RecordingHelper.java:[line 611]Another occurrence at RecordingHelper.java:[line 614] DM_DEFAULT_ENCODING
Error:  Medium: Unread field: io.cryostat.recordings.RecordingHelper.httpTimeoutSeconds; should this field be static? [io.cryostat.recordings.RecordingHelper] At RecordingHelper.java:[line 112] SS_SHOULD_BE_STATIC
Error:  High: Found reliance on default encoding in io.cryostat.recordings.Recordings.lambda$createMetadataTagging$33(Map$Entry): String.getBytes() [io.cryostat.recordings.Recordings, io.cryostat.recordings.Recordings] At Recordings.java:[line 852]Another occurrence at Recordings.java:[line 855] DM_DEFAULT_ENCODING
Error:  Medium: io.cryostat.recordings.Recordings$ArchivedRecordingDirectory.recordings() may expose internal representation by returning Recordings$ArchivedRecordingDirectory.recordings [io.cryostat.recordings.Recordings$ArchivedRecordingDirectory] At Recordings.java:[line 957] EI_EXPOSE_REP
Error:  Medium: io.cryostat.recordings.Recordings$Metadata.labels() may expose internal representation by returning Recordings$Metadata.labels [io.cryostat.recordings.Recordings$Metadata] At Recordings.java:[line 968] EI_EXPOSE_REP
Error:  Medium: new io.cryostat.recordings.Recordings$Metadata(Map, Instant) may expose internal representation by storing an externally mutable object into Recordings$Metadata.labels [io.cryostat.recordings.Recordings$Metadata] At Recordings.java:[line 969] EI_EXPOSE_REP2
Error:  Medium: Unread public/protected field: io.cryostat.rules.Rule.description [io.cryostat.rules.Rules] At Rules.java:[line 120] URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD
Error:  Medium: io.cryostat.rules.Rule$RuleEvent.rule() may expose internal representation by returning Rule$RuleEvent.rule [io.cryostat.rules.Rule$RuleEvent] At Rule.java:[line 124] EI_EXPOSE_REP
Error:  Medium: new io.cryostat.rules.Rule$RuleEvent(Rule$RuleEventCategory, Rule) may expose internal representation by storing an externally mutable object into Rule$RuleEvent.rule [io.cryostat.rules.Rule$RuleEvent] At Rule.java:[line 125] EI_EXPOSE_REP2
Error:  Medium: io.cryostat.rules.RuleService$RuleRecording.recording() may expose internal representation by returning RuleService$RuleRecording.recording [io.cryostat.rules.RuleService$RuleRecording] At RuleService.java:[line 284] EI_EXPOSE_REP
Error:  Medium: io.cryostat.rules.RuleService$RuleRecording.rule() may expose internal representation by returning RuleService$RuleRecording.rule [io.cryostat.rules.RuleService$RuleRecording] At RuleService.java:[line 284] EI_EXPOSE_REP
Error:  Medium: new io.cryostat.rules.RuleService$RuleRecording(Rule, ActiveRecording) may expose internal representation by storing an externally mutable object into RuleService$RuleRecording.recording [io.cryostat.rules.RuleService$RuleRecording] At RuleService.java:[line 285] EI_EXPOSE_REP2
Error:  Medium: new io.cryostat.rules.RuleService$RuleRecording(Rule, ActiveRecording) may expose internal representation by storing an externally mutable object into RuleService$RuleRecording.rule [io.cryostat.rules.RuleService$RuleRecording] At RuleService.java:[line 285] EI_EXPOSE_REP2
Error:  Medium: io.cryostat.targets.Target$Annotations.cryostat() may expose internal representation by returning Target$Annotations.cryostat [io.cryostat.targets.Target$Annotations] At Target.java:[line 128] EI_EXPOSE_REP
Error:  Medium: io.cryostat.targets.Target$Annotations.platform() may expose internal representation by returning Target$Annotations.platform [io.cryostat.targets.Target$Annotations] At Target.java:[line 128] EI_EXPOSE_REP
Error:  Medium: io.cryostat.targets.Target$TargetDiscovery.serviceRef() may expose internal representation by returning Target$TargetDiscovery.serviceRef [io.cryostat.targets.Target$TargetDiscovery] At Target.java:[line 174] EI_EXPOSE_REP
Error:  Medium: new io.cryostat.targets.Target$TargetDiscovery(Target$EventKind, Target) may expose internal representation by storing an externally mutable object into Target$TargetDiscovery.serviceRef [io.cryostat.targets.Target$TargetDiscovery] At Target.java:[line 175] EI_EXPOSE_REP2
[INFO] 


To see bug detail using the Spotbugs GUI, use the following command "mvn spotbugs:gui"



[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  04:45 min
[INFO] Finished at: 2023-10-19T20:13:21Z
[INFO] ------------------------------------------------------------------------
Error:  Failed to execute goal com.github.spotbugs:spotbugs-maven-plugin:4.7.3.6:check (spotbugs) on project cryostat3: failed with 34 bugs and 0 errors -> [Help 1]

Each of these should be checked and either corrected (the Spotbugs error code can be referenced against the bug descriptions list for potential resolutions), or if it is a false positive then @SuppressFBWarnings can be added to suppress the warning and allow the CI to pass.

@andrewazores andrewazores added the chore Refactor, rename, cleanup, etc. label Oct 19, 2023
@andrewazores andrewazores moved this to Todo in 3.0.0 release Oct 19, 2023
@andrewazores andrewazores self-assigned this Oct 24, 2023
@andrewazores andrewazores moved this from Todo to In Progress in 3.0.0 release Oct 24, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in 3.0.0 release Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Refactor, rename, cleanup, etc.
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant