My C# WIndows Forms Application has some menu links which point out to web URIs. But now my SonarQube Scan is giving me this error/warning(S1075) to refactor my code. So what would be the safe/best way to use web URI inside C# backend code.
private void HelpDocMenu_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("https://docs.google.com/document/d/142SFA/edit?usp=sharing");
}
SonarQube Error
S1075 Refactor your code not to use hardcoded absolute paths or URIs
You have three options:
private void HelpDocMenu_Click(object sender, EventArgs e)
{
#pragma warning disable S1075 // URIs should not be hardcoded
System.Diagnostics.Process.Start("https://docs.google.com/document/d/142SFA/edit?usp=sharing");
#pragma warning restore S1075 // URIs should not be hardcoded
}
private void HelpDocMenu_Click(object sender, EventArgs e)
{
var url = "https://docs.google.com/document/d/142SFA/edit?usp=sharing";
System.Diagnostics.Process.Start(url);
}
Third option is the recommended one.