Skip to content

Increase maxwarns to -1 #291

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

fzakaria
Copy link

Please see bazelbuild/bazel#25927 (comment)

It's important not to filter out any warnings otherwise the lint warnings are not surfaced and then any attempt to do -Werror can fail with what may be observed as spurious (affect other parts of the codebase).

This is maybe a "breaking change" only if someone has enabled -Werror and may now see additional errors -- although that was in fact their intention...

Please see bazelbuild/bazel#25927 (comment)

It's important not to filter out any warnings otherwise the lint warnings are not surfaced and then any attempt to do `-Werror` can fail with what may be observed as spurious (affect other parts of the codebase).

This is maybe a "breaking change" only if someone has enabled `-Werror` and may now see additional errors -- although that was in fact their intention...
@hvadehra
Copy link
Member

hvadehra commented May 6, 2025

The motivation for this sounds reasonable to me, but I think we should only be setting defaults that make sense for everyone, all the time. So, it's probably best if we actually trim down the default list to an empty one rather than expanding it (so the default javac behavior is what everyone gets out-of-the-box). If you'd like to have different behavior, consider registering a custom java_toolchain with those options.

@cushon
Copy link
Collaborator

cushon commented May 6, 2025

The motivation for this sounds reasonable to me, but I think we should only be setting defaults that make sense for everyone, all the time. So, it's probably best if we actually trim down the default list to an empty one rather than expanding it (so the default javac behavior is what everyone gets out-of-the-box). If you'd like to have different behavior, consider registering a custom java_toolchain with those options.

FWIW I think this default sort of makes sense for everyone, the status quo is that errors may not be shown if there are too many warnings, and then there's no way to tell why the build failed from the log. There is an underlying bug causing that which should be fixed, but until then this default is helpful for everyone. And I also agree in theory it would be nice to use javac defaults, but in practice I'm not sure there's a strong reason to change this default upstream, the issue here is Bazel-specific.

@fzakaria
Copy link
Author

fzakaria commented May 6, 2025

Yea -- basically without this PR users of rules_java are subject to potential bugs that I've documented in the bug.
If someone (@cushon ) can recommend where to try and patch it upstream -- I can look into that as well; but for now this is a pretty reasonable change.

@hvadehra
Copy link
Member

hvadehra commented May 7, 2025

the issue here is Bazel-specific.

Is this because JavaBuilder does not propagate the -Werror to the compilation task? If so, ISTM we should perhaps not propagate -Xmaxwarns either (passing -1 instead), and do the limiting on the JavaBuilder side (after filtering ignored diagnostics). Is that right?

@cushon
Copy link
Collaborator

cushon commented May 7, 2025

the issue here is Bazel-specific.

Is this because JavaBuilder does not propagate the -Werror to the compilation task?

It's related to that: bazelbuild/bazel#25927 (comment)

If so, ISTM we should perhaps not propagate -Xmaxwarns either (passing -1 instead), and do the limiting on the JavaBuilder side (after filtering ignored diagnostics). Is that right?

Hard-coding -Xmaxwarns=-1 in JavaBuilder instead of configuring it via javacopts would also work around the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants