2

I started to develop Java in visual studio code but on our legacy project there are hundreds of unused fields. I'm getting 300+ warnings that "The value of the local variable XXXX is not used."

How can I ignore these warnings?

4 Answers 4

7

There is a file in the in the project root folder .settings/org.eclipse.jdt.core.prefs. Add the following line, or edit it if exist:

org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore

UPD: If you want edit more of your preferences, check this link.

Sign up to request clarification or add additional context in comments.

3 Comments

Hi, I already found that issue but the thing is I have still different warnings so I need to ignore every warning
Check the link, you can disable any warning
Hi again. I removed most of warnings and only TODO's remain atm and this will became solution
1

Adding onto simply_sideways's answer.

If above settings don't work, you can add "java.settings.url":"/yourPathTo/org.eclipse.jdt.core.prefs" to settings.json file.

Visit https://github.com/redhat-developer/vscode-java/wiki/Settings-Global-Preferences for more settings global preferences.

Comments

0

Not a java expert but following worked for me in vscode

  1. Open Java Formatter Settings With Preview via vscode command palette
  2. It should create java-formatter.xml file in the .vscode directory
  3. Based on previous answers, I added following line to the end of this file

<setting id="org.eclipse.jdt.core.compiler.problem.unusedLocal" value="ignore"/>

Comments

0

Adding onto Vlad's answer for those that come across this question later:

It may be obvious for a more experienced developer but I spent time looking for that .settings folder in a new project, unaware that I could/should just create it myself if it didn't exist. Don't waste your time like me. Create the .settings folder and org.eclipse.jdt.core.prefs file yourself, then add Vlad's code (org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore). That link he gave helped me generalize to other issues.

Also, VS Code may hide a .settings folder that does already exist. To show it, open your settings.json file and add:

  "files.exclude": {
    "**/.settings": false
  }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.