github / github/codeql

False positive in csharp for useless-assignment-to-local

オープン
#22,032 コメント 1 件 リアクション 0 件 担当者 1 名 @hvitved が担当を希望しています GitHub で見る
false-positive
主要言語
CodeQL
スター
10.1k
フォーク
2.1k
平均マージ
2日 15時間
マージ済み PR(30日)
141

説明

**Description of the false positive**

The context is the following: the variable is used inside a lambda and captured by it.

It is not clear to me what the exact cause is. I tried to create a self-contained code sample, but I was not able to trigger the false positive that way, so the sample code relies on AspNetCore, which is the context where I got the warning.

**Code samples or links to source code**

To reproduce, you need a project that depends on AspNetCore, which is possible with a project file like the following: `Sample.csproj`:

```csharp

```

The following is helper code to configure a AspNetCore `WebApplication`:

```csharp
public static class App
{
extension(WebApplication app)
{
public void Configure()
{
string redirectPath = "/app";
app.MapGet("/", () => Results.Redirect(redirectPath));
}
}
}
```

CodeQL complains about the `redirectPath` not being used. The type of the lambda passed to `MapGet` is `Delegate`. An example with self-contained code with a similar setup and the use of a `Delegate` type did not trigger the false positive.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。