Skip to content

"The value of the local variable XXXX is not used" throws error instead of warning #1404

Closed

Description

@hannah23280

Vscode: v1.44.2
extension: 0.60.0

Why is this message "The value of the local variable XXXX is not used" considered an error instead of warning?

Activity

  1. changed the title [-]The value of the local variable XXXX is not used throws error instead of warning[/-] [+]"The value of the local variable XXXX is not used" throws error instead of warning[/+] on Apr 21, 2020
  2. fbricon commented on Apr 21, 2020

    @fbricon
    Collaborator

    Probably because your project is configured to report such problems as errors. Can you share you .settings/ folder?

  3. hannah23280 commented on Apr 21, 2020

    @hannah23280
    Author

    Hi,
    Thanks for the response. Do u mean the settings in the workspace file?

    "settings": {
    		
    		"java.home": "D:\\Projects\\Source_Codes\\DemoProjects\\hands_on_microservices_with_SB_SC\\jdk1.8.0_77",
    		"java.configuration.updateBuildConfiguration": "automatic",
    		"java.dependency.syncWithFolderExplorer": false,
    		"java.import.gradle.wrapper.enabled":true,
    		"java.import.gradle.enabled": true,
    		"java.import.gradle.user.home": "D:\\Projects\\Source_Codes\\DemoProjects\\hands_on_microservices_with_SB_SC\\chapter03\\codes\\.gradle" 
    			
    	}
    
  4. fbricon commented on Apr 21, 2020

    @fbricon
    Collaborator

    No. You should have a .settings/ folder at the root of your project, containing Eclipse preference files (as Eclipse is used under the hood to provide Java support). It should be hidden by default, you can make it visible in vscode by adding this to your settings.json

      "files.exclude": {
        "**/.settings": false,
    },
    
  5. hannah23280 commented on Apr 21, 2020

    @hannah23280
    Author

    Hi,

    Yes. I can see the .settings folder. Inside contain a file called org.eclipse.buildship.core.prefs, whose content as shown below

    arguments=
    auto.sync=false
    build.scans.enabled=false
    connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
    connection.project.dir=
    eclipse.preferences.version=1
    gradle.user.home=D\:/Projects/Source_Codes/DemoProjects/hands_on_microservices_with_SB_SC/chapter03/codes/.gradle
    java.home=D\:/Projects/Source_Codes/DemoProjects/hands_on_microservices_with_SB_SC/jdk1.8.0_77
    jvm.arguments=
    offline.mode=false
    override.workspace.settings=true
    show.console.view=true
    show.executions.view=true
    

    Curious, the settings in this file, are we allowed to modify it? or is the content of this files autogenerated by vscode-java extension, and the values are derived from some other places, such that developers should not modify this file directly?

  6. robstryker commented on Oct 29, 2026

    @robstryker
    Contributor

    @datho7561 It would be good to document here in this issue how a user might override these settings.

  7. datho7561 commented on Oct 29, 2026

    @datho7561
    Contributor

    It might be nice to make a UI for the compiler settings now that we've set a precedent for this kind of thing in vscode-java, and the current "correct" way to do it is messy.


    Anyways, here's my best explanation:

    1. Check for a file .settings/org.eclipse.jdt.core.prefs in your project folder. If that file exists, then it will contain the compiler preferences. It's a file with key/value pairs, one per line, similar to Java .properties and Windows .ini files, with setting name as the key and value as the setting value.

    Here's an example entry: org.eclipse.jdt.core.compiler.problem.forbiddenReference=error.

    In the case mentioned here, you'd want to find the entry for "unused local variable" and change it from error to warn.

    In the case you can't find the relevant setting being set in the file, you can reference the complete list of compiler settings here: https://github.com/eclipse-jdt/eclipse.jdt.core/blob/1d9ec5242bd76a8dfebbf3f896de97583d448cf2/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java#L173 . Unfortunately, that's the only spot I can think of where the full list is documented for the time being.

    1. If that file doesn't exist in your project folder, there's a setting called java.import.generatesMetadataFilesAtProjectRoot which can be enabled to generate the file in your project folder. By default, vscode-java generates this configuration into a folder provided by VS Code for storing extension data to avoid cluttering the user's project, but disabling this feature makes it much easier to modify these files if that's what you want to do.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions