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

silence spotbugs warnings #1018

Closed
soloturn opened this issue Oct 28, 2023 · 3 comments
Closed

silence spotbugs warnings #1018

soloturn opened this issue Oct 28, 2023 · 3 comments

Comments

@soloturn
Copy link

i tried to silence a spotbugs warning with:

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

        @SuppressFBWarnings
        private T t;

but the dependency is not known. can you pleaes include it into the plugin so one does not need it extra in the project?

soloturn added a commit to soloturn/terasology that referenced this issue Oct 28, 2023
as a workaround, add dependency for spotbugs annotations, and create a
[ticket there so the spotbugs gradle plugin would include the dependency]
(spotbugs/spotbugs-gradle-plugin#1018).

see MovingBlocks#3859
soloturn added a commit to soloturn/terasology that referenced this issue Oct 28, 2023
as a workaround, add dependency for spotbugs annotations, and create a
[ticket there so the spotbugs gradle plugin would include the dependency]
(spotbugs/spotbugs-gradle-plugin#1018).

see here a motivation for inner type last rule. if we leave the rule we
should respect it, otherwise disable the rule.
https://stackoverflow.com/questions/25158939/what-motivation-is-behind-checkstyle-inner-type-last-rule

pmd warnings not yet addressed, there are some log guard related, which
are false positive.

see MovingBlocks#3859

typehandlerlibrary qa, checkstyle

squash to qa
soloturn added a commit to soloturn/terasology that referenced this issue Oct 28, 2023
as a workaround, add dependency for spotbugs annotations, and create a
[ticket there so the spotbugs gradle plugin would include the dependency]
(spotbugs/spotbugs-gradle-plugin#1018).

see here a motivation for inner type last rule. if we leave the rule we
should respect it, otherwise disable the rule.
https://stackoverflow.com/questions/25158939/what-motivation-is-behind-checkstyle-inner-type-last-rule

pmd warnings not yet addressed, there are some log guard related, which
are false positive.

see MovingBlocks#3859

typehandlerlibrary qa, checkstyle

squash to qa
soloturn added a commit to soloturn/terasology that referenced this issue Oct 28, 2023
as a workaround, add dependency for spotbugs annotations, and create a
[ticket there so the spotbugs gradle plugin would include the dependency]
(spotbugs/spotbugs-gradle-plugin#1018).

see here a motivation for inner type last rule. if we leave the rule we
should respect it, otherwise disable the rule.
https://stackoverflow.com/questions/25158939/what-motivation-is-behind-checkstyle-inner-type-last-rule

pmd warnings not yet addressed, there are some log guard related, which
are false positive.

see MovingBlocks#3859

typehandlerlibrary qa, checkstyle

squash to qa
soloturn added a commit to soloturn/terasology that referenced this issue Oct 29, 2023
as a workaround, add dependency for spotbugs annotations, and create a
[ticket there so the spotbugs gradle plugin would include the dependency]
(spotbugs/spotbugs-gradle-plugin#1018).

see here a motivation for inner type last rule. if we leave the rule we
should respect it, otherwise disable the rule.
https://stackoverflow.com/questions/25158939/what-motivation-is-behind-checkstyle-inner-type-last-rule

pmd warnings not yet addressed, there are some log guard related, which
are false positive.

see MovingBlocks#3859

typehandlerlibrary qa, checkstyle

squash to qa
soloturn added a commit to soloturn/terasology that referenced this issue Oct 29, 2023
as a workaround, add dependency for spotbugs annotations, and create a
[ticket there so the spotbugs gradle plugin would include the dependency]
(spotbugs/spotbugs-gradle-plugin#1018).

see here a motivation for inner type last rule. if we leave the rule we
should respect it, otherwise disable the rule.
https://stackoverflow.com/questions/25158939/what-motivation-is-behind-checkstyle-inner-type-last-rule

pmd warnings not yet addressed, there are some log guard related, which
are false positive.

see MovingBlocks#3859

typehandlerlibrary qa, checkstyle

squash to qa
soloturn added a commit to soloturn/terasology that referenced this issue Oct 29, 2023
as a workaround, add dependency for spotbugs annotations, and create a
[ticket there so the spotbugs gradle plugin would include the dependency]
(spotbugs/spotbugs-gradle-plugin#1018).

see here a motivation for inner type last rule. if we leave the rule we
should respect it, otherwise disable the rule.
https://stackoverflow.com/questions/25158939/what-motivation-is-behind-checkstyle-inner-type-last-rule

pmd warnings not yet addressed, there are some log guard related, which
are false positive.

see MovingBlocks#3859

typehandlerlibrary qa, checkstyle

squash to qa
soloturn added a commit to soloturn/terasology that referenced this issue Oct 29, 2023
as a workaround, add dependency for spotbugs annotations, and create a
[ticket there so the spotbugs gradle plugin would include the dependency]
(spotbugs/spotbugs-gradle-plugin#1018).

see here a motivation for inner type last rule. if we leave the rule we
should respect it, otherwise disable the rule.
https://stackoverflow.com/questions/25158939/what-motivation-is-behind-checkstyle-inner-type-last-rule

especially in tests just quite the warnings, in most cases the code is
deliberate as it is.

see MovingBlocks#3859
soloturn added a commit to soloturn/terasology that referenced this issue Oct 29, 2023
as a workaround, add dependency for spotbugs annotations, and create a
[ticket there so the spotbugs gradle plugin would include the dependency]
(spotbugs/spotbugs-gradle-plugin#1018).

see here a motivation for inner type last rule. if we leave the rule we
should respect it, otherwise disable the rule.
https://stackoverflow.com/questions/25158939/what-motivation-is-behind-checkstyle-inner-type-last-rule

especially in tests just quite the warnings, in most cases the code is
deliberate as it is.

see MovingBlocks#3859 and see bugs:
* pmd/pmd#4731
* spotbugs/spotbugs-gradle-plugin#1018
* spotbugs/spotbugs#2667
soloturn added a commit to soloturn/terasology that referenced this issue Oct 29, 2023
as a workaround, add dependency for spotbugs annotations, and create a
[ticket there so the spotbugs gradle plugin would include the dependency]
(spotbugs/spotbugs-gradle-plugin#1018).

see here a motivation for inner type last rule. if we leave the rule we
should respect it, otherwise disable the rule.
https://stackoverflow.com/questions/25158939/what-motivation-is-behind-checkstyle-inner-type-last-rule

especially in tests just quite the warnings, in most cases the code is
deliberate as it is.

see MovingBlocks#3859 and see bugs:
* pmd/pmd#4731
* spotbugs/spotbugs-gradle-plugin#1018
* spotbugs/spotbugs#2667
soloturn added a commit to soloturn/terasology that referenced this issue Nov 8, 2023
as a workaround, add dependency for spotbugs annotations, and create a
[ticket there so the spotbugs gradle plugin would include the dependency]
(spotbugs/spotbugs-gradle-plugin#1018).

see here a motivation for inner type last rule. if we leave the rule we
should respect it, otherwise disable the rule.
https://stackoverflow.com/questions/25158939/what-motivation-is-behind-checkstyle-inner-type-last-rule

especially in tests just quite the warnings, in most cases the code is
deliberate as it is.

see MovingBlocks#3859 and see bugs:
* pmd/pmd#4731
* spotbugs/spotbugs-gradle-plugin#1018
* spotbugs/spotbugs#2667
soloturn added a commit to soloturn/terasology that referenced this issue Nov 9, 2023
as a workaround, add dependency for spotbugs annotations, and create a
[ticket there so the spotbugs gradle plugin would include the dependency]
(spotbugs/spotbugs-gradle-plugin#1018).

see here a motivation for inner type last rule. if we leave the rule we
should respect it, otherwise disable the rule.
https://stackoverflow.com/questions/25158939/what-motivation-is-behind-checkstyle-inner-type-last-rule

especially in tests just quite the warnings, in most cases the code is
deliberate as it is.

see MovingBlocks#3859 and see bugs:
* pmd/pmd#4731
* spotbugs/spotbugs-gradle-plugin#1018
* spotbugs/spotbugs#2667
soloturn added a commit to soloturn/terasology that referenced this issue Nov 11, 2023
as a workaround, add dependency for spotbugs annotations, and create a
[ticket there so the spotbugs gradle plugin would include the dependency]
(spotbugs/spotbugs-gradle-plugin#1018).

see here a motivation for inner type last rule. if we leave the rule we
should respect it, otherwise disable the rule.
https://stackoverflow.com/questions/25158939/what-motivation-is-behind-checkstyle-inner-type-last-rule

especially in tests just quite the warnings, in most cases the code is
deliberate as it is.

see MovingBlocks#3859 and see bugs:
* pmd/pmd#4731
* spotbugs/spotbugs-gradle-plugin#1018
* spotbugs/spotbugs#2667
@C-Otto
Copy link
Contributor

C-Otto commented Nov 16, 2023

The dependency needs to be available at compile time, otherwise the code won't compile. Spotbugs brings in its own dependencies which are needed for the analysis, i.e. at runtime of the scan. These are two very different scopes and should not be mixed.

Furthermore, handling some project's (compile) dependencies can be very involved and needs to be handled with care. I personally don't want some "random" plugin mess with my project's dependencies, just so that some optional feature works. This plugin's purpose is to make "spotbugs" run. Running spotbugs and tweaking your code to please spotbugs (or make spotbugs ignore certain issues) are two different things, which is why I think this is out of scope.

I suggest a) that you, @soloturn, add the dependency yourself, b) to close the issue ("won't do").

soloturn added a commit to soloturn/terasology that referenced this issue Nov 17, 2023
as a workaround, add dependency for spotbugs annotations, and create a
[ticket there so the spotbugs gradle plugin would include the dependency]
(spotbugs/spotbugs-gradle-plugin#1018).

see here a motivation for inner type last rule. if we leave the rule we
should respect it, otherwise disable the rule.
https://stackoverflow.com/questions/25158939/what-motivation-is-behind-checkstyle-inner-type-last-rule

especially in tests just quite the warnings, in most cases the code is
deliberate as it is.

see MovingBlocks#3859 and see bugs:
* pmd/pmd#4731
* spotbugs/spotbugs-gradle-plugin#1018
* spotbugs/spotbugs#2667
soloturn added a commit to soloturn/terasology that referenced this issue Nov 18, 2023
as a workaround, add dependency for spotbugs annotations, and create a
[ticket there so the spotbugs gradle plugin would include the dependency]
(spotbugs/spotbugs-gradle-plugin#1018).

see here a motivation for inner type last rule. if we leave the rule we
should respect it, otherwise disable the rule.
https://stackoverflow.com/questions/25158939/what-motivation-is-behind-checkstyle-inner-type-last-rule

especially in tests just quite the warnings, in most cases the code is
deliberate as it is.

see MovingBlocks#3859 and see bugs:
* pmd/pmd#4731
* spotbugs/spotbugs-gradle-plugin#1018
* spotbugs/spotbugs#2667
@soloturn
Copy link
Author

soloturn commented Dec 8, 2023

that would be then a problem of all other software as well where warnings can be silenced, like pmd, checkstyle, sonar, .... what makes spotbugs special?

@KengoTODA
Copy link
Member

There is nothing special. SpotBugs provides own annotations so if you want to annotate your code with it, you need to add the annotation artifact via compileOnly dependency.

And actually java.lang.SuppressWarnings also works even for SpotBugs. SpotBugs has a longer history than java.lang.SuppressWarnings so it has its own annotation, but it does not mean that SpotBugs users are forced to use SuppressFBWarnings.

Anyway your doubt is unrelated to this Gradle plugin so that I will close this issue. If you still have doubts to ask, open a discussion at spotbugs/spotbugs project.

@spotbugs spotbugs locked as off-topic and limited conversation to collaborators Dec 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants