Skip to content

Suggestion: Ignore compiler warnings and information from specified directories #660

Open

Description

@ChrisTrenkamp

As a user of the vscode-java extension, I would like to ignore Java compiler warnings and information coming from certain directories.

Generated code and unit tests often generate warnings from the compiler. I would like to have warnings coming from certain directories suppressed so it'll be easier to find warnings from code we're interested in.

files.ignore is not good enough because sometimes you want to ignore warnings coming from unit tests. For example, you might want to test your equals() method against different objects, but you will get an information message telling you that it's an unlikely argument.

For now, entering src/main/** into the problems filter seems to be good enough for now, but I would like to create a workspace with some sane defaults for my coworkers to use when pulling the project.

Activity

  1. fbricon commented on Oct 3, 2018

    @fbricon
    Collaborator

    You can add an ignore_optional_problems flag to your project's .classpath file, like:

    <classpathentry kind="src" output="target/classes" path="src/main/java">
        <attributes>
            <attribute name="ignore_optional_problems" value="true" />
        </attributes>
    </classpathentry>
  2. BlazerYang commented on Jul 17, 2019

    @BlazerYang

    same problem, any solution yet?

  3. dashorst commented on Jun 27, 2022

    @dashorst

    Since VS Code no longer generates the .classpath files inside the workspace, it is quite difficult to modify them directly, especially when using a remote devcontainer. Having a UI to add this boolean attribute, or a menu item to open the .classpath file for the project would be absolutely helpful. At this time I can't recommend using VS Code for our project as the number of warnings in generated dwarfs the actual warnings in our code base, and we have a zero warning policy.

  4. rubensa commented on Sep 14, 2022

    @rubensa

    Should be great to have an option to do this in the JAVA PROJECTS view by a right click in an specific source folder (or in the Configure Classpath page).

    (related to: #2150)

  5. rubensa commented on May 29, 2023

    @rubensa

    Any chance for the ignore_optional_problems to be added for any folder under "target/generated-sources" (like it is currently automatically being added for target/generated-sources/annotations and target/generated-test-sources/test-annotations)?

  6. heruan commented on Feb 12, 2024

    @heruan

    Any chance for the ignore_optional_problems to be added for any folder under "target/generated-sources" (like it is currently automatically being added for target/generated-sources/annotations and target/generated-test-sources/test-annotations)?

    This would be great. I use a Maven plugin to generate a lot of sources in target/generated-sources/** and I have thousands of warnings 🤯

  7. snjeza commented on Feb 12, 2024

    @snjeza
    Collaborator

    @rubensa @heruan You can try the ecliseignorehelper plugin.

  8. mrgarbagegamer commented on Jan 27, 2026

    @mrgarbagegamer

    I think I've found it!

    Image Image

    I need to test this in full, but it appears that the java.diagnostic.filter option allows you to exclude directories completely from warnings, without causing project recognition issues (like I had earlier with a java resource filter on the target directory).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions