From 41df251669785a2baed6e861b623759ac766c691 Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Mon, 2 Dec 2024 11:58:10 +0900 Subject: [PATCH] chore: remove pre-commit and fix format --- .devcontainer/boot.sh | 3 --- .devcontainer/term_settings/pre-commit | 4 ---- CONTRIBUTING.md | 7 +++---- CONTRIBUTING_JP.md | 7 +++---- cobj/format | 1 - 5 files changed, 6 insertions(+), 16 deletions(-) delete mode 100755 .devcontainer/term_settings/pre-commit diff --git a/.devcontainer/boot.sh b/.devcontainer/boot.sh index ff3b253e..2e20ebd8 100755 --- a/.devcontainer/boot.sh +++ b/.devcontainer/boot.sh @@ -5,8 +5,5 @@ make make install -# Set up pre-commit hook -cp .devcontainer/term_settings/pre-commit .git/hooks/pre-commit - # Set up ~/.bashrc cat .devcontainer/term_settings/extra_bashrc.sh >> ~/.bashrc diff --git a/.devcontainer/term_settings/pre-commit b/.devcontainer/term_settings/pre-commit deleted file mode 100755 index dbc77f69..00000000 --- a/.devcontainer/term_settings/pre-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -./format -git add -u diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c3b2fb9e..3d14bac2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,6 +10,8 @@ Although any topics related to opensource COBOL 4J can be posted in [Issues](htt We will check pull requests that passed all CI checks running both tests and static code analysis. The static analysis checks whether C and Java source files are formatted using [clang-format](https://clang.llvm.org/docs/ClangFormat.html) and [google-java-format](https://github.com/google/google-java-format) respectively, and whether [PMD](https://pmd.github.io/) finds no error and warning in Java source files. +Before you submit pull requests, you should run `./format` in order to format files in this repository. + The below sections describe how to setup and run static code analysis. ## Setup Development Environment @@ -26,13 +28,10 @@ We strongly recommend using [Visual Studio Code with Dev Containers](https://cod 1. (Optional) Press `Ctrl+Shift+@` to open a new terminal of Visual Studio code. 1. (Optional) [Setup credentials for git](https://code.visualstudio.com/remote/advancedcontainers/sharing-git-credentials). -> [!CAUTION] -> In the dev container, [Git Hooks](https://git-scm.com/book/ms/v2/Customizing-Git-Git-Hooks) executes code formatters when starting `git commit` command. It may take a minutes when you run `git commit` for the first time. - ## Run static analysis > [!CAUTION] -> CI executes formatters and static analysis tools in Almalinux 9. The behavior of these tools may differ from the one in other operatins systems. +> Since the behavior of these tools may differ from the one in other operatins systems, we recommend that you run `./format` in Visual Studio Code with Dev Containers described in the previous section. ### check with clang-format and google-java-format diff --git a/CONTRIBUTING_JP.md b/CONTRIBUTING_JP.md index d9733c87..8bebc24c 100644 --- a/CONTRIBUTING_JP.md +++ b/CONTRIBUTING_JP.md @@ -10,6 +10,8 @@ CIはテストとコードの静的解析を実行します。 CIの静的解析はCとJavaのソースコードがそれぞれ[clang-format](https://clang.llvm.org/docs/ClangFormat.html) and [google-java-format](https://github.com/google/google-java-format)で整形されているか、 [PMD](https://pmd.github.io/)によるJavaソースコードの静的解析でエラーや警告が表示されないかをチェックします。 +Pull Request提出時には、./formatを実行してリポジトリ内のコードをフォーマットしてください。 + 下記にそれぞれのツールのセットアップと使用方法を説明します。 ## 開発環境のセットアップ @@ -26,14 +28,11 @@ CIの静的解析はCとJavaのソースコードがそれぞれ[clang-format](h 1. (オプション)`Ctrl+Shift+@`を押して、Visual Studio Codeの新しいターミナルを開きます。 1. (オプション)[gitの認証情報を設定](https://code.visualstudio.com/remote/advancedcontainers/sharing-git-credentials)します。 -> [!CAUTION] -> Dev container内では、[Git Hooks](https://git-scm.com/book/ms/v2/Customizing-Git-Git-Hooks)が`git commit`コマンドを開始する際にコードフォーマッタを実行します。初めて`git commit`を実行する際には数分かかることがあります。 - ## 静的解析の実行 > [!CAUTION] -> CIはAlmalinux 9でフォーマッタと静的解析ツールを実行します。これらのツールの動作は他のオペレーティングシステムとは異なる場合があります。 +> これらのツールの動作は他のオペレーティングシステムとは異なる場合があります。上記のVisual Studio Code with Dev Containersの環境でフォーマッタを実行することを推奨します。 ### clang-formatとgoogle-java-format diff --git a/cobj/format b/cobj/format index 7205d31b..3b835409 100755 --- a/cobj/format +++ b/cobj/format @@ -7,7 +7,6 @@ codegen.c \ config.c \ error.c \ field.c \ -pplex.c \ ppparse.c \ ppparse.h \ reserved.c \