dotnet/aspnetcore

Analyzers API1000 and API1001 should trigger on conditional returns

Open

#33,105 opened on 2021年5月28日

GitHub で見る
 (9 comments) (2 reactions) (0 assignees)C# (10,653 forks)batch import
analyzerarea-mvcfeature-openapigood first issuehelp wanted

Repository metrics

Stars
 (37,933 stars)
PR merge metrics
 (平均マージ 16d 9h) (30d で 258 merged PRs)

説明

Describe the solution you'd like

Analyzers API1000 and API1001 should trigger on returns (or expression-bodied methods) with conditional expressions.

Additional context

public ActionResult<object> OopsUndocumentedIf(int id)
{
    if (id == 0)
    {
        return NotFound(); // API1000
    }

    return Ok(new object());
}

public ActionResult<object> OopsUndocumentedConditional(int id)
{
    return id == 0 ? NotFound() : Ok(new object()); // No API1000
}

コントリビューターガイド