Thanks Julien. I tried the following code (taken from the PHP rules URL you provided):
<?php
$filename = $_GET["filename"];
include $filename . ".php";
The IDE is VSCode with SonarLint without connected mode (as it doesn’t make any difference from testing standpoint anyway). There is no problem detected by SonarLint. Here is the output from the plugin:
Executing /Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home/bin/java -jar /Users/vsinghal/.vscode/extensions/sonarsource.sonarlint-vscode-1.10.0/server/sonarlint-ls.jar 55137 file:///Users/vsinghal/.vscode/extensions/sonarsource.sonarlint-vscode-1.10.0/analyzers/sonarjs.jar file:///Users/vsinghal/.vscode/extensions/sonarsource.sonarlint-vscode-1.10.0/analyzers/sonarphp.jar file:///Users/vsinghal/.vscode/extensions/sonarsource.sonarlint-vscode-1.10.0/analyzers/sonarpython.jar file:///Users/vsinghal/.vscode/extensions/sonarsource.sonarlint-vscode-1.10.0/analyzers/sonarts.jar file:///Users/vsinghal/.vscode/extensions/sonarsource.sonarlint-vscode-1.10.0/analyzers/sonarhtml.jar
Binding to 55137
Child process connected on port 55137
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.sonarsource.sonarlint.shaded.com.google.gson.internal.reflect.UnsafeReflectionAccessor (file:/Users/vsinghal/.vscode/extensions/sonarsource.sonarlint-vscode-1.10.0/server/sonarlint-ls.jar) to field java.time.LocalDate.year
WARNING: Please consider reporting this to the maintainers of org.sonarsource.sonarlint.shaded.com.google.gson.internal.reflect.UnsafeReflectionAccessor
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Analysis triggered on file:///Work/code/poc/ide-plugin-testing/sonarlint.php with configuration:
[
baseDir: /Work/code/poc/ide-plugin-testing
extraProperties: {}
excludedRules: []
includedRules: []
inputFiles: [
file:///Work/code/poc/ide-plugin-testing/sonarlint.php (UTF-8) [php]
]
]
Starting standalone SonarLint engine...
Using 5 analyzers
Create : /Users/vsinghal/.sonarlint/plugins
Plugin cache: /Users/vsinghal/.sonarlint/plugins
Create : /Users/vsinghal/.sonarlint/plugins/_tmp
Load plugins
Load plugins (done) | time=14ms
Plugins:
* SonarPHP 3.0.0.4537 (php)
* SonarPython 1.12.0.2726 (python)
* SonarTS 1.9.0.3766 (typescript)
* SonarHTML 3.2.0.2082 (web)
* SonarJS 5.1.1.7506 (javascript)
[Info - 11:45:47 AM] Starting SonarTS Server
Deploying bundle to /Users/vsinghal/.sonarlint/work/.sonartmp_7445351134669267468/971209022126498457
[Info - 11:45:48 AM] Using typescript at [/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript], version 3.5.2
[Info - 11:45:48 AM] SonarTS Server is started
Standalone SonarLint engine started
[Info - 11:45:48 AM] SonarTS Server connected to 55143
Available languages:
* PHP => "php"
* Python => "py"
* TypeScript => "ts"
* HTML => "web"
* JSP => "jsp"
* JavaScript => "js"
Start analysis
Declared extensions of language PHP were converted to php: **/*.php,**/*.php3,**/*.php4,**/*.php5,**/*.phtml,**/*.inc
Declared extensions of language Python were converted to py: **/*.py
Declared extensions of language TypeScript were converted to ts: **/*.ts,**/*.tsx
Declared extensions of language HTML were converted to web: **/*.html,**/*.xhtml,**/*.cshtml,**/*.vbhtml,**/*.aspx,**/*.ascx,**/*.rhtml,**/*.erb,**/*.shtm,**/*.shtml
Declared extensions of language JSP were converted to jsp: **/*.jsp,**/*.jspf,**/*.jspx
Declared extensions of language JavaScript were converted to js: **/*.js,**/*.jsx,**/*.vue
[Info - 11:45:48 AM] Index files
Language of file 'file:///Work/code/poc/ide-plugin-testing/sonarlint.php' is set to 'php'
[Info - 11:45:48 AM] 1 file indexed
Execute Sensor: PHP sensor
[Warn - 11:45:48 AM] No workDir in SonarLint
[Info - 11:45:48 AM] 1 source files to be analyzed
[Info - 11:45:48 AM] 1/1 source files have been analyzed
Execute Sensor: Analyzer for "php.ini" files
'Python Squid Sensor' skipped because there is no related file in current project
'Contextual SonarTS' skipped because there is no related file in current project
Execute Sensor: HTML
'SonarJS' skipped because there is no related file in current project
'ESLint-based SonarJS' skipped because there is no related file in current project
Analysis triggered on file:///Work/code/poc/ide-plugin-testing/sonarlint.php with configuration:
[
baseDir: /Work/code/poc/ide-plugin-testing
extraProperties: {}
excludedRules: []
includedRules: []
inputFiles: [
file:///Work/code/poc/ide-plugin-testing/sonarlint.php (UTF-8) [php]
]
]
Available languages:
* PHP => "php"
* Python => "py"
* TypeScript => "ts"
* HTML => "web"
* JSP => "jsp"
* JavaScript => "js"
Start analysis
Declared extensions of language PHP were converted to php: **/*.php,**/*.php3,**/*.php4,**/*.php5,**/*.phtml,**/*.inc
Declared extensions of language Python were converted to py: **/*.py
Declared extensions of language TypeScript were converted to ts: **/*.ts,**/*.tsx
Declared extensions of language HTML were converted to web: **/*.html,**/*.xhtml,**/*.cshtml,**/*.vbhtml,**/*.aspx,**/*.ascx,**/*.rhtml,**/*.erb,**/*.shtm,**/*.shtml
Declared extensions of language JSP were converted to jsp: **/*.jsp,**/*.jspf,**/*.jspx
Declared extensions of language JavaScript were converted to js: **/*.js,**/*.jsx,**/*.vue
[Info - 11:45:59 AM] Index files
Language of file 'file:///Work/code/poc/ide-plugin-testing/sonarlint.php' is set to 'php'
[Info - 11:45:59 AM] 1 file indexed
Execute Sensor: PHP sensor
[Warn - 11:45:59 AM] No workDir in SonarLint
[Info - 11:45:59 AM] 1 source files to be analyzed
Execute Sensor: Analyzer for "php.ini" files
[Info - 11:45:59 AM] 1/1 source files have been analyzed
'Python Squid Sensor' skipped because there is no related file in current project
'Contextual SonarTS' skipped because there is no related file in current project
Execute Sensor: HTML
'SonarJS' skipped because there is no related file in current project
'ESLint-based SonarJS' skipped because there is no related file in current project