-
Notifications
You must be signed in to change notification settings - Fork 144
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
SCAN4NET-171 Read new properties for downloading plugins #2294
base: master
Are you sure you want to change the base?
Conversation
0e8ecff
to
fdc4cef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small conceptual nuke to start with
src/SonarScanner.MSBuild.PreProcessor/Interfaces/IAnalyzerProvider.cs
Outdated
Show resolved
Hide resolved
src/SonarScanner.MSBuild.PreProcessor/Roslyn/RoslynAnalyzerProvider.cs
Outdated
Show resolved
Hide resolved
src/SonarScanner.MSBuild.PreProcessor/Roslyn/RoslynAnalyzerProvider.cs
Outdated
Show resolved
Hide resolved
src/SonarScanner.MSBuild.PreProcessor/Roslyn/RoslynAnalyzerProvider.cs
Outdated
Show resolved
Hide resolved
src/SonarScanner.MSBuild.PreProcessor/Roslyn/RoslynAnalyzerProvider.cs
Outdated
Show resolved
Hide resolved
src/SonarScanner.MSBuild.PreProcessor/Roslyn/RoslynAnalyzerProvider.cs
Outdated
Show resolved
Hide resolved
src/SonarScanner.MSBuild.PreProcessor/Roslyn/RoslynAnalyzerProvider.cs
Outdated
Show resolved
Hide resolved
51fadff
to
ad8f09f
Compare
5fb0eda
to
1e11364
Compare
ad8f09f
to
ac9dd05
Compare
1e11364
to
f4efaca
Compare
98affdf
to
f089335
Compare
f089335
to
80132ec
Compare
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some polishing
{ | ||
SuppliedPlugins.Should().NotBeEmpty("No plugins have been requested"); | ||
var found = SuppliedPlugins.Any(x => string.Equals(key, x.Key, System.StringComparison.Ordinal)); | ||
found.Should().BeTrue("Expected plugin was not requested. Id: {0}", key); | ||
var suppliedPlugin = SuppliedPlugins.FirstOrDefault(x => string.Equals(plugin.Key, x.Key, System.StringComparison.Ordinal)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To throw in case the expectation of having single with that key is broken
var suppliedPlugin = SuppliedPlugins.FirstOrDefault(x => string.Equals(plugin.Key, x.Key, System.StringComparison.Ordinal)); | |
var suppliedPlugin = SuppliedPlugins.SingleOrDefault(x => string.Equals(plugin.Key, x.Key, System.StringComparison.Ordinal)); |
{ | ||
SuppliedPlugins.Should().NotBeEmpty("No plugins have been requested"); | ||
var found = SuppliedPlugins.Any(x => string.Equals(key, x.Key, System.StringComparison.Ordinal)); | ||
found.Should().BeTrue("Expected plugin was not requested. Id: {0}", key); | ||
var suppliedPlugin = SuppliedPlugins.FirstOrDefault(x => string.Equals(plugin.Key, x.Key, System.StringComparison.Ordinal)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What the Java?
var suppliedPlugin = SuppliedPlugins.FirstOrDefault(x => string.Equals(plugin.Key, x.Key, System.StringComparison.Ordinal)); | |
var suppliedPlugin = SuppliedPlugins.FirstOrDefault(x => plugin.Key = x.Key); |
@@ -18,11 +18,6 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
|
|||
using System; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you see why it's worth taking care of the project structure in general? :)
private const string RoslynRepoPrefix = "roslyn."; | ||
private const string ServerPropertyFormat = "sonar.{0}.analyzer"; | ||
private const string RoslynRepoPrefix = "roslyn."; // Used for plugins generated by SonarQube Roslyn SDK, and legacy Sonar Security C# Frontend | ||
private const string LegacySecurityFrontEndPropertyPrefix = "sonaranalyzer.security.cs"; // Should not be used and exists for backward compatibility with version <= 9.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment doesn't sound right on the Security front end. It's only used for deduplication, and it's not really needed for backward compatibility.
As this constant was not here before, I'd hardcode the value below where it's used.
private const string ServerPropertyFormat = "sonar.{0}.analyzer"; | ||
private const string RoslynRepoPrefix = "roslyn."; // Used for plugins generated by SonarQube Roslyn SDK, and legacy Sonar Security C# Frontend | ||
private const string LegacySecurityFrontEndPropertyPrefix = "sonaranalyzer.security.cs"; // Should not be used and exists for backward compatibility with version <= 9.2 | ||
private const string LegacyServerPropertyPrefix = "sonaranalyzer-"; // Should not be used and exists for backward compatibility with version <= 9.2. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is version 9.2? Plugin? SonarQube? Scanner?
Plugin was < 10.4
SQ was < 10.8
Scanner is irrelevant
private const string LegacyServerPropertyPrefix = "sonaranalyzer-"; // Should not be used and exists for backward compatibility with version <= 9.2. | |
private const string LegacyServerPropertyPrefix = "sonaranalyzer-"; // Backward compatibility with ??? version <= 9.2. |
} | ||
|
||
[TestMethod] | ||
public void RoslynConfig_ValidProfile_Security_Frontend() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not write 3 dedicated UT for security. Add the scaffolding to the existing UTs above
} | ||
|
||
[TestMethod] | ||
public void RoslynConfig_IncompletePluginDoesNotPopulate() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void RoslynConfig_IncompletePluginDoesNotPopulate() | |
public void RoslynConfig_IncompletePluginIgnored() |
{"sonar.cs.analyzer.dotnet.staticResourceName", "SonarAnalyzer.zip"}, | ||
}); | ||
var context = new Context(TestContext, sonarProperties, [[@"c:\assembly1.dll"], [@"d:\foo\assembly2.dll"]]); | ||
var expectedSonarLintXml = """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point of asserting this file in this UT? It seems immutable to the scaffolding
{"sonar.cs.analyzer.security.pluginVersion", "1.13.0"}, | ||
{"sonar.cs.analyzer.security.staticResourceName", "SecurityAnalyzer.zip"}, | ||
{"sonaranalyzer.security.cs.analyzerId", "SonarAnalyzer.Security"}, | ||
{"sonaranalyzer.security.cs.ruleNamespace", "SonarAnalyzer.Security"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ruleNamespace
should not exist as part of the new properties
{"wintellect.pluginKey", "wintellect"}, | ||
{"sonar.cs.analyzer.dotnet.analyzerId", "SonarAnalyzer.CSharp"}, | ||
{"sonar.cs.analyzer.dotnet.ruleNamespace", "SonarAnalyzer.CSharp"}, | ||
{"sonar.cs.analyzer.dotnet.staticResourceName", "SonarAnalyzer.zip"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this trying to say? That any missing property will be no-op? It's bit hard to see. We should make that more explicit. Something like this:
{"sonar.cs.analyzer.security.missing-pluginKey", "securitycsharpfrontend"},
{"sonar.cs.analyzer.security.pluginVersion", "1.13.0"},
{"sonar.cs.analyzer.security.staticResourceName", "SecurityAnalyzer.zip"},
The question is how to make it visible for all 3 of them. Parametrized test with analyzerIdName, versionName, staticResourceName
?
SCAN4NET-171