> For the complete documentation index, see [llms.txt](https://help.aikido.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.aikido.dev/docs/docs-ja/kdo/code-quality-setup.md).

# PR におけるコード品質

PR チェックが対象とするのは **新しいコード**、つまりプルリクエストで追加または変更した行です。Aikido はそれらの変更を自動でスキャンし、インラインコメントを残すか、ゲートを失敗させることで、品質の問題がメインブランチに入るのを防ぎます。

このガイドでは、PR / MR チェックでコード品質を設定する手順を説明します。スキャンするには **既存コード** リポジトリ全体にわたってカテゴリスコア、公開中の検出事項、ホットスポットを確認するには、 [リポジトリスキャン](/docs/docs-ja/kdo/repository-scans.md).

## 前提条件

始める前に、以下を確認してください：

* GitHub、Bitbucket、GitLab、または Azure DevOps Git に接続されたアカウント
* Aikido アカウントへの管理者権限
* [Aikido に接続されたリポジトリ](/docs/docs-ja/kdosukyan/connect-your-source-code.md)

Code Quality は、ローカルスキャンアカウントや Team Foundation Version Control (TFVC) リポジトリでは利用できません。

## 開始するには <a href="#getting-started" id="getting-started"></a>

最初のコード品質ステップを設定して実行するには、全部で 3 つの手順があります。Aikido の UI では、サイドバーからアクセスできる Code Quality ページで、従うべき手順が明確に表示されます。以下に、より詳しい説明を示します。

{% stepper %}
{% step %}
**リポジトリで Code Quality を有効にする**

Code Quality チェックを有効にするリポジトリを選択してください：

1. をクリック **リポジトリを設定** Code Quality ページで PR チェックページを開きます。まだ CI チェックを設定していない場合は、インストールフローに進みます。
2. Code Quality チェックを実行したいリポジトリを選択して、有効にします **Code Quality スキャン**.
3. Code Quality コメントの最低重大度を選択してください。Aikido は、その重大度以上の検出事項に対してコメントを追加します。
4. 有効にする **オープンな品質コメントがある場合はチェックを失敗させる** Aikido が選択した重大度以上の Code Quality 問題を見つけたときにチェックを失敗させます。

<div data-with-frame="true"><figure><img src="/files/99565b45b0f3b67bc38579c216cf7c0183ee1a80" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
**品質チェックを選択**

Code Quality Checks ページで、どのコード品質ルールを適用するかを設定します

1. 利用可能なチェックを次の分類で確認してください：
   * **デフォルトチェック** - 複数言語向けの事前設定済みベストプラクティス
   * **カスタムチェック** - チーム固有のルール（後で追加できます）
2. チームのニーズに応じてチェックのオン／オフを切り替えます

<div data-with-frame="true"><figure><img src="/files/764dd8f182a99525c92d01890c92c72fe93c3524" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
**最初のスキャンを実行する**

リポジトリとチェックを設定したら：

1. 新しいプルリクエストを作成するか、設定済みリポジトリの既存のプルリクエストに新しいコミットを push します。これにより、最初の Code Quality スキャンが自動的に開始されます。
2. 結果を確認するには **アクティビティ** タブ。
   {% endstep %}
   {% endstepper %}

Code Quality の問題を修正すると、Aikido は自動的にコメントを解決します。 [問題修正後に Aikido がコメントをどのように扱うかを学ぶ](/docs/docs-ja/pr-torirsunogtingu/aikido-ci-gating-functionality/autofix-suggestions-and-inline-commenting-for-pr-checks.md#what-happens-to-comments-after-you-fix-an-issue).

## 重大度の決定方法

すべての Code Quality ルールには基本の重大度があり、 [**Checks** ページ](https://app.aikido.dev/code-quality/checks)に表示されます。Aikido が違反を見つけると、その基本重大度から始めて、特定のコンテキストに応じて調整します。最終的な検出事項の重大度は、ルールの基本重大度より高くなることも低くなることもあります。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.aikido.dev/docs/docs-ja/kdo/code-quality-setup.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
