Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checkstyle.xmlに汎用検査例外のキャッチを禁止する設定を追加 #1874

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions documents/contents/guidebooks/conventions/coding-conventions.md
Original file line number Diff line number Diff line change
@@ -51,3 +51,21 @@ SpotBugs を利用して、 SpotBugs が提供するバグパターンに該当
- [SpotBugs プラグイン](../how-to-develop/java/common-project-settings.md#spotbugs-plugin)
- [Java formatting and linting :material-open-in-new:](https://code.visualstudio.com/docs/java/java-linting){ target=_blank }
- [静的コード分析とフォーマット(Vue.js)](../how-to-develop/vue-js/static-verification-and-format.md)

## AlesInfiny Maia でカスタマイズしている規約 {#custom-conventions}

AlesInfiny Maia では上記に示した基本のコーディング規約に加えて、以下に示すカスタマイズした規約を採用しています。

- Java アプリケーション

- Checkstyle プラグイン

Checkstyle の規約をカスタマイズする場合、 Checkstyle プラグインが読み込むインプットファイルを編集します。具体的な方法については [こちら](../how-to-develop/java/common-project-settings.md#checkstyle-plugin) を参照ください。
Checkstyle プラグインでカスタマイズする規約は以下の通りです。

- [IllegalCatch :material-open-in-new:](https://checkstyle.sourceforge.io/checks/coding/illegalcatch.html){ target=_blank }

汎用検査例外を含む特定の例外のキャッチを禁止します。

汎用的な例外をキャッチしてしまうと、具体的な例外が隠蔽されてしまい、原因の特定が難しくなります。
汎用的な例外ではなく、具体的な例外のみをキャッチするように本規約を設けます。
Original file line number Diff line number Diff line change
@@ -283,5 +283,6 @@
<property name="exceptionVariableName" value="expected"/>
</module>
<module name="CommentsIndentation"/>
<module name="IllegalCatch"/>
</module>
</module>
Original file line number Diff line number Diff line change
@@ -9,4 +9,6 @@
<suppress checks=".*" files="com[\\/]dressca[\\/]infrastructure[\\/]repository[\\/]mybatis[\\/]generated"/>
<!-- テストクラスのメソッド名はチェックしない(日本語を使用するため) -->
<suppress checks="MethodName" files=".*Test.java$"/>
<!-- テストクラスでは汎用的な例外のキャッチを禁止しない -->
<suppress checks="IllegalCatch" files=".*Test.java$"/>
</suppressions>
Original file line number Diff line number Diff line change
@@ -283,5 +283,6 @@
<property name="exceptionVariableName" value="expected"/>
</module>
<module name="CommentsIndentation"/>
<module name="IllegalCatch"/>
</module>
</module>
Original file line number Diff line number Diff line change
@@ -11,4 +11,6 @@
<suppress checks="MethodName" files=".*Test.java$"/>
<!-- メッセージクラスの文字数はチェックしない -->
<suppress checks="LineLength" files=".*MessageIdConstants.java$"/>
<!-- テストクラスでは汎用的な例外のキャッチを禁止しない -->
<suppress checks="IllegalCatch" files=".*Test.java$"/>
</suppressions>