robotcode icon indicating copy to clipboard operation
robotcode copied to clipboard

[BUG] Analyser checks non-open files despite of the extension setting

Open Heck-R opened this issue 4 months ago • 3 comments

Describe the bug The extension analyses all test and resource files regardless of the "robotcode.analysis.diagnosticMode": "openFilesOnly" setting

Steps To Reproduce Steps to reproduce the behavior:

  1. Open an empty folder in VsCode
    • For simplicity, it is assumed that robotframework is available in the default interpreter used by the extension, but the issue is the same regardless of the interpreter coming from a Python installation or a virtual environent
  2. Add a .vscode\settings.json
{
  "robotcode.analysis.progressMode": "detailed",
  "robotcode.analysis.diagnosticMode": "openFilesOnly"
}
  1. Create some .resource files
  2. Create some .robot files
  3. Close all open .resource and .robot files (actually some can stay open, just make sure there are un-referenced files that are not open)
  4. Run Clear Cache and Restart Language Servers extension command
  5. See the analysis going through all .resource and .robot files regardless of them being open

To minimize the reproduction effort, just use the generator script from this analyserIssue.zip (it's PowerShell, so it works on Windows by default)

  1. Extract the zip to an empty folder
  2. Open with VsCode
  3. Run the generator script in the integrated terminal: .\PackageGenerator.ps1 \
    • the working directory should be the opened folder
    • there are no arguments, but the generated files can be tweaked by changing the commented variables as the top to make it easier or harder for the analyser
      • To make it actually slow, just set $resourceLevels = @(100, 100, 100) to make a ridiculous amount of resource references
  4. Make sure .resource and .robot files are closed
  5. Run Clear Cache and Restart Language Servers extension command
  6. See the analysis going through all .resource and .robot files regardless of them being open

From the dummy examples above it seems like this is not a real issue, as it's quite fast, but in our real-world repo (which I can sadly not share) with hundreds of tests referencing hundreds of resources with proper logic and documentation, this can take minutes, and it would be a lot better if it was really only the open files that are analysed

Expected behavior When the "robotcode.analysis.diagnosticMode": "openFilesOnly" setting is defined, only the open files (and the ones referenced from these) are analysed

Screenshots/ Videos Showcasing the problem using the generator script as preparation https://github.com/user-attachments/assets/aba0cb70-3545-4a39-b768-c5ac7b45b3ad

Logs RobotCode

Activate RobotCode Extension.
Try to activate python extension
Python Extension is active
executeRobotCode: c:\Program Files\Python\3.12\python.exe -u -X utf8 c:\Users\heckmannd\.vscode\extensions\d-biehl.robotcode-0.95.2\bundled\tool\robotcode --format json --no-color --no-pager --default-path . profiles list
create Language client: RobotCode Language Server mode=pipe for folder 'analyserIssue'
trying to start Language client: RobotCode Language Server mode=pipe for folder 'analyserIssue'
client for file:///c%3A/Users/heckmannd/LocalMadness/tmp/analyserIssue starting.
executeRobotCode: exit code 0
executeRobotCode: c:\Program Files\Python\3.12\python.exe -u -X utf8 c:\Users\heckmannd\.vscode\extensions\d-biehl.robotcode-0.95.2\bundled\tool\robotcode --format json --no-color --no-pager --default-path . profiles list
client for file:///c%3A/Users/heckmannd/LocalMadness/tmp/analyserIssue running.
client for file:///c%3A/Users/heckmannd/LocalMadness/tmp/analyserIssue started.
executeRobotCode: c:\Program Files\Python\3.12\python.exe -u -X utf8 c:\Users\heckmannd\.vscode\extensions\d-biehl.robotcode-0.95.2\bundled\tool\robotcode --format json --no-color --no-pager --default-path . discover --read-from-stdin all
executeRobotCode: exit code 0
executeRobotCode: c:\Program Files\Python\3.12\python.exe -u -X utf8 c:\Users\heckmannd\.vscode\extensions\d-biehl.robotcode-0.95.2\bundled\tool\robotcode --format json --no-color --no-pager --default-path . profiles list
executeRobotCode: exit code 0
executeRobotCode: exit code 0
executeRobotCode: c:\Program Files\Python\3.12\python.exe -u -X utf8 c:\Users\heckmannd\.vscode\extensions\d-biehl.robotcode-0.95.2\bundled\tool\robotcode --format json --no-color --no-pager --default-path . profiles list
executeRobotCode: exit code 0
executeRobotCode: c:\Program Files\Python\3.12\python.exe -u -X utf8 c:\Users\heckmannd\.vscode\extensions\d-biehl.robotcode-0.95.2\bundled\tool\robotcode --format json --no-color --no-pager --default-path . profiles list
executeRobotCode: exit code 0
executeRobotCode: c:\Program Files\Python\3.12\python.exe -u -X utf8 c:\Users\heckmannd\.vscode\extensions\d-biehl.robotcode-0.95.2\bundled\tool\robotcode --format json --no-color --no-pager --default-path . profiles list
executeRobotCode: exit code 0

RobotCode Language Server

Start analyzing workspace for 300 documents
End analyzing workspace for 300 documents took 3.1720 seconds
Start collect workspace diagnostic for 0 documents
End collect workspace diagnostic for 0 documents took 0.0150 seconds

Additional context This issue is not specific to newer releases, it's been present for a while

Making the folder a git repo and gitignoring the folder containing all the related files will actually cause the expected result (only analysing the open files)

There is also a potentially related issue where modifying a file re-analyses unrelated files, but I could not yet reproduce that with a dummy example I can share, so for now I'll just leave it here as an additional note (maybe it gives some ideas regarding the provided reproducible issue, if not, just ignore it for now, and I'll try to report that separately with a proper example)

Desktop (please complete the following information):

  • VS Code Version 1.95.0
  • RobotCode Version v0.95.2
  • OS: Windows
  • Python Version 3.11.9 (it was the same with 3.9.13) (the language server seems to be using Python 3.12 ased on its log, not sure why, but when doing the same test with a virtual environment, robotframework was definitely installed inside 3.11.9, resulting in the same issue)
  • RobotFramework Version 7.1 (it was the same with older versions, but can't recall the exact ones anymore)
  • Additional tools robotidy was installed at the time of the recording, but the issue remains after a pip uninstall

Heck-R avatar Oct 30 '24 17:10 Heck-R