vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

Suggestion: Ignore compiler warnings and information from specified directories

Open ChrisTrenkamp opened this issue 7 years ago • 8 comments

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.

ChrisTrenkamp avatar Oct 01 '18 18:10 ChrisTrenkamp

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>

fbricon avatar Oct 03 '18 22:10 fbricon

same problem, any solution yet?

BlazerYang avatar Jul 17 '19 06:07 BlazerYang

+1

ghost avatar May 24 '22 01:05 ghost

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.

dashorst avatar Jun 27 '22 07:06 dashorst

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)

rubensa avatar Sep 14 '22 09:09 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)?

rubensa avatar May 29 '23 13:05 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)?

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 🤯

heruan avatar Feb 12 '24 22:02 heruan

@rubensa @heruan You can try the ecliseignorehelper plugin.

snjeza avatar Feb 12 '24 23:02 snjeza