False positive on S1075 in ASP.NET MVC with ~/ paths

csharp

(Kristian Williams) #1

When using Server.MapPath("~/ ...") to map a relative path to the server root directory, SonarLint raises an “S1075: Refactor your code not to use hardcoded absolute paths or URIs”.

~/ paths are not absolute by their very nature.

Running SonarLint on Visual Studio 2015 Professional, ASP.NET MVC 5


(Amaury Levé) #2

Hi @Kristian_Williams,

Thanks for the feedback.
I have created a ticket on our backlog (here).

Out of curiosity, can you think of other methods than MapPath where you would use ~?

Cheers,
Amaury