dotnet/aspnetcore

Analyzers API1000 and API1001 should trigger on conditional returns

已关闭

#33,105 创建于 2021年5月28日

 (9 条评论) (2 个反应) (0 位负责人)C# (10,653 个派生)batch import
analyzerarea-mvcfeature-openapigood first issuehelp wanted

仓库指标

星标
 (37,933 个星标)
PR 合并指标
 (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
}

贡献者指南