Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Real-time scanning doesn't refresh for whitespace characters #513

Closed
marcinkunert opened this issue Jan 13, 2021 · 6 comments
Closed

Real-time scanning doesn't refresh for whitespace characters #513

marcinkunert opened this issue Jan 13, 2021 · 6 comments

Comments

@marcinkunert
Copy link

marcinkunert commented Jan 13, 2021

IntelliJ IDEA Ultimate 2020.3
CheckStyle-IDEA 5.46.0
Checkstyle version: 8.36.2

I've chosen Google Checks, but the same happens to custom checkstyle config file.

Simple file as example:

public class Main {

  void method1() {

  }

  void method2() {
    
  }

}

Steps to reproduce:

  1. Move cursor before the second method declaration and press backspace. No tooltip is visible.
  2. Remove or add any letter to the code and add it back. The tooltip will be shown.

Looks like the check is not triggered by 'empty' characters (enter, space, tab).

I've recorded a git to show it a bit better.
checkstyle-issue

I've enabled the logging and surprisingly it seems that the checks are being run after adding whitespace characters, but they are not detecting any issues.

2021-01-13 15:08:09,718 [2147377]  DEBUG - heckstyle.CheckStyleInspection - Inspection cancelled when scanning: Main.java 
2021-01-13 15:08:10,037 [2147696]  DEBUG - heckstyle.CheckStyleInspection - Inspection has been invoked for Main.java 
2021-01-13 15:08:10,040 [2147699]  DEBUG - ckstyle.checker.CheckerFactory - Getting CheckStyle checker with location Google Checks 
2021-01-13 15:08:10,040 [2147699]  DEBUG - le.checker.CheckerFactoryCache - Valid cached checker found; returning for Google Checks 
@marcinkunert marcinkunert changed the title Real-time scanning doesn't refresh in some cases Real-time scanning doesn't refresh for whitespace characters Jan 13, 2021
@MariuszSzmagara
Copy link

👍

@jshiell
Copy link
Owner

jshiell commented Jan 13, 2021

Thanks for the great report.

Bad news - we rely on IDEA for the trigger - I'll double check the integration when I get a moment, but I don't believe there's a lot of option here for fine-tuning.

public ProblemDescriptor[] checkFile(@NotNull final PsiFile psiFile,

<localInspection implementationClass="org.infernus.idea.checkstyle.CheckStyleInspection"

@marcinkunert
Copy link
Author

@jshiell I've edited the issue and added debug log output: the trigger seems to be firing, but the check is not reporting any issues ultil a non-whitespace character is added or removed

@jshiell
Copy link
Owner

jshiell commented Jan 13, 2021

Ah, that's more interesting. My guess at first glance is that it could be something to do with the file read - we need to make a copy of the file contents to scan, as Checkstyle needs a static file on disk (and IDEA may not have written changes). If there's something awry with the syncing there on whitespace (e.g. IDEA doesn't flag the change) then we could well end up scanning something unexpected.

@jshiell
Copy link
Owner

jshiell commented Apr 6, 2021

Good news - I finally had a look at it.

Bad news - it appears to be an IDEA issue. We return exactly the same ProblemDescriptors from the inspection in both cases, but IDEA seems to ignore them in the whitespace case.

I've created an issue with Youtrack - https://youtrack.jetbrains.com/issue/IDEA-265941

@jshiell
Copy link
Owner

jshiell commented May 2, 2021

It turns out there's a scary attribute to turn on whitespace scanning, with the appropriate perf impact. That's now active as of 5.52.0, which should resolve this problem.

@jshiell jshiell closed this as completed May 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants