Skip to content

Commit c6aed74

Browse files
Add devcontainer (#529)
1 parent 92fa351 commit c6aed74

File tree

90 files changed

+27142
-26316
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+27142
-26316
lines changed

.devcontainer/Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM almalinux:9
2+
3+
SHELL ["/bin/bash", "-c"]
4+
5+
# classpath settings
6+
ENV CLASSPATH :/usr/lib/opensourcecobol4j/libcobj.jar
7+
RUN echo 'export CLASSPATH=:/usr/lib/opensourcecobol4j/libcobj.jar' >> ~/.bashrc
8+
9+
# install dependencies
10+
RUN dnf update -y
11+
RUN dnf install -y epel-release
12+
RUN dnf install -y gcc make bison flex automake autoconf diffutils gettext java-21-openjdk-devel git-clang-format cppcheck

.devcontainer/boot.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# Build and Install
4+
./configure --prefix=/usr/
5+
make
6+
make install
7+
8+
# Set up pre-commit hook
9+
cp .devcontainer/term_settings/pre-commit .git/hooks/pre-commit
10+
11+
# Set up ~/.bashrc
12+
cat .devcontainer/term_settings/extra_bashrc.sh >> ~/.bashrc

.devcontainer/devcontainer.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "opensource COBOL 4J development",
3+
"build": {
4+
"dockerfile": "Dockerfile"
5+
},
6+
"postCreateCommand": ".devcontainer/boot.sh && source ~/.bashrc"
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
alias ls='ls --color=auto'
2+
alias ll='ls -l'
3+
alias la='ls -a'
4+
5+
alias g='git'
6+
7+
parse_git_branch() {
8+
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
9+
}
10+
11+
export PS1="\e[0;32m[\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\]\e[0;32m]\033[00m "
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
git add -u
4+
./format

.github/workflows/static-analysis.yml

+13-12
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ permissions:
99
jobs:
1010
static_analysis:
1111
runs-on: ubuntu-22.04
12+
container:
13+
image: almalinux:9
1214
steps:
13-
# Checkout opensource COBOL
1415
- name: Checkout opensource COBOL 4J
1516
uses: actions/checkout@v4
1617

@@ -21,19 +22,19 @@ jobs:
2122

2223
- name: Install static analysis tools
2324
run: |
24-
sudo apt-get update -y
25-
sudo apt-get install -y clang-format cppcheck
25+
dnf update -y
26+
dnf install -y epel-release
27+
dnf install -y gcc make bison flex automake autoconf diffutils gettext java-21-openjdk-devel git-clang-format cppcheck
2628
2729
- name: Install opensource COBOL 4J
2830
run: |
29-
sudo apt-get install -y build-essential bison flex gettext texinfo autoconf
3031
./configure --prefix=/usr/
3132
make
32-
sudo make install
33+
make install
3334
34-
#- name: Check format with google-java-format and clang-format
35-
# run: |
36-
# ./check-format
35+
- name: Check format with google-java-format and clang-format
36+
run: |
37+
./check-format
3738
3839
- name: Run SpotBugs
3940
working-directory: libcobj
@@ -45,7 +46,7 @@ jobs:
4546
run: |
4647
./gradlew pmdMain
4748
48-
#- name: Run cppcheck
49-
# working-directory: cobj
50-
# run: |
51-
# ./cpp-check
49+
- name: Run cppcheck
50+
working-directory: cobj
51+
run: |
52+
./cpp-check

CONTRIBUTING.md

+18-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,28 @@ The static analysis checks whether C and Java source files are formatted using [
1212

1313
The below sections describe how to setup and run static code analysis.
1414

15-
## Setup static analysis tools
15+
## Setup Development Environment
1616

17-
Run `sudo apt install clang-format` in Ubuntu to install `clang-format`.
17+
We strongly recommend using [Visual Studio Code with Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers) for a consistent development environment. Follow the steps below to set up your development environment.
18+
19+
1. Install [Docker](https://www.docker.com/get-started) on your machine.
20+
1. Install [Visual Studio Code](https://code.visualstudio.com/).
21+
1. Install the [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension in Visual Studio Code.
22+
1. Clone the repository.
23+
1. Open the repository in Visual Studio Code.
24+
1. Press `Ctrl+Shift+P` and Select `Dev Containers: Reopen in Container`.
25+
1. Wait for the DevContainer to start up and the build to complete. It may take several minutes to complete this process.
26+
1. (Optional) Press `Ctrl+Shift+@` to open a new terminal of Visual Studio code.
27+
1. (Optional) [Setup credentials for git](https://code.visualstudio.com/remote/advancedcontainers/sharing-git-credentials).
28+
29+
> [!CAUTION]
30+
> 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.
1831
1932
## Run static analysis
2033

34+
> [!CAUTION]
35+
> CI executes formatters and static analysis tools in Almalinux 9. The behavior of these tools may differ from the one in other operatins systems.
36+
2137
### check with clang-format and google-java-format
2238

2339
Run `./format` in the top directory of opensource COBOL 4J.

CONTRIBUTING_JP.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,29 @@ CIの静的解析はCとJavaのソースコードがそれぞれ[clang-format](h
1212

1313
下記にそれぞれのツールのセットアップと使用方法を説明します。
1414

15-
## セットアップ
15+
## 開発環境のセットアップ
16+
17+
一貫した開発環境を確保するために、[Visual Studio Code with Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers)の使用を強く推奨します。以下の手順に従って開発環境をセットアップしてください。
18+
19+
1. [Docker](https://www.docker.com/get-started)をインストールします。
20+
1. [Visual Studio Code](https://code.visualstudio.com/)をインストールします。
21+
1. Visual Studio Codeに[Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)拡張機能をインストールします。
22+
1. リポジトリをクローンします。
23+
1. Visual Studio Codeでリポジトリを開きます。
24+
1. `Ctrl+Shift+P`を押して、`Dev Containers: Reopen in Container`を選択します。
25+
1. DevContainerの起動とビルドが完了するまで待ちます。このプロセスは数分かかることがあります。
26+
1. (オプション)`Ctrl+Shift+@`を押して、Visual Studio Codeの新しいターミナルを開きます。
27+
1. (オプション)[gitの認証情報を設定](https://code.visualstudio.com/remote/advancedcontainers/sharing-git-credentials)します。
28+
29+
> [!CAUTION]
30+
> Dev container内では、[Git Hooks](https://git-scm.com/book/ms/v2/Customizing-Git-Git-Hooks)`git commit`コマンドを開始する際にコードフォーマッタを実行します。初めて`git commit`を実行する際には数分かかることがあります。
1631
17-
Ubuntuでは`sudo apt install clang-format`コマンドを実行すれば`clang-format`をインストールできます。
1832

1933
## 静的解析の実行
2034

35+
> [!CAUTION]
36+
> CIはAlmalinux 9でフォーマッタと静的解析ツールを実行します。これらのツールの動作は他のオペレーティングシステムとは異なる場合があります。
37+
2138
### clang-formatとgoogle-java-format
2239

2340
opensource COBOL 4Jのトップディレクトリで`./format`を実行してください。

check-format

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
2-
cd libcobj && ./gradlew verGJF
2+
cd libcobj && ./gradlew spotlessCheck
33
cd ../cobj && ./check-format

cobj/codegen.c

+6-12
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ extern unsigned char cb_default_byte;
8787
static int index_read_flag = 0;
8888

8989
static struct label_list {
90-
struct label_list *next;
90+
// struct label_list *next;
9191
int id;
9292
int call_num;
9393
} *label_cache = NULL;
@@ -1416,10 +1416,8 @@ static void joutput_param(cb_tree x, int id) {
14161416
cb_tree l;
14171417
struct literal_list *ll;
14181418
int n;
1419-
int extrefs;
14201419
int sav_stack_id;
14211420
char fname[12];
1422-
COB_UNUSED(extrefs);
14231421

14241422
param_id = id;
14251423

@@ -1506,7 +1504,6 @@ static void joutput_param(cb_tree x, int id) {
15061504
break;
15071505
case CB_TAG_REFERENCE:
15081506
r = CB_REFERENCE(x);
1509-
extrefs = 0;
15101507
if (r->check) {
15111508
joutput("(new GetAbstractCobolField() {");
15121509
joutput_newline();
@@ -1578,7 +1575,6 @@ static void joutput_param(cb_tree x, int id) {
15781575
}
15791576
f = CB_FIELD(r->value);
15801577
if (f->redefines && f->redefines->flag_external) {
1581-
extrefs = 1;
15821578
f->flag_item_external = 1;
15831579
f->flag_external = 1;
15841580
}
@@ -1587,12 +1583,10 @@ static void joutput_param(cb_tree x, int id) {
15871583
}
15881584
for (pechk = f->parent; pechk; pechk = pechk->parent) {
15891585
if (pechk->flag_external) {
1590-
extrefs = 1;
15911586
f->flag_item_external = 1;
15921587
break;
15931588
}
15941589
if (pechk->redefines && pechk->redefines->flag_external) {
1595-
extrefs = 1;
15961590
f->flag_item_external = 1;
15971591
f->flag_external = 1;
15981592
break;
@@ -1979,7 +1973,7 @@ static void joutput_cond(cb_tree x, int save_flag) {
19791973
joutput_indent("public int run(){");
19801974
joutput_indent_level += 2;
19811975
for (; x; x = CB_CHAIN(x)) {
1982-
//最後の文ならreturn文を書く
1976+
// 最後の文ならreturn文を書く
19831977
if (!CB_CHAIN(x)) {
19841978
joutput_indent("return ");
19851979
}
@@ -6236,20 +6230,20 @@ void codegen(struct cb_program *prog, const int nested, char **program_id_list,
62366230

62376231
/* Program local stuff */
62386232

6239-
//コンストラクタの実装コードを出力
6240-
//メンバ変数の初期化を行う
6233+
// コンストラクタの実装コードを出力
6234+
// メンバ変数の初期化を行う
62416235
joutput_line("public %s()", prog->program_id);
62426236
joutput_line("{");
62436237
joutput_line(" init();");
62446238
joutput_line("}");
62456239
joutput_newline();
62466240

6247-
//メンバ変数の初期化メソッドを出力
6241+
// メンバ変数の初期化メソッドを出力
62486242
create_sorted_data_storage_cache();
62496243
joutput_init_method(prog);
62506244
joutput_newline();
62516245

6252-
//メンバ変数の出力
6246+
// メンバ変数の出力
62536247
joutput_declare_member_variables(prog, prog->parameter_list);
62546248
joutput("\n");
62556249

cobj/cpp-check

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ cppcheck --error-exitcode=1 \
55
--enable=performance \
66
--enable=portability \
77
--suppress=unusedFunctions \
8-
--suppress=toomanyconfigs
8+
--suppress=toomanyconfigs \
9+
--suppress=unusedStructMember \
10+
--suppress=leakNoVarFunctionCall \
11+
--suppress=unreadVariable

cobj/ppparse.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ void *malloc(YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
436436
#ifndef YYFREE
437437
#define YYFREE free
438438
#if !defined free && !defined EXIT_SUCCESS
439-
void free(void *); /* INFRINGES ON USER NAME SPACE */
439+
void free(void *); /* INFRINGES ON USER NAME SPACE */
440440
#endif
441441
#endif
442442
#endif

cobj/tree.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ struct cb_field {
515515
cb_tree key; /* KEY */
516516
cb_tree ref; /* reference used in SEARCH ALL */
517517
cb_tree val; /* value to be compared in SEARCH ALL */
518-
} * keys;
518+
} *keys;
519519
int nkeys; /* the number of keys */
520520
int param_num; /* CHAINING param number */
521521
struct cb_picture *pic; /* PICTURE */

format

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
2-
cd libcobj && ./gradlew goJF
2+
cd libcobj && ./gradlew spotlessApply
33
cd ../cobj && ./format

libcobj/app/build.gradle.kts

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
33
plugins {
44
application
55
id("com.github.johnrengelman.shadow") version "8.1.1"
6+
id("com.diffplug.spotless") version "7.0.0.BETA4"
67
id("java")
7-
id("com.github.sherter.google-java-format") version "0.9"
88
id("maven-publish")
99
pmd
1010
id("com.github.spotbugs") version "6.0.25"
@@ -59,6 +59,12 @@ spotbugs {
5959
excludeFilter.set(project.file("${rootDir}/config/spotbugsFilter.xml"))
6060
}
6161

62+
spotless {
63+
java {
64+
googleJavaFormat("1.17.0").aosp().reflowLongStrings().skipJavadocFormatting()
65+
}
66+
}
67+
6268
publishing {
6369
repositories {
6470
maven {
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
/*
2-
* Copyright (C) 2021-2022 TOKYO SYSTEM HOUSE Co., Ltd.
3-
*
4-
* This library is free software; you can redistribute it and/or
5-
* modify it under the terms of the GNU Lesser General Public License
6-
* as published by the Free Software Foundation; either version 3.0,
7-
* or (at your option) any later version.
8-
*
9-
* This library is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
* GNU Lesser General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU Lesser General Public
15-
* License along with this library; see the file COPYING.LIB. If
16-
* not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor
17-
* Boston, MA 02110-1301 USA
18-
*/
19-
20-
package jp.osscons.opensourcecobol.libcobj;
21-
22-
/** TODO: 準備中 */
23-
public class Const {
24-
25-
/** TODO: 準備中 */
26-
public static final String version = "1.1.2";
27-
}
1+
/*
2+
* Copyright (C) 2021-2022 TOKYO SYSTEM HOUSE Co., Ltd.
3+
*
4+
* This library is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public License
6+
* as published by the Free Software Foundation; either version 3.0,
7+
* or (at your option) any later version.
8+
*
9+
* This library is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public
15+
* License along with this library; see the file COPYING.LIB. If
16+
* not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor
17+
* Boston, MA 02110-1301 USA
18+
*/
19+
20+
package jp.osscons.opensourcecobol.libcobj;
21+
22+
/** TODO: 準備中 */
23+
public class Const {
24+
25+
/** TODO: 準備中 */
26+
public static final String version = "1.1.2";
27+
}

0 commit comments

Comments
 (0)