2017-10-11 69 views
0

我有一個問題,其中SonarQube認爲我的本地函數以函數作用域範圍內的變量賦值結束是無用的賦值。如何使用C#7.0定義清除此錯誤或在SonarQube中繞過它?SonarQube MsBuild,支持C#7.0本地函數?

我該如何解決這個問題?

功能定義:

public (bool, int) func(string str) 
    { 
     int variable = 0; 

     // C# 7.0 - Local Functions 

     void localFunc() 
     { 
      variable = 1; //SonarQube complains that this usless assignment needs to be removed 
     } 


     return (true, variable); 
    } 

回答

1

SonarC#不支持(還)C#7特點等等一些分析結果奇怪的輸出。您現在唯一能做的就是在SonarQube實例下將問題標記爲False Positive