question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

False positives problems (when using Lombok)

See original GitHub issue

When using this plugin with a lombok-project the plugin determines many problems (e. g. for missing getters and setters) that disappear when the corresponding file is opened.

Environment
  • Operating System: macOS
  • JDK version: 1.8.0_102
  • Visual Studio Code version: 1.20.1
  • Java extension version: 0.20.0
Steps To Reproduce
  1. Configure lombok support for this plugin, as described here
  2. Open a project that uses lombok annotations like @Getter or @Data
Sample Project

Unfortunately, I cannot submit the affected project. The important bits are:

<!-- pom.xml -->
<dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <scope>provided</scope>
</dependency>
// License.java
@Data
public class License {
    private String serial;
}
Java Language Server log
!SESSION 2018-03-06 07:59:11.945 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_102
java.vendor=Oracle Corporation
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=de_DE
Command-line arguments:  -data /Users/oliverherrmann/Library/Application Support/Code/User/workspaceStorage/d8ec444f7205bbe5fb9c8b70109bb494/redhat.java/jdt_ws

!ENTRY org.eclipse.jdt.ls.core 1 0 2018-03-06 07:59:14.658
!MESSAGE class org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin is started

!ENTRY org.eclipse.jdt.ls.core 1 0 2018-03-06 07:59:14.992
!MESSAGE Main thread is waiting


{ ... }


!ENTRY org.eclipse.jdt.ls.core 4 0 2018-03-06 08:00:20.767
!MESSAGE Error occured while building workspace. Details: 
message: The method getSerial() is undefined for the type License;code: 67108964
message: The method getExportChannels() is undefined for the type Project;code: 67108964
message: The method getEditions() is undefined for the type Project;code: 67108964
Current Result

A Problem “The method getSerial() is undefined for the type License“ is listed in the problems view. When opening the corresponding file by clicking on the entry the problem disappears after a few seconds.
This behavior is reproducable when restarting vs code.

Expected Result

No problem “The method getSerial() is undefined for the type License“ is listed in the problems view.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:7
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
GabrielBBcommented, Dec 12, 2018

This bug is still happening, please see: Problems list still show errors of undefined for getters or setters. The issue opener resolved it doing this: https://github.com/GabrielBB/vscode-lombok/issues/13#issuecomment-440981551 , but that workaround doesn’t work for others

4reactions
YongJieYongJiecommented, Oct 9, 2020

Here’s how I managed to solve the problem:

  1. Make sure everything else works:
    • I.e., even though the errors show up in the PROBLEMS list, once you navigate to the specific file, the errors for that file disappears.
    • You will likely need to install the Lombok Annotations Support for VSCode extension for this.
  2. Run Java: Clean the Java language server workspace from Command Palette.
  3. Run Java: Import Java projects in workspace from Command Palette.
  4. The problem is fixed (at least for me).
    • Do note however that you might still see a huge number of warnings / info messages.
Read more comments on GitHub >

github_iconTop Results From Across the Web

False Positive with Java and Lombok - Sonar Community
We have identified some false positives when we are using Lombok. We had a look around and found this in StackOverflow which advices...
Read more >
sonarqube + lombok = false positives - Stack Overflow
I've seen that some fixes related to support of "lombok. Data" annotation have been pushed, but still having these annoying false positives.
Read more >
SonarJava S1118 creates false positives when using Lombok
Hi all! When you write no constructor, but use one or more of Lombok's constructor annotations, the compiler will not add an implicit...
Read more >
Bundled Lombok plugin gives false positive typing complains : IDEA ...
The entire code reproducing the problem can be seen below: Code example with a test case. import lombok.Builder; import lombok.
Read more >
Sonar-scanner + Lombok + Gradle = False-Positives codesmells
We use Gradle to build our Java code and sonar-scanner to analyse it, but sonar-scanner generates false-positive codesmells regarding Lombok ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found