# 静的解析が必要な理由

### 静的解析とは

静的解析を使えば明らかに動かない構文崩れのコードを検知したり使っていない変数を発見する事が出来ます(他にも色々)。

2章で書いたテストコードとは違う側面から検証できます。

### フォーマッターとは

ソースコードのインデントを整えてくれるツールをフォーマッターといいます。

今までいっぱいバックスペースキーを押してインデント整えるの面倒ではありませんでしたか？

rubocopには静的解析だけでなくフォーマットも出来ます。

{% hint style="warning" %}
**失敗談・静的解析導入編**

チームに参加して2\~3年が経った頃です。

人も増えて4名ほどの体制になりテストを記述する文化が根付いてきた頃です。

別の問題が出てきました。

みんな"俺が一番いけてると思うフォーマット"でコードに個性を出し始めました。

PRのレビューでインデントを指定されたり変数の命名が指定されることも増え始めました。

この消耗の中で、あるチームメンバーがrubocopを導入してくれました。

rubocopによる自動レビューは当時のメンバーには、かなり効果的でした。

インデントを手作業で修正することもなくなり、明らかに変な名前のメソッドはrubocopがブロックしてくれたので開発工数の削減に繋がりました。
{% endhint %}


---

# Agent Instructions: 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:

```
GET https://kashiwara.gitbook.io/rubydesurufurusukuratchibe/di-san-zhang-jing-de-jie-xi/gana.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
