dotnet/aspnetcore

Analyzers API1000 and API1001 should trigger on conditional returns

Open

#33,105 建立於 2021年5月28日

在 GitHub 查看
 (9 留言) (2 反應) (0 負責人)C# (10,653 fork)batch import
analyzerarea-mvcfeature-openapigood first issuehelp wanted

倉庫指標

Star
 (37,933 star)
PR 合併指標
 (平均合併 16天 9小時) (30 天內合併 258 個 PR)

描述

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
}

貢獻者指南