admin管理员组文章数量:1291120
I would like to use SonarLint for Eclipse’s Connected Mode showing New Code issue markers only while developing. My SonarQube server is < 9.9 (upgrading isn’t an option at this point). AFAIK the last SonarLint plugin version supporting it is 10.2 so that’s what I’m using.
I have a multimodule maven project with a structure like so:
rootproject
├─ backend
│ ├─ moduleA
│ │ ├─ src
│ │ │ └─ main
│ │ | ├─ java
│ │ | ├─ resources
│ │ | └─ webapp
│ │ └─ pom.xml
│ ├─ moduleB
│ │ └─ ...
│ ├─ moduleC
│ │ └─ ...
│ └─ pom.xml
└── pom.xml
This is a single SonarQube project server side (named ROOTPROJECT
) and with the same structure. Analysis runs from rootproject’s pom just fine in CI/CD, with code from all modules being properly scanned.
In Eclipse, I can enable Connected Mode and bind projects to ROOTPROJECT
correctly.
rootproject and backend don’t provide any code by themselves so I would like SonarLint to act on the module<N>
projects individually.
I can’t get New Code mode to work properly, and I believe the issue is with SonarLint not knowing or realising the source files are actually in a submodule that has parents whose path has to be prefixed to the local, relative path of the files in the project:
GET 404 https://myserver/sonar/batch/issues?key=ROOTPROJECT%3Asrc%2Fmain%2Fjava%2FsomePackage%2FSomeClass.java&branch=master
I tried with a browser that same URL but prefixing src
with backend%2FmoduleA%2F
and it works fine (returns some content and not a 404).
I also see lines like this (one for each folder) at the beginning of the scan (which maybe are the reason why the files don’t have the correct prefix?)
[DefaultSonarLintProjectAdapter#collect] Try get Eclipse file of resource ‘F/moduleA/src/main/java/somePackage’ → ‘F/moduleA/src/main/java/somePackage’ could not be adapted to ‘.eclipse.core.resources.IFile’
Find below the (almost) full log of a manually triggered analysis on Changed files. There is only one changed file with 3 issues. Only one of them is new code. I guess the 404 error is while querying the SonarQube server for already existing issues on that class and therefore the reason why SonarLint can’t filter New Code issues only.
Could anyone please help me get New Code issue filtering working on Eclipse? That is, if this can work at all with this plugin version. I know it’s old and probably unsupported, but it’s the only one I can use with my SonarQube server as of now.
[SelectionUtils#collectProjects] Try get container of object 'P/moduleA' -> 'P/moduleA' could not be adapted to '.sonarlint.eclipse.core.resource.ISonarLintProjectContainer'
[DefaultSonarLintProjectAdapter#collect] Try get Eclipse file of resource 'P/moduleA' -> 'P/moduleA' could not be adapted to '.eclipse.core.resources.IFile'
[DefaultSonarLintProjectAdapter#collect] Try get Eclipse file of resource 'F/moduleA/src' -> 'F/moduleA/src' could not be adapted to '.eclipse.core.resources.IFile'
[DefaultSonarLintProjectAdapter#collect] Try get Eclipse file of resource 'F/moduleA/src/main/java/somePackage' -> 'F/moduleA/src/main/java/somePackage' could not be adapted to '.eclipse.core.resources.IFile'
... <Similar log line for all subdirectories>
Analyzing 1 changed file(s) in 1 project(s)
Trigger: MANUAL_CHANGESET
Analysis started with the engines being ready
Clear markers on 0 excluded files
SonarLint processing file /moduleA/src/main/java/somepackage/SomeClass.java...
* css: 23 active rules
* java: 468 active rules
Rule java:S2077 is enabled on the server, but not available in SonarLint
... <Several irrelevant similar lines>
Triggering analysis with configuration: [
baseDir: C:\SomeAbsolutePath\rootproject\backend\moduleA
extraProperties: {sonar.updatecenter.cache.ttl=3600000, sonaranalyzer-cs.nuget.packageVersion=8.32.0.39516, sonar.auth.bitbucket.allowUsersToSignUp=true, sonar.cs.ignoreHeaderComments=true, sonar.typescript.file.suffixes=.ts,.tsx, sonar.auth.github.enabled=false, sonar.python.coverage.reportPaths=coverage-reports/*coverage-*.xml, sonaranalyzer-vbnet.nuget.packageVersion=8.32.0.39516, sonar.groovy.file.suffixes=.groovy, sonar.go.file.suffixes=.go, sonar.java.test.binaries=C:/SomeAbsolutePath/rootproject/backend/moduleA/target/test-classes, sonar.auth.saml.applicationId=sonarqube, sonar.zpa.errorRecoveryEnabled=true, email.fromName=SonarQube, sonar.python.xunit.skipDetails=false, sonar.dbcleaner.weeksBeforeKeepingOnlyAnalysesWithVersion=104, sonar.qualitygate.ignoreSmallChanges=true, sonar.go.exclusions=**/vendor/**, sonar.php.exclusions=**/vendor/**, sonar.terraform.file.suffixes=.tf, sonar.forceAuthentication=false, sonar.notifications.delay=60, sonar.groovy.ignoreHeaderComments=true, sonar.vbnet.roslyn.ignoreIssues=false, sonar.flex.file.suffixes=as, sonar.groovy.jacoco.itReportPath=target/jacoco-it.exec, sonar.auth.gitlab.groupsSync=false, sonar.auth.github.apiUrl=/, sonar.ruby.file.suffixes=.rb, sonaranalyzer-cs.ruleNamespace=SonarAnalyzer.CSharp, sonar.auth.github.allowUsersToSignUp=true, sonar.cs.analyzeGeneratedCode=false, sonar.python.xunit.reportPath=xunit-reports/xunit-result-*.xml, sonar.builtInQualityProfiles.disableNotificationOnUpdate=false, sonar.javascript.globals=angular,goog,google,OenLayers,d3,dojo,dojox,dijit,Backbone,moment,casper,_, sonar.dbcleaner.hoursBeforeKeepingOnlyOneSnapshotByDay=24, sonar.yaml.file.suffixes=.yaml,.yml, sonar.auth.bitbucket.enabled=false, sonar.terraform.activate=true, sonar.java.source=1.7, sonar.css.file.suffixes=.css,.less,.scss, sonar.auth.github.webUrl=/, sonar.projectBaseDir=C:/SomeAbsolutePath/rootproject, sonar.html.file.suffixes=.html,.xhtml,.cshtml,.vbhtml,.aspx,.ascx,.rhtml,.erb,.shtm,.shtml, sonaranalyzer-vbnet.nuget.packageId=SonarAnalyzer.VisualBasic, sonar.auth.gitlab.enabled=false, sonar.cpd.cross_project=false, email.from=noreply@nowhere, sonaranalyzer-vbnet.pluginVersion=8.32.0.39516, sonar.vbnet.ignoreHeaderComments=true, sonar.auth.github.groupsSync=false, sonar.dbcleaner.weeksBeforeKeepingOnlyOneSnapshotByWeek=4, sonaranalyzer-vbnet.analyzerId=SonarAnalyzer.VisualBasic, email.prefix=[SONARQUBE], sonar.sources=backend/moduleA/src/main/java, sonar.scala.file.suffixes=.scala, sonar.cs.roslyn.ignoreIssues=false, sonar.cloudformation.activate=true, sonar.java.libraries=<many_jars.jar>}
activeRules: [<several rules>]
inputFiles: [
file:/C:/SomeAbsolutePath/rootproject/backend/moduleA/src/main/java/somepackage/SomeClass.java (UTF-8)
]
]
Start analysis
Index files
Language of file "file:/C:/SomeAbsolutePath/rootproject/backend/moduleA/src/main/java/somepackage/SomeClass.java" is detected to be "JAVA"
1 file indexed
Added 144 checks for language='ts', repository='typescript'
Added 155 checks for language='js', repository='javascript'
Execute Sensor: JavaSensor
No workDir in SonarLint
Configured Java source version (sonar.java.source): 7
JavaClasspath initialization
Property 'sonar.java.jdkHome' resolved with:
[]
Property 'sonar.java.libraries' resolved with:
[<many_jars.jar>]
JavaClasspath initialization (done) | time=2ms
JavaTestClasspath initialization
Property 'sonar.java.jdkHome' resolved with:
[]
Property 'sonar.java.test.libraries' resolved with:
[<many_jars.jar>]
JavaTestClasspath initialization (done) | time=3ms
Java "Main" source files AST scan
1 source file to be analyzed
Initializing metadata of file file:/C:/SomeAbsolutePath/rootproject/backend/moduleA/src/main/java/somepackage/SomeClass.java
[SE] Loaded 179 hardcoded method behaviors.
Analysis time of [uri=file:/C:/SomeAbsolutePath/rootproject/backend/moduleA/src/main/java/somepackage/SomeClass.java] (89ms)
1/1 source file has been analyzed
Java "Main" source files AST scan (done) | time=89ms
No "Test" source files to scan.
No "Generated" source files to scan.
'Scala Sensor' skipped because there are no related files in the current project
'Python Sensor' skipped because there are no related files in the current project
Execute Sensor: JavaXmlSensor
Execute Sensor: HTML
'XML Sensor' skipped because there are no related files in the current project
'Kotlin Sensor' skipped because there are no related files in the current project
'PHP sensor' skipped because there are no related files in the current project
'Analyzer for "php.ini" files' skipped because there are no related files in the current project
'JavaScript/TypeScript analysis' skipped because there are no related files in the current project
'JavaScript inside YAML analysis' skipped because there are no related files in the current project
'JavaScript inside HTML analysis' skipped because there are no related files in the current project
Execute Sensor: CSS Rules
No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
'Ruby Sensor' skipped because there are no related files in the current project
Execute Sensor: TextAndSecretsSensor
Available processors: 24
Using 24 threads for analysis.
Analyzing all except non binary files
1 source file to be analyzed
1/1 source file has been analyzed
Analysis detected 3 issues and 0 Security Hotspots in 188ms
Found 3 issue(s)
GET 404 https://myserver/sonar/batch/issues?key=ROOT_PROJECT%3Asrc%2Fmain%2Fjava%2FsomePackage%2FSomeClass.java&branch=master | response time=423ms
Downloaded issues in 423ms
Wrote 0 issues in store | took 1ms
Done in 639 ms
I would like to use SonarLint for Eclipse’s Connected Mode showing New Code issue markers only while developing. My SonarQube server is < 9.9 (upgrading isn’t an option at this point). AFAIK the last SonarLint plugin version supporting it is 10.2 so that’s what I’m using.
I have a multimodule maven project with a structure like so:
rootproject
├─ backend
│ ├─ moduleA
│ │ ├─ src
│ │ │ └─ main
│ │ | ├─ java
│ │ | ├─ resources
│ │ | └─ webapp
│ │ └─ pom.xml
│ ├─ moduleB
│ │ └─ ...
│ ├─ moduleC
│ │ └─ ...
│ └─ pom.xml
└── pom.xml
This is a single SonarQube project server side (named ROOTPROJECT
) and with the same structure. Analysis runs from rootproject’s pom just fine in CI/CD, with code from all modules being properly scanned.
In Eclipse, I can enable Connected Mode and bind projects to ROOTPROJECT
correctly.
rootproject and backend don’t provide any code by themselves so I would like SonarLint to act on the module<N>
projects individually.
I can’t get New Code mode to work properly, and I believe the issue is with SonarLint not knowing or realising the source files are actually in a submodule that has parents whose path has to be prefixed to the local, relative path of the files in the project:
GET 404 https://myserver/sonar/batch/issues?key=ROOTPROJECT%3Asrc%2Fmain%2Fjava%2FsomePackage%2FSomeClass.java&branch=master
I tried with a browser that same URL but prefixing src
with backend%2FmoduleA%2F
and it works fine (returns some content and not a 404).
I also see lines like this (one for each folder) at the beginning of the scan (which maybe are the reason why the files don’t have the correct prefix?)
[DefaultSonarLintProjectAdapter#collect] Try get Eclipse file of resource ‘F/moduleA/src/main/java/somePackage’ → ‘F/moduleA/src/main/java/somePackage’ could not be adapted to ‘.eclipse.core.resources.IFile’
Find below the (almost) full log of a manually triggered analysis on Changed files. There is only one changed file with 3 issues. Only one of them is new code. I guess the 404 error is while querying the SonarQube server for already existing issues on that class and therefore the reason why SonarLint can’t filter New Code issues only.
Could anyone please help me get New Code issue filtering working on Eclipse? That is, if this can work at all with this plugin version. I know it’s old and probably unsupported, but it’s the only one I can use with my SonarQube server as of now.
[SelectionUtils#collectProjects] Try get container of object 'P/moduleA' -> 'P/moduleA' could not be adapted to '.sonarlint.eclipse.core.resource.ISonarLintProjectContainer'
[DefaultSonarLintProjectAdapter#collect] Try get Eclipse file of resource 'P/moduleA' -> 'P/moduleA' could not be adapted to '.eclipse.core.resources.IFile'
[DefaultSonarLintProjectAdapter#collect] Try get Eclipse file of resource 'F/moduleA/src' -> 'F/moduleA/src' could not be adapted to '.eclipse.core.resources.IFile'
[DefaultSonarLintProjectAdapter#collect] Try get Eclipse file of resource 'F/moduleA/src/main/java/somePackage' -> 'F/moduleA/src/main/java/somePackage' could not be adapted to '.eclipse.core.resources.IFile'
... <Similar log line for all subdirectories>
Analyzing 1 changed file(s) in 1 project(s)
Trigger: MANUAL_CHANGESET
Analysis started with the engines being ready
Clear markers on 0 excluded files
SonarLint processing file /moduleA/src/main/java/somepackage/SomeClass.java...
* css: 23 active rules
* java: 468 active rules
Rule java:S2077 is enabled on the server, but not available in SonarLint
... <Several irrelevant similar lines>
Triggering analysis with configuration: [
baseDir: C:\SomeAbsolutePath\rootproject\backend\moduleA
extraProperties: {sonar.updatecenter.cache.ttl=3600000, sonaranalyzer-cs.nuget.packageVersion=8.32.0.39516, sonar.auth.bitbucket.allowUsersToSignUp=true, sonar.cs.ignoreHeaderComments=true, sonar.typescript.file.suffixes=.ts,.tsx, sonar.auth.github.enabled=false, sonar.python.coverage.reportPaths=coverage-reports/*coverage-*.xml, sonaranalyzer-vbnet.nuget.packageVersion=8.32.0.39516, sonar.groovy.file.suffixes=.groovy, sonar.go.file.suffixes=.go, sonar.java.test.binaries=C:/SomeAbsolutePath/rootproject/backend/moduleA/target/test-classes, sonar.auth.saml.applicationId=sonarqube, sonar.zpa.errorRecoveryEnabled=true, email.fromName=SonarQube, sonar.python.xunit.skipDetails=false, sonar.dbcleaner.weeksBeforeKeepingOnlyAnalysesWithVersion=104, sonar.qualitygate.ignoreSmallChanges=true, sonar.go.exclusions=**/vendor/**, sonar.php.exclusions=**/vendor/**, sonar.terraform.file.suffixes=.tf, sonar.forceAuthentication=false, sonar.notifications.delay=60, sonar.groovy.ignoreHeaderComments=true, sonar.vbnet.roslyn.ignoreIssues=false, sonar.flex.file.suffixes=as, sonar.groovy.jacoco.itReportPath=target/jacoco-it.exec, sonar.auth.gitlab.groupsSync=false, sonar.auth.github.apiUrl=https://api.github/, sonar.ruby.file.suffixes=.rb, sonaranalyzer-cs.ruleNamespace=SonarAnalyzer.CSharp, sonar.auth.github.allowUsersToSignUp=true, sonar.cs.analyzeGeneratedCode=false, sonar.python.xunit.reportPath=xunit-reports/xunit-result-*.xml, sonar.builtInQualityProfiles.disableNotificationOnUpdate=false, sonar.javascript.globals=angular,goog,google,OenLayers,d3,dojo,dojox,dijit,Backbone,moment,casper,_, sonar.dbcleaner.hoursBeforeKeepingOnlyOneSnapshotByDay=24, sonar.yaml.file.suffixes=.yaml,.yml, sonar.auth.bitbucket.enabled=false, sonar.terraform.activate=true, sonar.java.source=1.7, sonar.css.file.suffixes=.css,.less,.scss, sonar.auth.github.webUrl=https://github/, sonar.projectBaseDir=C:/SomeAbsolutePath/rootproject, sonar.html.file.suffixes=.html,.xhtml,.cshtml,.vbhtml,.aspx,.ascx,.rhtml,.erb,.shtm,.shtml, sonaranalyzer-vbnet.nuget.packageId=SonarAnalyzer.VisualBasic, sonar.auth.gitlab.enabled=false, sonar.cpd.cross_project=false, email.from=noreply@nowhere, sonaranalyzer-vbnet.pluginVersion=8.32.0.39516, sonar.vbnet.ignoreHeaderComments=true, sonar.auth.github.groupsSync=false, sonar.dbcleaner.weeksBeforeKeepingOnlyOneSnapshotByWeek=4, sonaranalyzer-vbnet.analyzerId=SonarAnalyzer.VisualBasic, email.prefix=[SONARQUBE], sonar.sources=backend/moduleA/src/main/java, sonar.scala.file.suffixes=.scala, sonar.cs.roslyn.ignoreIssues=false, sonar.cloudformation.activate=true, sonar.java.libraries=<many_jars.jar>}
activeRules: [<several rules>]
inputFiles: [
file:/C:/SomeAbsolutePath/rootproject/backend/moduleA/src/main/java/somepackage/SomeClass.java (UTF-8)
]
]
Start analysis
Index files
Language of file "file:/C:/SomeAbsolutePath/rootproject/backend/moduleA/src/main/java/somepackage/SomeClass.java" is detected to be "JAVA"
1 file indexed
Added 144 checks for language='ts', repository='typescript'
Added 155 checks for language='js', repository='javascript'
Execute Sensor: JavaSensor
No workDir in SonarLint
Configured Java source version (sonar.java.source): 7
JavaClasspath initialization
Property 'sonar.java.jdkHome' resolved with:
[]
Property 'sonar.java.libraries' resolved with:
[<many_jars.jar>]
JavaClasspath initialization (done) | time=2ms
JavaTestClasspath initialization
Property 'sonar.java.jdkHome' resolved with:
[]
Property 'sonar.java.test.libraries' resolved with:
[<many_jars.jar>]
JavaTestClasspath initialization (done) | time=3ms
Java "Main" source files AST scan
1 source file to be analyzed
Initializing metadata of file file:/C:/SomeAbsolutePath/rootproject/backend/moduleA/src/main/java/somepackage/SomeClass.java
[SE] Loaded 179 hardcoded method behaviors.
Analysis time of [uri=file:/C:/SomeAbsolutePath/rootproject/backend/moduleA/src/main/java/somepackage/SomeClass.java] (89ms)
1/1 source file has been analyzed
Java "Main" source files AST scan (done) | time=89ms
No "Test" source files to scan.
No "Generated" source files to scan.
'Scala Sensor' skipped because there are no related files in the current project
'Python Sensor' skipped because there are no related files in the current project
Execute Sensor: JavaXmlSensor
Execute Sensor: HTML
'XML Sensor' skipped because there are no related files in the current project
'Kotlin Sensor' skipped because there are no related files in the current project
'PHP sensor' skipped because there are no related files in the current project
'Analyzer for "php.ini" files' skipped because there are no related files in the current project
'JavaScript/TypeScript analysis' skipped because there are no related files in the current project
'JavaScript inside YAML analysis' skipped because there are no related files in the current project
'JavaScript inside HTML analysis' skipped because there are no related files in the current project
Execute Sensor: CSS Rules
No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
'Ruby Sensor' skipped because there are no related files in the current project
Execute Sensor: TextAndSecretsSensor
Available processors: 24
Using 24 threads for analysis.
Analyzing all except non binary files
1 source file to be analyzed
1/1 source file has been analyzed
Analysis detected 3 issues and 0 Security Hotspots in 188ms
Found 3 issue(s)
GET 404 https://myserver/sonar/batch/issues?key=ROOT_PROJECT%3Asrc%2Fmain%2Fjava%2FsomePackage%2FSomeClass.java&branch=master | response time=423ms
Downloaded issues in 423ms
Wrote 0 issues in store | took 1ms
Done in 639 ms
Share
Improve this question
asked Feb 13 at 23:01
Xavi LópezXavi López
27.9k11 gold badges99 silver badges163 bronze badges
1 Answer
Reset to default 0After testing older versions of SonarLint for Eclipse I found out 9.3.0.81553 works for me.
The next version 10.0.0.81687 doesn’t, it queries Sonar’s /batch/issues
endpoint without the parent paths backend/moduleA
of the module.
本文标签:
版权声明:本文标题:New Code with a Maven multimodule project in SonarLint for Eclipse - Module parent paths missing - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741502816a2382144.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论