dotnet/aspnetcore

Analyzers API1000 and API1001 should trigger on conditional returns

クローズ

#33,105 opened on 2021/05/28

 (9 件のコメント) (2 件のリアクション) (0 人の担当者)C# (10,653 件のフォーク)batch import
analyzerarea-mvcfeature-openapigood first issuehelp wanted

Repository metrics

Stars
 (37,933 個のスター)
PR merge metrics
 (PR metrics pending)

説明

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
}

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