Skip to content
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

Cannot connect SonarLint to SonarQube in 6.7.0.52071 #3251

Merged
merged 2 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ public void GetAnalysisLanguageFromExtension_ReturnsAnalysisLangFromExtension(st

[DataRow("File.json")]
[DataRow("Folder")]
[DataRow("<SharedProject>")] //Shared projects in .Net Framework are represented by <>
[TestMethod]
public void GetAnalysisLanguageFromExtension_UnknownExtensionPassed_ReturnsNull(string fileName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ private static bool IsTypeScriptDocument(IEnumerable<IContentType> contentTypes)

public AnalysisLanguage? GetAnalysisLanguageFromExtension(string fileName)
{
if(IsFileNameInvalid(fileName))
{
return null;
}

var extension = GetNormalizedExtention(fileName);

// ContentType for "js" is typescript we do manual check to be consistent with Detect method
Expand Down Expand Up @@ -154,6 +159,16 @@ private string GetNormalizedExtention(string fileName)
return extension.ToLowerInvariant();
}


private bool IsFileNameInvalid(string fileName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://stackoverflow.com/questions/27253394/getinvalidfilenamechars-doesnt-contain-all-illegal-chars

I think it's better to do a try-catch around GetNormalizedExtention

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a concern for us. Our code will always run on a windows machine. This would create problems if we had operations run on different systems.

{
foreach (var invalidChar in Path.GetInvalidFileNameChars())
{
if(fileName.Contains(invalidChar))
{
return true;
}
}
return false;
}
}
}