From e61c61ec3f4159bf516dbf3755a8ac4bc3dca64e Mon Sep 17 00:00:00 2001 From: Chengyu HAN Date: Mon, 1 Dec 2025 17:55:50 +0800 Subject: [PATCH 1/5] Create dependabot.yml --- .github/workflows/dependabot.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/workflows/dependabot.yml diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml new file mode 100644 index 0000000..1704304 --- /dev/null +++ b/.github/workflows/dependabot.yml @@ -0,0 +1,11 @@ +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "monthly" From d07db572dff73b47181d8e0ecb62168a388094cf Mon Sep 17 00:00:00 2001 From: Chengyu HAN Date: Mon, 1 Dec 2025 17:55:53 +0800 Subject: [PATCH 2/5] Create CI.yml --- .github/workflows/workflows/CI.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/workflows/CI.yml diff --git a/.github/workflows/workflows/CI.yml b/.github/workflows/workflows/CI.yml new file mode 100644 index 0000000..d75f7b7 --- /dev/null +++ b/.github/workflows/workflows/CI.yml @@ -0,0 +1,27 @@ +name: CI + +on: + push: + branches: + - main + workflow_dispatch: + +# Allow one concurrent deployment +concurrency: + group: 'pages' + cancel-in-progress: true + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: Install and Build + run: | + npm install + npm run docs:build + - name: Deploy (main) + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: gh-pages + folder: docs/.vitepress/dist From 488e19bfdd7681c6d616d1ab8187a0f0136e6e2b Mon Sep 17 00:00:00 2001 From: Chengyu HAN Date: Mon, 1 Dec 2025 17:55:55 +0800 Subject: [PATCH 3/5] Create preview.yml --- .github/workflows/workflows/preview.yml | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/workflows/preview.yml diff --git a/.github/workflows/workflows/preview.yml b/.github/workflows/workflows/preview.yml new file mode 100644 index 0000000..ebc7937 --- /dev/null +++ b/.github/workflows/workflows/preview.yml @@ -0,0 +1,28 @@ +name: PR Preview + +on: + pull_request: + +permissions: + contents: write # upload gh-pages + pull-requests: write # create pr comment + +concurrency: + group: 'preview-${{ github.ref }}' + cancel-in-progress: true + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: Install and Build + env: + BASE_URL: "/Clean-Code-zh/pr-preview/pr-${{ github.event.pull_request.number }}/" + run: | + npm install + npm run docs:build -- --base $BASE_URL + - name: Deploy preview + uses: rossjrw/pr-preview-action@v1 + with: + source-dir: docs/.vitepress/dist From a3e70168346e28e5662aa48035ddd0294f2f2883 Mon Sep 17 00:00:00 2001 From: Chengyu HAN Date: Mon, 1 Dec 2025 17:59:21 +0800 Subject: [PATCH 4/5] remove `workflows/` --- .github/{workflows => }/dependabot.yml | 1 + .github/workflows/{workflows => }/CI.yml | 0 .github/workflows/{workflows => }/preview.yml | 0 3 files changed, 1 insertion(+) rename .github/{workflows => }/dependabot.yml (99%) rename .github/workflows/{workflows => }/CI.yml (100%) rename .github/workflows/{workflows => }/preview.yml (100%) diff --git a/.github/workflows/dependabot.yml b/.github/dependabot.yml similarity index 99% rename from .github/workflows/dependabot.yml rename to .github/dependabot.yml index 1704304..7d62bb8 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/dependabot.yml @@ -1,4 +1,5 @@ # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + version: 2 updates: - package-ecosystem: "github-actions" diff --git a/.github/workflows/workflows/CI.yml b/.github/workflows/CI.yml similarity index 100% rename from .github/workflows/workflows/CI.yml rename to .github/workflows/CI.yml diff --git a/.github/workflows/workflows/preview.yml b/.github/workflows/preview.yml similarity index 100% rename from .github/workflows/workflows/preview.yml rename to .github/workflows/preview.yml From 335f6a0518c45d52e84be3f440ac05e716e31170 Mon Sep 17 00:00:00 2001 From: Chengyu HAN Date: Mon, 1 Dec 2025 18:06:22 +0800 Subject: [PATCH 5/5] =?UTF-8?q?docs:=20=E4=BF=AE=E6=AD=A3=E4=BC=AA?= =?UTF-8?q?=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/ch2.md | 5 +++-- docs/ch3.md | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/ch2.md b/docs/ch2.md index 16f280e..1f1d88f 100644 --- a/docs/ch2.md +++ b/docs/ch2.md @@ -417,9 +417,10 @@ If names are too clever, they will be memorable only to people who share the aut ![](figures/ch2/2_3fig_martin.jpg) -Cuteness in code often appears in the form of colloquialisms or slang. For example, don’t use the name whack() to mean kill(). Don’t tell little culture-dependent jokes like eatMyShorts() to mean abort(). +Cuteness in code often appears in the form of colloquialisms or slang. For example, don’t use the name `whack()` to mean `kill()`. Don’t tell little culture-dependent jokes like `eatMyShorts()` to mean `abort()`. -> 扮可爱的做法在代码中经常体现为使用俗话或俚语。例如,别用 whack[ ](13)来表示 kill( )。别用 eatMyShorts[ ](14)这类与文化紧密相关的笑话来表示 abort( )。 +> 扮可爱的做法在代码中经常体现为使用俗话或俚语。例如,别用 `whack()` 来表示 `kill()`。 +别用 `eatMyShorts()` 这类与文化紧密相关的笑话来表示 `abort()`。 Say what you mean. Mean what you say. diff --git a/docs/ch3.md b/docs/ch3.md index c145dfe..d8321e5 100644 --- a/docs/ch3.md +++ b/docs/ch3.md @@ -441,9 +441,9 @@ In Listing 3-7 we had no choice because the callers were already passing that fl ### 3.6.3 Dyadic Functions 二元函数 -A function with two arguments is harder to understand than a monadic function. For example, writeField(name) is easier to understand than writeField(output-Stream, name).10 Though the meaning of both is clear, the first glides past the eye, easily depositing its meaning. The second requires a short pause until we learn to ignore the first parameter. And that, of course, eventually results in problems because we should never ignore any part of code. The parts we ignore are where the bugs will hide. +A function with two arguments is harder to understand than a monadic function. For example, `writeField(name)` is easier to understand than `writeField(output-Stream, name)`. (^10) Though the meaning of both is clear, the first glides past the eye, easily depositing its meaning. The second requires a short pause until we learn to ignore the first parameter. And that, of course, eventually results in problems because we should never ignore any part of code. The parts we ignore are where the bugs will hide. -> 有两个参数的函数要比一元函数难懂。例如,writeField(name)比 writeField[outputStream,name](10)好懂。尽管两种情况下意义都很清楚,但第一个只要扫一眼就明白,更好地表达了其意义。第二个就得暂停一下才能明白,除非我们学会忽略第一个参数。而且最终那也会导致问题,因为我们根本就不该忽略任何代码。忽略掉的部分就是缺陷藏身之地。 +> 有两个参数的函数要比一元函数难懂。例如,`writeField(name)` 比 `writeField[outputStream,name]` (^10)好懂。尽管两种情况下意义都很清楚,但第一个只要扫一眼就明白,更好地表达了其意义。第二个就得暂停一下才能明白,除非我们学会忽略第一个参数。而且最终那也会导致问题,因为我们根本就不该忽略任何代码。忽略掉的部分就是缺陷藏身之地。 10. I just finished refactoring a module that used the dyadic form. I was able to make the outputStream a field of the class and convert all the writeField calls to the monadic form. The result was much cleaner.