From d4956c2cd42e543d7ae79b08fa3bd28b98639677 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 10 Feb 2026 14:31:34 +0100 Subject: [PATCH 01/42] test --- .djlintrc | 14 ++++++++++++++ .github/workflows/analysis.yml | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 .djlintrc create mode 100644 .github/workflows/analysis.yml diff --git a/.djlintrc b/.djlintrc new file mode 100644 index 000000000..9c80af64f --- /dev/null +++ b/.djlintrc @@ -0,0 +1,14 @@ +{ + "profile": "golang", + "indent": 2, + "max_line_length": 120, + "format_css": true, + "format_js": true, + "exclude": "node_modules,public,resources,static,.git", + "ignore": "H006,H013,H021,H030,H031,T001,T002", + "custom_blocks": "define,block,range,with,if,else,end", + "linter_output_format": "{filename}:{line} {code} {message} ({match})", + "require_pragma": false, + "preserve_blank_lines": true, + "max_blank_lines": 2 +} diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml new file mode 100644 index 000000000..b98fb5047 --- /dev/null +++ b/.github/workflows/analysis.yml @@ -0,0 +1,33 @@ +name: Hugo Static Analysis + +on: + pull_request: + types: [opened, reopened, synchronize] + +permissions: + contents: read + pull-requests: write + +jobs: + # Analyse des templates Hugo + template-lint: + name: Lint Hugo Templates + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install djLint + run: pip install djlint + + - name: Lint layouts + if: hashFiles('layouts/**/*.html') != '' + run: | + echo "## 🎨 Template Analysis" >> $GITHUB_STEP_SUMMARY + djlint layouts/ --profile=golang --lint --quiet || true + echo "βœ… Layouts checked" >> $GITHUB_STEP_SUMMARY From c883df275107e22ab7066d94de03499497618848 Mon Sep 17 00:00:00 2001 From: Alexis BENOIT Date: Tue, 10 Feb 2026 14:52:38 +0100 Subject: [PATCH 02/42] test --- .github/workflows/analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index b98fb5047..f92bc6e8a 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -1,8 +1,8 @@ name: Hugo Static Analysis -on: - pull_request: - types: [opened, reopened, synchronize] +on: push + # pull_request: + # types: [opened, reopened, synchronize] permissions: contents: read From 652ff130c25a45b06a38bb95e90c3667c462b3c9 Mon Sep 17 00:00:00 2001 From: Alexis BENOIT Date: Tue, 10 Feb 2026 15:01:08 +0100 Subject: [PATCH 03/42] test lint --- layouts/partials/categories/section/hero.html | 2 +- layouts/partials/events/partials/agenda.html | 2 +- layouts/partials/events/section/archives/years.html | 2 +- layouts/partials/jobs/single/job-infos.html | 1 - layouts/partials/locations/partials/location.html | 2 +- layouts/partials/pages/partials/page.html | 2 +- layouts/partials/papers/single/abstract.html | 2 +- layouts/partials/papers/single/sidebar.html | 4 +--- layouts/partials/persons/section/persons-taxonomies.html | 2 +- layouts/partials/posts/partials/post.html | 2 +- layouts/partials/posts/single/signature.html | 2 +- 11 files changed, 10 insertions(+), 13 deletions(-) diff --git a/layouts/partials/categories/section/hero.html b/layouts/partials/categories/section/hero.html index e884f83d8..25ca2a7a2 100644 --- a/layouts/partials/categories/section/hero.html +++ b/layouts/partials/categories/section/hero.html @@ -2,7 +2,7 @@ {{/* Check if page is osuny taxonomy */}} {{ if .Params.is_taxonomy }} - {{ with or .Params.header_text .Title }} + {{ with or .Params.header_text .Title }} {{- $title = . -}} {{ end }} {{ end }} diff --git a/layouts/partials/events/partials/agenda.html b/layouts/partials/events/partials/agenda.html index 74158403b..831a48cec 100644 --- a/layouts/partials/events/partials/agenda.html +++ b/layouts/partials/events/partials/agenda.html @@ -4,7 +4,7 @@ {{ $is_sub_event := .is_sub_event }} {{ $event_attributes := "itemscope itemtype='https://schema.org/Event'" }} -
    +
      {{ range $agenda }}
    • {{ if eq $layout "agenda" }} diff --git a/layouts/partials/events/section/archives/years.html b/layouts/partials/events/section/archives/years.html index a502314fb..9bf2d489b 100644 --- a/layouts/partials/events/section/archives/years.html +++ b/layouts/partials/events/section/archives/years.html @@ -8,7 +8,7 @@

      {{ i18n "events.archives.by_year" }}

    • {{ .Title }} {{ $count := len (where .RegularPagesRecursive ".Params.is_month" nil) }} -

      {{ i18n "events.count" $count }}

      +

      {{ i18n "events.count" $count }}

    • {{ end }} {{ end }} diff --git a/layouts/partials/jobs/single/job-infos.html b/layouts/partials/jobs/single/job-infos.html index 2bab06497..92559b611 100644 --- a/layouts/partials/jobs/single/job-infos.html +++ b/layouts/partials/jobs/single/job-infos.html @@ -9,7 +9,6 @@ {{ end }} {{ end }} - {{ with .Params.dates }} {{ with .from }}
    • diff --git a/layouts/partials/locations/partials/location.html b/layouts/partials/locations/partials/location.html index b89c32d9e..6b6353cd2 100644 --- a/layouts/partials/locations/partials/location.html +++ b/layouts/partials/locations/partials/location.html @@ -18,7 +18,7 @@ {{ partial "commons/address" .postal_address }} {{ end }}
      - {{- if and .Params.summary $options.summary -}} + {{- if and .Params.summary $options.summary -}} {{ partial "GetRichSummary" ( dict "summary" .Params.summary "kind" "locations" diff --git a/layouts/partials/pages/partials/page.html b/layouts/partials/pages/partials/page.html index c5b12f92b..49dbc7c87 100644 --- a/layouts/partials/pages/partials/page.html +++ b/layouts/partials/pages/partials/page.html @@ -27,7 +27,7 @@ {{- partial "pages/partials/page/hook-after-title.html" . -}} - {{- with and $options.summary .Params.summary }} + {{- with and $options.summary .Params.summary }} {{ . | safeHTML }} {{ end -}} diff --git a/layouts/partials/papers/single/abstract.html b/layouts/partials/papers/single/abstract.html index ba7efe99c..059e9a693 100644 --- a/layouts/partials/papers/single/abstract.html +++ b/layouts/partials/papers/single/abstract.html @@ -1,7 +1,7 @@
      {{ with .Params.Abstract }}

      {{ i18n "papers.abstract" }}

      -

      {{ . | safeHTML }}

      +

      {{ . | safeHTML }}

      {{ end }} {{ if .Params.Pdf }}

      {{ i18n "papers.download" }}

      diff --git a/layouts/partials/papers/single/sidebar.html b/layouts/partials/papers/single/sidebar.html index 643654316..1abba0a7a 100644 --- a/layouts/partials/papers/single/sidebar.html +++ b/layouts/partials/papers/single/sidebar.html @@ -70,6 +70,4 @@ "context" . ) }}
      - - - + \ No newline at end of file diff --git a/layouts/partials/persons/section/persons-taxonomies.html b/layouts/partials/persons/section/persons-taxonomies.html index 786b612a7..7f17d0e9b 100644 --- a/layouts/partials/persons/section/persons-taxonomies.html +++ b/layouts/partials/persons/section/persons-taxonomies.html @@ -8,7 +8,7 @@ {{ end }} {{ end }} -{{ if $is_taxonomy_present }} +{{ if $is_taxonomy_present }}
        {{- range $taxonomies -}} {{- if index $has . -}} diff --git a/layouts/partials/posts/partials/post.html b/layouts/partials/posts/partials/post.html index 012c48a53..6b6bb6edf 100644 --- a/layouts/partials/posts/partials/post.html +++ b/layouts/partials/posts/partials/post.html @@ -46,7 +46,7 @@ {{ partial "posts/partials/post/federated.html" . }} - {{ if and $options.summary .Params.summary }} + {{ if and $options.summary .Params.summary }}
        {{ partial "GetRichSummary" ( dict "summary" .Params.summary diff --git a/layouts/partials/posts/single/signature.html b/layouts/partials/posts/single/signature.html index 1d2141133..7273e7ac5 100644 --- a/layouts/partials/posts/single/signature.html +++ b/layouts/partials/posts/single/signature.html @@ -7,7 +7,7 @@
      • {{ safeHTML .Params.summary }} From 662ac5baf37075331e35febd21fa448666bf1b8f Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 10 Feb 2026 16:33:24 +0100 Subject: [PATCH 04/42] message --- .github/workflows/analysis.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index b98fb5047..d1cfc3b8e 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -9,7 +9,6 @@ permissions: pull-requests: write jobs: - # Analyse des templates Hugo template-lint: name: Lint Hugo Templates runs-on: ubuntu-latest @@ -19,15 +18,15 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 - with: - python-version: '3.11' - name: Install djLint run: pip install djlint - name: Lint layouts - if: hashFiles('layouts/**/*.html') != '' run: | - echo "## 🎨 Template Analysis" >> $GITHUB_STEP_SUMMARY - djlint layouts/ --profile=golang --lint --quiet || true - echo "βœ… Layouts checked" >> $GITHUB_STEP_SUMMARY + echo "## 🎨 Template Analysis" >> message.txt + djlint layouts/ >> message.txt + + - uses: mshick/add-pr-comment@v2 + with: + message-path: message.txt \ No newline at end of file From 4f1b65b8f3f7361fa72562efc38c6a49b11cfe15 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 10 Feb 2026 16:34:32 +0100 Subject: [PATCH 05/42] python --- .github/workflows/analysis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 2c4c247a8..f99ad8090 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -17,7 +17,9 @@ jobs: uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 + with: + python-version: '3.13' - name: Install djLint run: pip install djlint @@ -27,6 +29,7 @@ jobs: echo "## 🎨 Template Analysis" >> message.txt djlint layouts/ >> message.txt - - uses: mshick/add-pr-comment@v2 + - name: Comment pull request + uses: mshick/add-pr-comment@v2 with: message-path: message.txt \ No newline at end of file From 51d3fec850db52a1e4048194b4666a127ccc5b7c Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 10 Feb 2026 16:42:25 +0100 Subject: [PATCH 06/42] test --- .github/workflows/analysis.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index f99ad8090..1c49792ac 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -1,8 +1,6 @@ name: Hugo Static Analysis on: push - # pull_request: - # types: [opened, reopened, synchronize] permissions: contents: read @@ -26,10 +24,11 @@ jobs: - name: Lint layouts run: | - echo "## 🎨 Template Analysis" >> message.txt - djlint layouts/ >> message.txt + echo "## 🎨 Template Analysis" >> $GITHUB_STEP_SUMMARY + djlint layouts/ || $GITHUB_STEP_SUMMARY - name: Comment pull request uses: mshick/add-pr-comment@v2 with: - message-path: message.txt \ No newline at end of file + message: | + $GITHUB_STEP_SUMMARY \ No newline at end of file From c0d67df6f09f0a539d2b236173f0908b0f549123 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 10 Feb 2026 16:48:47 +0100 Subject: [PATCH 07/42] test --- .github/workflows/analysis.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 1c49792ac..1b1354a19 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -2,9 +2,7 @@ name: Hugo Static Analysis on: push -permissions: - contents: read - pull-requests: write +permissions: write jobs: template-lint: @@ -24,11 +22,11 @@ jobs: - name: Lint layouts run: | - echo "## 🎨 Template Analysis" >> $GITHUB_STEP_SUMMARY - djlint layouts/ || $GITHUB_STEP_SUMMARY + echo "## 🎨 Template Analysis" > report.txt + djlint layouts/ > report.txt - name: Comment pull request uses: mshick/add-pr-comment@v2 with: - message: | - $GITHUB_STEP_SUMMARY \ No newline at end of file + message-path: | + report.txt \ No newline at end of file From a6eb820241ec67ad900a0e1b63d2bf8f6e28e30e Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 10 Feb 2026 16:49:39 +0100 Subject: [PATCH 08/42] test --- .github/workflows/analysis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 1b1354a19..f4a229ba6 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -2,7 +2,10 @@ name: Hugo Static Analysis on: push -permissions: write +permissions: + contents: read + pull-requests: write + checks: write jobs: template-lint: From 94411a1da4225ff84576762bee04d29503409e2a Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 10 Feb 2026 16:50:14 +0100 Subject: [PATCH 09/42] test --- .github/workflows/analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index f4a229ba6..a93d8bae4 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -26,7 +26,7 @@ jobs: - name: Lint layouts run: | echo "## 🎨 Template Analysis" > report.txt - djlint layouts/ > report.txt + djlint layouts/ > report.txt || true - name: Comment pull request uses: mshick/add-pr-comment@v2 From a320e8d4d0fbd0753e928e8698828bc4f6d17da1 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 10 Feb 2026 16:53:12 +0100 Subject: [PATCH 10/42] test --- .djlintrc | 2 +- .github/workflows/analysis.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.djlintrc b/.djlintrc index 9c80af64f..dc626faa6 100644 --- a/.djlintrc +++ b/.djlintrc @@ -7,7 +7,7 @@ "exclude": "node_modules,public,resources,static,.git", "ignore": "H006,H013,H021,H030,H031,T001,T002", "custom_blocks": "define,block,range,with,if,else,end", - "linter_output_format": "{filename}:{line} {code} {message} ({match})", + // "linter_output_format": "{filename}:{line} {code} {message} ({match})", "require_pragma": false, "preserve_blank_lines": true, "max_blank_lines": 2 diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index a93d8bae4..873079a95 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -25,8 +25,8 @@ jobs: - name: Lint layouts run: | - echo "## 🎨 Template Analysis" > report.txt - djlint layouts/ > report.txt || true + echo "## 🎨 Template Analysis" >> report.txt + djlint layouts/ >> report.txt || true - name: Comment pull request uses: mshick/add-pr-comment@v2 From d0028849d80e1bdd34566e47da16cc3c29078635 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 10 Feb 2026 16:55:21 +0100 Subject: [PATCH 11/42] test --- .djlintrc | 1 - .github/workflows/analysis.yml | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.djlintrc b/.djlintrc index dc626faa6..958f9fc62 100644 --- a/.djlintrc +++ b/.djlintrc @@ -7,7 +7,6 @@ "exclude": "node_modules,public,resources,static,.git", "ignore": "H006,H013,H021,H030,H031,T001,T002", "custom_blocks": "define,block,range,with,if,else,end", - // "linter_output_format": "{filename}:{line} {code} {message} ({match})", "require_pragma": false, "preserve_blank_lines": true, "max_blank_lines": 2 diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 873079a95..a431c8be0 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -25,8 +25,9 @@ jobs: - name: Lint layouts run: | - echo "## 🎨 Template Analysis" >> report.txt + echo "## 🎨 Template Analysis ```" >> report.txt djlint layouts/ >> report.txt || true + echo "```" >> report.txt - name: Comment pull request uses: mshick/add-pr-comment@v2 From 17d71a96106874aa7d10f506eff7bfca9bbc5139 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 10 Feb 2026 16:56:11 +0100 Subject: [PATCH 12/42] test --- .github/workflows/analysis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index a431c8be0..10dca6ac4 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -25,7 +25,8 @@ jobs: - name: Lint layouts run: | - echo "## 🎨 Template Analysis ```" >> report.txt + echo "## 🎨 Template Analysis" >> report.txt + echo "```" >> report.txt djlint layouts/ >> report.txt || true echo "```" >> report.txt From be9fe2c410aac7a1989071c0a270b67f361cb03e Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 10 Feb 2026 16:57:50 +0100 Subject: [PATCH 13/42] test --- .djlintrc | 1 + .github/workflows/analysis.yml | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.djlintrc b/.djlintrc index 958f9fc62..5bf67ec42 100644 --- a/.djlintrc +++ b/.djlintrc @@ -7,6 +7,7 @@ "exclude": "node_modules,public,resources,static,.git", "ignore": "H006,H013,H021,H030,H031,T001,T002", "custom_blocks": "define,block,range,with,if,else,end", + "linter_output_format": "`{filename}:{line} {code} {message} ({match})`", "require_pragma": false, "preserve_blank_lines": true, "max_blank_lines": 2 diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 10dca6ac4..873079a95 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -26,9 +26,7 @@ jobs: - name: Lint layouts run: | echo "## 🎨 Template Analysis" >> report.txt - echo "```" >> report.txt djlint layouts/ >> report.txt || true - echo "```" >> report.txt - name: Comment pull request uses: mshick/add-pr-comment@v2 From fa6df0128a66bda9ce984cb0b7f9d063325dfff5 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 10 Feb 2026 16:59:28 +0100 Subject: [PATCH 14/42] test --- .djlintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.djlintrc b/.djlintrc index 5bf67ec42..ad0ada2cf 100644 --- a/.djlintrc +++ b/.djlintrc @@ -7,7 +7,7 @@ "exclude": "node_modules,public,resources,static,.git", "ignore": "H006,H013,H021,H030,H031,T001,T002", "custom_blocks": "define,block,range,with,if,else,end", - "linter_output_format": "`{filename}:{line} {code} {message} ({match})`", + "linter_output_format": "### {filename}\nLine {line} {code} {message} \n```html{match}```", "require_pragma": false, "preserve_blank_lines": true, "max_blank_lines": 2 From 5518f92dcfa52cc08d57cfa6f3f7b3f262990f4e Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 10 Feb 2026 17:00:35 +0100 Subject: [PATCH 15/42] test --- .djlintrc | 2 +- .github/workflows/analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.djlintrc b/.djlintrc index ad0ada2cf..c2f1625f9 100644 --- a/.djlintrc +++ b/.djlintrc @@ -7,7 +7,7 @@ "exclude": "node_modules,public,resources,static,.git", "ignore": "H006,H013,H021,H030,H031,T001,T002", "custom_blocks": "define,block,range,with,if,else,end", - "linter_output_format": "### {filename}\nLine {line} {code} {message} \n```html{match}```", + "linter_output_format": "### {filename}\nLine {line} {code} {message} \n```html\n{match}\n```", "require_pragma": false, "preserve_blank_lines": true, "max_blank_lines": 2 diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 873079a95..62ba9d362 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -25,7 +25,7 @@ jobs: - name: Lint layouts run: | - echo "## 🎨 Template Analysis" >> report.txt + echo "## Template Analysis" >> report.txt djlint layouts/ >> report.txt || true - name: Comment pull request From 307e3ca40fcb03fe6b24134969ba786f27e7ad1a Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 10 Feb 2026 17:01:43 +0100 Subject: [PATCH 16/42] test --- .djlintrc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.djlintrc b/.djlintrc index c2f1625f9..8c91c5ee7 100644 --- a/.djlintrc +++ b/.djlintrc @@ -1,14 +1,14 @@ { "profile": "golang", - "indent": 2, - "max_line_length": 120, - "format_css": true, - "format_js": true, - "exclude": "node_modules,public,resources,static,.git", - "ignore": "H006,H013,H021,H030,H031,T001,T002", - "custom_blocks": "define,block,range,with,if,else,end", - "linter_output_format": "### {filename}\nLine {line} {code} {message} \n```html\n{match}\n```", - "require_pragma": false, - "preserve_blank_lines": true, - "max_blank_lines": 2 + // "indent": 2, + // "max_line_length": 120, + // "format_css": true, + // "format_js": true, + // "exclude": "node_modules,public,resources,static,.git", + // "ignore": "H006,H013,H021,H030,H031,T001,T002", + // "custom_blocks": "define,block,range,with,if,else,end", + "linter_output_format": "### {message}\n{filename}, line {line}, code {code} \n```html\n{match}\n```", + // "require_pragma": false, + // "preserve_blank_lines": true, + // "max_blank_lines": 2 } From c092607fcddb4e6321ce4fe1f1e7b231dac01994 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 10 Feb 2026 17:05:22 +0100 Subject: [PATCH 17/42] better --- .djlintrc | 20 +++++++++---------- ...AddCreditMention => AddCreditMention.html} | 0 .../{AnchorAttribute => AnchorAttribute.html} | 0 ...FilterIframeLazy => FilterIframeLazy.html} | 0 ...erPublications => FilterPublications.html} | 0 .../{GetBlockClass => GetBlockClass.html} | 0 .../{GetBodyclass => GetBodyclass.html} | 0 ...tCategoriesSlug => GetCategoriesSlug.html} | 0 .../{GetDayAnchor => GetDayAnchor.html} | 0 ...GetExtensionFile => GetExtensionFile.html} | 0 ...igureAriaLabel => GetFigureAriaLabel.html} | 0 ...WithSize => GetFileExtensionWithSize.html} | 0 .../{GetHeadTitle => GetHeadTitle.html} | 0 .../{GetHeadingTag => GetHeadingTag.html} | 0 .../{GetHumanSize => GetHumanSize.html} | 0 ...mageDimensions => GetImageDimensions.html} | 0 ...tImageDirection => GetImageDirection.html} | 0 .../{GetImageUrl => GetImageUrl.html} | 0 ...tImageUrlKeycdn => GetImageUrlKeycdn.html} | 0 ...GetImageUrlOsuny => GetImageUrlOsuny.html} | 0 ...outAndOptions => GetLayoutAndOptions.html} | 0 .../{GetLightboxUrl => GetLightboxUrl.html} | 0 .../partials/{GetLogoUrl => GetLogoUrl.html} | 0 .../{GetMainClass => GetMainClass.html} | 0 ...ttributes => GetMainSearchAttributes.html} | 0 layouts/partials/{GetMedia => GetMedia.html} | 0 layouts/partials/{GetMenu => GetMenu.html} | 0 .../{GetMenuSummary => GetMenuSummary.html} | 0 .../{GetMonthFromNow => GetMonthFromNow.html} | 0 ...PathSlice => GetObjectsFromPathSlice.html} | 0 ...omObjects => GetPathSliceFromObjects.html} | 0 .../{GetPermalink => GetPermalink.html} | 0 .../{GetRichSummary => GetRichSummary.html} | 0 ...thDefault => GetSiteParamWithDefault.html} | 0 ...ummaryPosition => GetSummaryPosition.html} | 0 ...iesPosition => GetTaxonomiesPosition.html} | 0 ...Taxonomies => GetTermsFromTaxonomies.html} | 0 .../{GetTextFromHTML => GetTextFromHTML.html} | 0 ...GetTruncatedText => GetTruncatedText.html} | 0 ...tion => HasAdministrativeInformation.html} | 0 .../{IsFirstPage => IsFirstPage.html} | 0 .../{PrepareHTML => PrepareHTML.html} | 0 .../{PrepareText => PrepareText.html} | 0 .../{RemoveSrOnlyTag => RemoveSrOnlyTag.html} | 0 ...apPresent => isInteractiveMapPresent.html} | 0 45 files changed, 10 insertions(+), 10 deletions(-) rename layouts/partials/{AddCreditMention => AddCreditMention.html} (100%) rename layouts/partials/{AnchorAttribute => AnchorAttribute.html} (100%) rename layouts/partials/{FilterIframeLazy => FilterIframeLazy.html} (100%) rename layouts/partials/{FilterPublications => FilterPublications.html} (100%) rename layouts/partials/{GetBlockClass => GetBlockClass.html} (100%) rename layouts/partials/{GetBodyclass => GetBodyclass.html} (100%) rename layouts/partials/{GetCategoriesSlug => GetCategoriesSlug.html} (100%) rename layouts/partials/{GetDayAnchor => GetDayAnchor.html} (100%) rename layouts/partials/{GetExtensionFile => GetExtensionFile.html} (100%) rename layouts/partials/{GetFigureAriaLabel => GetFigureAriaLabel.html} (100%) rename layouts/partials/{GetFileExtensionWithSize => GetFileExtensionWithSize.html} (100%) rename layouts/partials/{GetHeadTitle => GetHeadTitle.html} (100%) rename layouts/partials/{GetHeadingTag => GetHeadingTag.html} (100%) rename layouts/partials/{GetHumanSize => GetHumanSize.html} (100%) rename layouts/partials/{GetImageDimensions => GetImageDimensions.html} (100%) rename layouts/partials/{GetImageDirection => GetImageDirection.html} (100%) rename layouts/partials/{GetImageUrl => GetImageUrl.html} (100%) rename layouts/partials/{GetImageUrlKeycdn => GetImageUrlKeycdn.html} (100%) rename layouts/partials/{GetImageUrlOsuny => GetImageUrlOsuny.html} (100%) rename layouts/partials/{GetLayoutAndOptions => GetLayoutAndOptions.html} (100%) rename layouts/partials/{GetLightboxUrl => GetLightboxUrl.html} (100%) rename layouts/partials/{GetLogoUrl => GetLogoUrl.html} (100%) rename layouts/partials/{GetMainClass => GetMainClass.html} (100%) rename layouts/partials/{GetMainSearchAttributes => GetMainSearchAttributes.html} (100%) rename layouts/partials/{GetMedia => GetMedia.html} (100%) rename layouts/partials/{GetMenu => GetMenu.html} (100%) rename layouts/partials/{GetMenuSummary => GetMenuSummary.html} (100%) rename layouts/partials/{GetMonthFromNow => GetMonthFromNow.html} (100%) rename layouts/partials/{GetObjectsFromPathSlice => GetObjectsFromPathSlice.html} (100%) rename layouts/partials/{GetPathSliceFromObjects => GetPathSliceFromObjects.html} (100%) rename layouts/partials/{GetPermalink => GetPermalink.html} (100%) rename layouts/partials/{GetRichSummary => GetRichSummary.html} (100%) rename layouts/partials/{GetSiteParamWithDefault => GetSiteParamWithDefault.html} (100%) rename layouts/partials/{GetSummaryPosition => GetSummaryPosition.html} (100%) rename layouts/partials/{GetTaxonomiesPosition => GetTaxonomiesPosition.html} (100%) rename layouts/partials/{GetTermsFromTaxonomies => GetTermsFromTaxonomies.html} (100%) rename layouts/partials/{GetTextFromHTML => GetTextFromHTML.html} (100%) rename layouts/partials/{GetTruncatedText => GetTruncatedText.html} (100%) rename layouts/partials/{HasAdministrativeInformation => HasAdministrativeInformation.html} (100%) rename layouts/partials/{IsFirstPage => IsFirstPage.html} (100%) rename layouts/partials/{PrepareHTML => PrepareHTML.html} (100%) rename layouts/partials/{PrepareText => PrepareText.html} (100%) rename layouts/partials/{RemoveSrOnlyTag => RemoveSrOnlyTag.html} (100%) rename layouts/partials/{isInteractiveMapPresent => isInteractiveMapPresent.html} (100%) diff --git a/.djlintrc b/.djlintrc index 8c91c5ee7..b55aa0926 100644 --- a/.djlintrc +++ b/.djlintrc @@ -1,14 +1,14 @@ { "profile": "golang", - // "indent": 2, - // "max_line_length": 120, - // "format_css": true, - // "format_js": true, - // "exclude": "node_modules,public,resources,static,.git", - // "ignore": "H006,H013,H021,H030,H031,T001,T002", - // "custom_blocks": "define,block,range,with,if,else,end", + "indent": 2, + "max_line_length": 120, + "format_css": true, + "format_js": true, + "exclude": "node_modules,public,resources,static,.git", + "ignore": "H006,H013,H021,H030,H031,T001,T002", + "custom_blocks": "define,block,range,with,if,else,end", "linter_output_format": "### {message}\n{filename}, line {line}, code {code} \n```html\n{match}\n```", - // "require_pragma": false, - // "preserve_blank_lines": true, - // "max_blank_lines": 2 + "require_pragma": false, + "preserve_blank_lines": true, + "max_blank_lines": 2 } diff --git a/layouts/partials/AddCreditMention b/layouts/partials/AddCreditMention.html similarity index 100% rename from layouts/partials/AddCreditMention rename to layouts/partials/AddCreditMention.html diff --git a/layouts/partials/AnchorAttribute b/layouts/partials/AnchorAttribute.html similarity index 100% rename from layouts/partials/AnchorAttribute rename to layouts/partials/AnchorAttribute.html diff --git a/layouts/partials/FilterIframeLazy b/layouts/partials/FilterIframeLazy.html similarity index 100% rename from layouts/partials/FilterIframeLazy rename to layouts/partials/FilterIframeLazy.html diff --git a/layouts/partials/FilterPublications b/layouts/partials/FilterPublications.html similarity index 100% rename from layouts/partials/FilterPublications rename to layouts/partials/FilterPublications.html diff --git a/layouts/partials/GetBlockClass b/layouts/partials/GetBlockClass.html similarity index 100% rename from layouts/partials/GetBlockClass rename to layouts/partials/GetBlockClass.html diff --git a/layouts/partials/GetBodyclass b/layouts/partials/GetBodyclass.html similarity index 100% rename from layouts/partials/GetBodyclass rename to layouts/partials/GetBodyclass.html diff --git a/layouts/partials/GetCategoriesSlug b/layouts/partials/GetCategoriesSlug.html similarity index 100% rename from layouts/partials/GetCategoriesSlug rename to layouts/partials/GetCategoriesSlug.html diff --git a/layouts/partials/GetDayAnchor b/layouts/partials/GetDayAnchor.html similarity index 100% rename from layouts/partials/GetDayAnchor rename to layouts/partials/GetDayAnchor.html diff --git a/layouts/partials/GetExtensionFile b/layouts/partials/GetExtensionFile.html similarity index 100% rename from layouts/partials/GetExtensionFile rename to layouts/partials/GetExtensionFile.html diff --git a/layouts/partials/GetFigureAriaLabel b/layouts/partials/GetFigureAriaLabel.html similarity index 100% rename from layouts/partials/GetFigureAriaLabel rename to layouts/partials/GetFigureAriaLabel.html diff --git a/layouts/partials/GetFileExtensionWithSize b/layouts/partials/GetFileExtensionWithSize.html similarity index 100% rename from layouts/partials/GetFileExtensionWithSize rename to layouts/partials/GetFileExtensionWithSize.html diff --git a/layouts/partials/GetHeadTitle b/layouts/partials/GetHeadTitle.html similarity index 100% rename from layouts/partials/GetHeadTitle rename to layouts/partials/GetHeadTitle.html diff --git a/layouts/partials/GetHeadingTag b/layouts/partials/GetHeadingTag.html similarity index 100% rename from layouts/partials/GetHeadingTag rename to layouts/partials/GetHeadingTag.html diff --git a/layouts/partials/GetHumanSize b/layouts/partials/GetHumanSize.html similarity index 100% rename from layouts/partials/GetHumanSize rename to layouts/partials/GetHumanSize.html diff --git a/layouts/partials/GetImageDimensions b/layouts/partials/GetImageDimensions.html similarity index 100% rename from layouts/partials/GetImageDimensions rename to layouts/partials/GetImageDimensions.html diff --git a/layouts/partials/GetImageDirection b/layouts/partials/GetImageDirection.html similarity index 100% rename from layouts/partials/GetImageDirection rename to layouts/partials/GetImageDirection.html diff --git a/layouts/partials/GetImageUrl b/layouts/partials/GetImageUrl.html similarity index 100% rename from layouts/partials/GetImageUrl rename to layouts/partials/GetImageUrl.html diff --git a/layouts/partials/GetImageUrlKeycdn b/layouts/partials/GetImageUrlKeycdn.html similarity index 100% rename from layouts/partials/GetImageUrlKeycdn rename to layouts/partials/GetImageUrlKeycdn.html diff --git a/layouts/partials/GetImageUrlOsuny b/layouts/partials/GetImageUrlOsuny.html similarity index 100% rename from layouts/partials/GetImageUrlOsuny rename to layouts/partials/GetImageUrlOsuny.html diff --git a/layouts/partials/GetLayoutAndOptions b/layouts/partials/GetLayoutAndOptions.html similarity index 100% rename from layouts/partials/GetLayoutAndOptions rename to layouts/partials/GetLayoutAndOptions.html diff --git a/layouts/partials/GetLightboxUrl b/layouts/partials/GetLightboxUrl.html similarity index 100% rename from layouts/partials/GetLightboxUrl rename to layouts/partials/GetLightboxUrl.html diff --git a/layouts/partials/GetLogoUrl b/layouts/partials/GetLogoUrl.html similarity index 100% rename from layouts/partials/GetLogoUrl rename to layouts/partials/GetLogoUrl.html diff --git a/layouts/partials/GetMainClass b/layouts/partials/GetMainClass.html similarity index 100% rename from layouts/partials/GetMainClass rename to layouts/partials/GetMainClass.html diff --git a/layouts/partials/GetMainSearchAttributes b/layouts/partials/GetMainSearchAttributes.html similarity index 100% rename from layouts/partials/GetMainSearchAttributes rename to layouts/partials/GetMainSearchAttributes.html diff --git a/layouts/partials/GetMedia b/layouts/partials/GetMedia.html similarity index 100% rename from layouts/partials/GetMedia rename to layouts/partials/GetMedia.html diff --git a/layouts/partials/GetMenu b/layouts/partials/GetMenu.html similarity index 100% rename from layouts/partials/GetMenu rename to layouts/partials/GetMenu.html diff --git a/layouts/partials/GetMenuSummary b/layouts/partials/GetMenuSummary.html similarity index 100% rename from layouts/partials/GetMenuSummary rename to layouts/partials/GetMenuSummary.html diff --git a/layouts/partials/GetMonthFromNow b/layouts/partials/GetMonthFromNow.html similarity index 100% rename from layouts/partials/GetMonthFromNow rename to layouts/partials/GetMonthFromNow.html diff --git a/layouts/partials/GetObjectsFromPathSlice b/layouts/partials/GetObjectsFromPathSlice.html similarity index 100% rename from layouts/partials/GetObjectsFromPathSlice rename to layouts/partials/GetObjectsFromPathSlice.html diff --git a/layouts/partials/GetPathSliceFromObjects b/layouts/partials/GetPathSliceFromObjects.html similarity index 100% rename from layouts/partials/GetPathSliceFromObjects rename to layouts/partials/GetPathSliceFromObjects.html diff --git a/layouts/partials/GetPermalink b/layouts/partials/GetPermalink.html similarity index 100% rename from layouts/partials/GetPermalink rename to layouts/partials/GetPermalink.html diff --git a/layouts/partials/GetRichSummary b/layouts/partials/GetRichSummary.html similarity index 100% rename from layouts/partials/GetRichSummary rename to layouts/partials/GetRichSummary.html diff --git a/layouts/partials/GetSiteParamWithDefault b/layouts/partials/GetSiteParamWithDefault.html similarity index 100% rename from layouts/partials/GetSiteParamWithDefault rename to layouts/partials/GetSiteParamWithDefault.html diff --git a/layouts/partials/GetSummaryPosition b/layouts/partials/GetSummaryPosition.html similarity index 100% rename from layouts/partials/GetSummaryPosition rename to layouts/partials/GetSummaryPosition.html diff --git a/layouts/partials/GetTaxonomiesPosition b/layouts/partials/GetTaxonomiesPosition.html similarity index 100% rename from layouts/partials/GetTaxonomiesPosition rename to layouts/partials/GetTaxonomiesPosition.html diff --git a/layouts/partials/GetTermsFromTaxonomies b/layouts/partials/GetTermsFromTaxonomies.html similarity index 100% rename from layouts/partials/GetTermsFromTaxonomies rename to layouts/partials/GetTermsFromTaxonomies.html diff --git a/layouts/partials/GetTextFromHTML b/layouts/partials/GetTextFromHTML.html similarity index 100% rename from layouts/partials/GetTextFromHTML rename to layouts/partials/GetTextFromHTML.html diff --git a/layouts/partials/GetTruncatedText b/layouts/partials/GetTruncatedText.html similarity index 100% rename from layouts/partials/GetTruncatedText rename to layouts/partials/GetTruncatedText.html diff --git a/layouts/partials/HasAdministrativeInformation b/layouts/partials/HasAdministrativeInformation.html similarity index 100% rename from layouts/partials/HasAdministrativeInformation rename to layouts/partials/HasAdministrativeInformation.html diff --git a/layouts/partials/IsFirstPage b/layouts/partials/IsFirstPage.html similarity index 100% rename from layouts/partials/IsFirstPage rename to layouts/partials/IsFirstPage.html diff --git a/layouts/partials/PrepareHTML b/layouts/partials/PrepareHTML.html similarity index 100% rename from layouts/partials/PrepareHTML rename to layouts/partials/PrepareHTML.html diff --git a/layouts/partials/PrepareText b/layouts/partials/PrepareText.html similarity index 100% rename from layouts/partials/PrepareText rename to layouts/partials/PrepareText.html diff --git a/layouts/partials/RemoveSrOnlyTag b/layouts/partials/RemoveSrOnlyTag.html similarity index 100% rename from layouts/partials/RemoveSrOnlyTag rename to layouts/partials/RemoveSrOnlyTag.html diff --git a/layouts/partials/isInteractiveMapPresent b/layouts/partials/isInteractiveMapPresent.html similarity index 100% rename from layouts/partials/isInteractiveMapPresent rename to layouts/partials/isInteractiveMapPresent.html From cb46c05d7849eed50adf9ea3c7dcefef5c43faf8 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 10 Feb 2026 17:32:35 +0100 Subject: [PATCH 18/42] ignore --- .djlintrc | 2 +- .github/workflows/analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.djlintrc b/.djlintrc index b55aa0926..6e3911be5 100644 --- a/.djlintrc +++ b/.djlintrc @@ -5,7 +5,7 @@ "format_css": true, "format_js": true, "exclude": "node_modules,public,resources,static,.git", - "ignore": "H006,H013,H021,H030,H031,T001,T002", + "ignore": "H006,H013,H016,H021,H030,H031,T001,T002", "custom_blocks": "define,block,range,with,if,else,end", "linter_output_format": "### {message}\n{filename}, line {line}, code {code} \n```html\n{match}\n```", "require_pragma": false, diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 62ba9d362..528869f23 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -25,7 +25,7 @@ jobs: - name: Lint layouts run: | - echo "## Template Analysis" >> report.txt + echo "## djLint" >> report.txt djlint layouts/ >> report.txt || true - name: Comment pull request From 57a6fe654b391db6825c0f79d518c862e3c935a5 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 10 Feb 2026 19:20:28 +0100 Subject: [PATCH 19/42] complexity --- .github/workflows/analysis.yml | 10 ++++++++ bin/analyze.rb | 44 ++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 bin/analyze.rb diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 528869f23..a6e2f3a93 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -27,6 +27,16 @@ jobs: run: | echo "## djLint" >> report.txt djlint layouts/ >> report.txt || true + + - name: Install Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 'latest' + + - name: Complexity + run: | + echo "## Complexity" >> report.txt + ruby bin/analyze.rb >> report.txt || true - name: Comment pull request uses: mshick/add-pr-comment@v2 diff --git a/bin/analyze.rb b/bin/analyze.rb new file mode 100644 index 000000000..b5eaa4eef --- /dev/null +++ b/bin/analyze.rb @@ -0,0 +1,44 @@ +KEYWORDS = [ + 'if', + 'else', + 'for', + 'range', + 'with', +].freeze + +DANGER = 10 +WARNING = 5 + +files = [] + +def occurences(needle, haystack) + return 0 if haystack.empty? + haystack.split(needle).count - 1 +end + +def compute_complexity(data) + complexity = 1 + KEYWORDS.each do |keyword| + complexity += occurences("#{keyword} ", data) + end + complexity +end + +Dir.glob('./layouts/**/*').each do |path| + next if File.directory?(path) + data = File.read(path) + complexity = compute_complexity(data) + files << { + path: path, + complexity: complexity + } +end + +files.sort_by! { |hash| hash[:complexity] }.reverse! + +puts "| File | Complexity | State |" +files.each do |hash| + next if hash[:complexity] < WARNING + icon = hash[:complexity] > DANGER ? '❌' : '⚠️' + puts "| #{icon} | #{hash[:complexity]} | #{hash[:path]} |" +end \ No newline at end of file From a18f47c4db992539e97c7a813db81936668d2402 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 10 Feb 2026 19:22:06 +0100 Subject: [PATCH 20/42] ruby --- .github/workflows/analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index a6e2f3a93..2aea72a9e 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -31,7 +31,7 @@ jobs: - name: Install Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 'latest' + ruby-version: '3.4.1' - name: Complexity run: | From 4ea297e44f7f9c2bd4b17f1d13f569e00e54d69f Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 10 Feb 2026 19:23:25 +0100 Subject: [PATCH 21/42] table --- bin/analyze.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/analyze.rb b/bin/analyze.rb index b5eaa4eef..719f60825 100644 --- a/bin/analyze.rb +++ b/bin/analyze.rb @@ -37,6 +37,7 @@ def compute_complexity(data) files.sort_by! { |hash| hash[:complexity] }.reverse! puts "| File | Complexity | State |" +puts "|---|---|---|" files.each do |hash| next if hash[:complexity] < WARNING icon = hash[:complexity] > DANGER ? '❌' : '⚠️' From 30da7e061dfb0613373751aca7f78ea0c793fa64 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Wed, 11 Feb 2026 09:01:46 +0100 Subject: [PATCH 22/42] test --- bin/analyze.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/analyze.rb b/bin/analyze.rb index 719f60825..b5e47eba9 100644 --- a/bin/analyze.rb +++ b/bin/analyze.rb @@ -36,10 +36,12 @@ def compute_complexity(data) files.sort_by! { |hash| hash[:complexity] }.reverse! -puts "| File | Complexity | State |" +puts "| State | Complexity | File |" puts "|---|---|---|" files.each do |hash| next if hash[:complexity] < WARNING icon = hash[:complexity] > DANGER ? '❌' : '⚠️' - puts "| #{icon} | #{hash[:complexity]} | #{hash[:path]} |" + path = hash[:path].gsub('./layouts/', '') + complexity = hash[:complexity] + puts "| #{icon} | #{complexity} | #{path} |" end \ No newline at end of file From b58a95cd4ebbd2558cc48b5040c185fca988a628 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Wed, 11 Feb 2026 09:41:37 +0100 Subject: [PATCH 23/42] test --- .github/workflows/analysis.yml | 1 - bin/analyze.rb | 74 ++++++++++++++++++++++++++++------ 2 files changed, 62 insertions(+), 13 deletions(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 2aea72a9e..5471f79a6 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -35,7 +35,6 @@ jobs: - name: Complexity run: | - echo "## Complexity" >> report.txt ruby bin/analyze.rb >> report.txt || true - name: Comment pull request diff --git a/bin/analyze.rb b/bin/analyze.rb index b5e47eba9..e155bc30b 100644 --- a/bin/analyze.rb +++ b/bin/analyze.rb @@ -9,6 +9,7 @@ DANGER = 10 WARNING = 5 +paths = Dir.glob('./layouts/**/*').reject { |path| File.directory?(path) } files = [] def occurences(needle, haystack) @@ -16,32 +17,81 @@ def occurences(needle, haystack) haystack.split(needle).count - 1 end +def occurrences_in_files(needle, files) + occurences = 0 + files.each do |file| + occurences += occurences(needle, file[:data]) + end + occurences +end + def compute_complexity(data) complexity = 1 KEYWORDS.each do |keyword| complexity += occurences("#{keyword} ", data) end - complexity + icon = 'βœ…' + if complexity > DANGER + icon = '❌' + elsif complexity > WARNING + icon = '⚠️' + end + { + score: complexity, + icon: icon, + problem: complexity > WARNING + } +end + +def count_calls(path, files) + root = './layouts/partials/' + if path.include?(root) + fragment = path.gsub(root, '').gsub('.html', '') + call = "partial \"#{fragment}" + count = occurrences_in_files(call, files) + { + fragment: fragment, + count: count + } + else + nil + end end -Dir.glob('./layouts/**/*').each do |path| +# Load content +paths.each do |path| next if File.directory?(path) data = File.read(path) - complexity = compute_complexity(data) files << { path: path, - complexity: complexity + short_path: path.gsub('./layouts/', ''), + data: data } end -files.sort_by! { |hash| hash[:complexity] }.reverse! +# Analyze +files.each do |file| + complexity = compute_complexity(file[:data]) + file[:complexity] = complexity + file[:calls] = count_calls(file[:path], files) +end +puts "## Complexity" puts "| State | Complexity | File |" puts "|---|---|---|" -files.each do |hash| - next if hash[:complexity] < WARNING - icon = hash[:complexity] > DANGER ? '❌' : '⚠️' - path = hash[:path].gsub('./layouts/', '') - complexity = hash[:complexity] - puts "| #{icon} | #{complexity} | #{path} |" -end \ No newline at end of file +files.sort_by{ |hash| hash[:complexity][:score] } + .reverse + .each do |file| + next unless file[:complexity][:problem] + puts "| #{file[:complexity][:icon]} | #{file[:complexity][:score]} | #{file[:short_path]} |" +end + +puts "## Partials calls" +puts "| Calls | Partial |" +puts "|---|---|" +files.reject { |hash| hash[:calls].nil? } + .sort_by { |hash| hash[:calls][:count] } + .reverse + .each do |file| + puts "| #{file[:calls][:count]} | #{file[:calls][:fragment]} |" +end From 7714de67ab697da73d3d8c4cf5abce2992ab8f28 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Wed, 11 Feb 2026 16:18:13 +0100 Subject: [PATCH 24/42] refactor --- .github/workflows/analysis.yml | 2 +- bin/analyze.rb | 97 ---------------------- bin/hugo-analyzer.rb | 2 + bin/hugo-analyzer/analyzer.rb | 39 +++++++++ bin/hugo-analyzer/engines/base.rb | 38 +++++++++ bin/hugo-analyzer/engines/complexity.rb | 59 +++++++++++++ bin/hugo-analyzer/engines/partial_calls.rb | 42 ++++++++++ bin/hugo-analyzer/file.rb | 22 +++++ bin/hugo-analyzer/utils.rb | 17 ++++ 9 files changed, 220 insertions(+), 98 deletions(-) delete mode 100644 bin/analyze.rb create mode 100644 bin/hugo-analyzer.rb create mode 100644 bin/hugo-analyzer/analyzer.rb create mode 100644 bin/hugo-analyzer/engines/base.rb create mode 100644 bin/hugo-analyzer/engines/complexity.rb create mode 100644 bin/hugo-analyzer/engines/partial_calls.rb create mode 100644 bin/hugo-analyzer/file.rb create mode 100644 bin/hugo-analyzer/utils.rb diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 5471f79a6..e3b553ca0 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -35,7 +35,7 @@ jobs: - name: Complexity run: | - ruby bin/analyze.rb >> report.txt || true + ruby bin/hugo-analyzer.rb >> report.txt || true - name: Comment pull request uses: mshick/add-pr-comment@v2 diff --git a/bin/analyze.rb b/bin/analyze.rb deleted file mode 100644 index e155bc30b..000000000 --- a/bin/analyze.rb +++ /dev/null @@ -1,97 +0,0 @@ -KEYWORDS = [ - 'if', - 'else', - 'for', - 'range', - 'with', -].freeze - -DANGER = 10 -WARNING = 5 - -paths = Dir.glob('./layouts/**/*').reject { |path| File.directory?(path) } -files = [] - -def occurences(needle, haystack) - return 0 if haystack.empty? - haystack.split(needle).count - 1 -end - -def occurrences_in_files(needle, files) - occurences = 0 - files.each do |file| - occurences += occurences(needle, file[:data]) - end - occurences -end - -def compute_complexity(data) - complexity = 1 - KEYWORDS.each do |keyword| - complexity += occurences("#{keyword} ", data) - end - icon = 'βœ…' - if complexity > DANGER - icon = '❌' - elsif complexity > WARNING - icon = '⚠️' - end - { - score: complexity, - icon: icon, - problem: complexity > WARNING - } -end - -def count_calls(path, files) - root = './layouts/partials/' - if path.include?(root) - fragment = path.gsub(root, '').gsub('.html', '') - call = "partial \"#{fragment}" - count = occurrences_in_files(call, files) - { - fragment: fragment, - count: count - } - else - nil - end -end - -# Load content -paths.each do |path| - next if File.directory?(path) - data = File.read(path) - files << { - path: path, - short_path: path.gsub('./layouts/', ''), - data: data - } -end - -# Analyze -files.each do |file| - complexity = compute_complexity(file[:data]) - file[:complexity] = complexity - file[:calls] = count_calls(file[:path], files) -end - -puts "## Complexity" -puts "| State | Complexity | File |" -puts "|---|---|---|" -files.sort_by{ |hash| hash[:complexity][:score] } - .reverse - .each do |file| - next unless file[:complexity][:problem] - puts "| #{file[:complexity][:icon]} | #{file[:complexity][:score]} | #{file[:short_path]} |" -end - -puts "## Partials calls" -puts "| Calls | Partial |" -puts "|---|---|" -files.reject { |hash| hash[:calls].nil? } - .sort_by { |hash| hash[:calls][:count] } - .reverse - .each do |file| - puts "| #{file[:calls][:count]} | #{file[:calls][:fragment]} |" -end diff --git a/bin/hugo-analyzer.rb b/bin/hugo-analyzer.rb new file mode 100644 index 000000000..9fc5ba5e8 --- /dev/null +++ b/bin/hugo-analyzer.rb @@ -0,0 +1,2 @@ +require_relative 'hugo-analyzer/analyzer' +puts HugoAnalyzer::Analyzer.run diff --git a/bin/hugo-analyzer/analyzer.rb b/bin/hugo-analyzer/analyzer.rb new file mode 100644 index 000000000..a64a5e496 --- /dev/null +++ b/bin/hugo-analyzer/analyzer.rb @@ -0,0 +1,39 @@ +require_relative 'engines/base' +require_relative 'engines/complexity' +require_relative 'engines/partial_calls' +require_relative 'file' +require_relative 'utils' + +module HugoAnalyzer + class Analyzer + + LAYOUTS = './layouts/**/*' + + def self.run + new.to_s + end + + def to_s + message = '' + message += engine_complexity.to_s + message += engine_partial_calls.to_s + message + end + + def engine_complexity + @engine_complexity ||= Engines::Complexity.new(self) + end + + def engine_partial_calls + @engine_partial_calls ||= Engines::PartialCalls.new(self) + end + + def paths + @paths ||= Dir.glob(LAYOUTS) + end + + def files + @files ||= paths.map { |path| HugoAnalyzer::File.new(path) } + end + end +end diff --git a/bin/hugo-analyzer/engines/base.rb b/bin/hugo-analyzer/engines/base.rb new file mode 100644 index 000000000..a8e473209 --- /dev/null +++ b/bin/hugo-analyzer/engines/base.rb @@ -0,0 +1,38 @@ +module HugoAnalyzer + module Engines + class Base + attr_reader :engine + + def initialize(engine) + @engine = engine + end + + def analyzed_files + unless @analyzed_files + @analyzed_files = [] + engine.files.each do |file| + next unless should_analyze?(file) + @analyzed_files << analyze(file) + end + sort! + end + @analyzed_files + end + + def to_s + end + + protected + + def should_analyze?(file) + true + end + + def analyze(file) + end + + def sort! + end + end + end +end diff --git a/bin/hugo-analyzer/engines/complexity.rb b/bin/hugo-analyzer/engines/complexity.rb new file mode 100644 index 000000000..9c333c139 --- /dev/null +++ b/bin/hugo-analyzer/engines/complexity.rb @@ -0,0 +1,59 @@ +module HugoAnalyzer + module Engines + class Complexity < Base + + KEYWORDS = [ + 'if', + 'else', + 'for', + 'range', + 'with', + ].freeze + + DANGER = 10 + WARNING = 5 + + def to_s + message = "## Complexity\n" + message += "| State | Complexity | File |\n" + message += "|---|---|---|" + analyzed_files.each do |file| + complexity = file.json[:complexity] + next unless complexity[:problem] + message += "| #{complexity[:icon]} | #{complexity[:score]} | #{file.short_path} |\n" + end + message + end + + protected + + def should_analyze?(file) + !file.directory? + end + + def sort! + @analyzed_files.sort_by!{ |file| file.json[:complexity][:score] }.reverse! + end + + def analyze(file) + score = 1 + KEYWORDS.each do |keyword| + score += HugoAnalyzer::Utils.occurences("#{keyword} ", file.data) + end + problem = score > WARNING + icon = 'βœ…' + if score > DANGER + icon = '❌' + elsif score > WARNING + icon = '⚠️' + end + file.json[:complexity] = { + score: score, + icon: icon, + problem: problem + } + file + end + end + end +end diff --git a/bin/hugo-analyzer/engines/partial_calls.rb b/bin/hugo-analyzer/engines/partial_calls.rb new file mode 100644 index 000000000..0f3ca3f01 --- /dev/null +++ b/bin/hugo-analyzer/engines/partial_calls.rb @@ -0,0 +1,42 @@ +module HugoAnalyzer + module Engines + class PartialCalls < Base + + ROOT = './layouts/partials/' + + def to_s + message = "## Partials calls\n" + message += "| Calls | Partial |\n" + message += "|---|---|\n" + analyzed_files.each do |file| + calls = file.json[:calls] + message += "| #{calls[:count]} | #{calls[:fragment]} |\n" + end + message + end + + protected + + def should_analyze?(file) + !file.directory? && + file.path.include?(ROOT) + end + + def analyze(file) + fragment = file.path.gsub(ROOT, '').gsub('.html', '') + call = "partial \"#{fragment}" + count = HugoAnalyzer::Utils.occurrences_in_files(call, engine.files) + file.json[:calls] = { + fragment: fragment, + count: count + } + file + end + + def sort! + @analyzed_files.sort_by! { |file| file.json[:calls][:count] } + .reverse! + end + end + end +end diff --git a/bin/hugo-analyzer/file.rb b/bin/hugo-analyzer/file.rb new file mode 100644 index 000000000..2796d4714 --- /dev/null +++ b/bin/hugo-analyzer/file.rb @@ -0,0 +1,22 @@ +module HugoAnalyzer + class File + attr_reader :path, :json + + def initialize(path) + @path = path + @json = {} + end + + def data + @data ||= ::File.read(path) + end + + def directory? + ::File.directory?(path) + end + + def short_path + @short_path ||= path.gsub('./layouts/', '') + end + end +end diff --git a/bin/hugo-analyzer/utils.rb b/bin/hugo-analyzer/utils.rb new file mode 100644 index 000000000..703fe8570 --- /dev/null +++ b/bin/hugo-analyzer/utils.rb @@ -0,0 +1,17 @@ +module HugoAnalyzer + class Utils + def self.occurences(needle, haystack) + return 0 if haystack.empty? + haystack.split(needle).count - 1 + end + + def self.occurrences_in_files(needle, files) + occurences = 0 + files.each do |file| + next if file.directory? + occurences += occurences(needle, file.data) + end + occurences + end + end +end \ No newline at end of file From f761f0f7eb1fc198384ee63c3076ad8ac54fb1f1 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Wed, 11 Feb 2026 16:25:46 +0100 Subject: [PATCH 25/42] refactor --- bin/hugo-analyzer/analyzer.rb | 4 +++ bin/hugo-analyzer/engines/complexity.rb | 8 ++--- bin/hugo-analyzer/engines/directories.rb | 40 ++++++++++++++++++++++ bin/hugo-analyzer/engines/partial_calls.rb | 21 +++++++++--- 4 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 bin/hugo-analyzer/engines/directories.rb diff --git a/bin/hugo-analyzer/analyzer.rb b/bin/hugo-analyzer/analyzer.rb index a64a5e496..3d76eae2d 100644 --- a/bin/hugo-analyzer/analyzer.rb +++ b/bin/hugo-analyzer/analyzer.rb @@ -9,6 +9,10 @@ class Analyzer LAYOUTS = './layouts/**/*' + ICON_DANGER = '❌' + ICON_WARNING = '⚠️' + ICON_OK = 'βœ…' + def self.run new.to_s end diff --git a/bin/hugo-analyzer/engines/complexity.rb b/bin/hugo-analyzer/engines/complexity.rb index 9c333c139..67e2541d2 100644 --- a/bin/hugo-analyzer/engines/complexity.rb +++ b/bin/hugo-analyzer/engines/complexity.rb @@ -16,7 +16,7 @@ class Complexity < Base def to_s message = "## Complexity\n" message += "| State | Complexity | File |\n" - message += "|---|---|---|" + message += "|---|---|---|\n" analyzed_files.each do |file| complexity = file.json[:complexity] next unless complexity[:problem] @@ -41,11 +41,11 @@ def analyze(file) score += HugoAnalyzer::Utils.occurences("#{keyword} ", file.data) end problem = score > WARNING - icon = 'βœ…' + icon = HugoAnalyzer::Analyzer::ICON_OK if score > DANGER - icon = '❌' + icon = HugoAnalyzer::Analyzer::ICON_DANGER elsif score > WARNING - icon = '⚠️' + icon = HugoAnalyzer::Analyzer::ICON_WARNING end file.json[:complexity] = { score: score, diff --git a/bin/hugo-analyzer/engines/directories.rb b/bin/hugo-analyzer/engines/directories.rb new file mode 100644 index 000000000..efa1bb5ea --- /dev/null +++ b/bin/hugo-analyzer/engines/directories.rb @@ -0,0 +1,40 @@ +module HugoAnalyzer + module Engines + class Directories < Base + + def to_s + message = "## Too many files in directory \n" + message += "| Files | Directory |\n" + message += "|---|---|\n" + analyzed_files.each do |file| + directory = file.json[:directory] + message += "| #{directory[:count]} | #{directory[:path]} |\n" + end + message + end + + protected + + def should_analyze?(file) + !file.directory? && + file.path.include?(ROOT) + end + + def analyze(file) + fragment = file.path.gsub(ROOT, '').gsub('.html', '') + call = "partial \"#{fragment}" + count = HugoAnalyzer::Utils.occurrences_in_files(call, engine.files) + file.json[:calls] = { + fragment: fragment, + count: count + } + file + end + + def sort! + @analyzed_files.sort_by! { |file| file.json[:calls][:count] } + .reverse! + end + end + end +end diff --git a/bin/hugo-analyzer/engines/partial_calls.rb b/bin/hugo-analyzer/engines/partial_calls.rb index 0f3ca3f01..d7a7bc606 100644 --- a/bin/hugo-analyzer/engines/partial_calls.rb +++ b/bin/hugo-analyzer/engines/partial_calls.rb @@ -6,11 +6,12 @@ class PartialCalls < Base def to_s message = "## Partials calls\n" - message += "| Calls | Partial |\n" - message += "|---|---|\n" + message += "| State | Calls | Partial |\n" + message += "|---|---|---|\n" analyzed_files.each do |file| calls = file.json[:calls] - message += "| #{calls[:count]} | #{calls[:fragment]} |\n" + next unless calls[:problem] + message += "| #{calls[:icon]} | #{calls[:count]} | #{calls[:fragment]} |\n" end message end @@ -26,9 +27,21 @@ def analyze(file) fragment = file.path.gsub(ROOT, '').gsub('.html', '') call = "partial \"#{fragment}" count = HugoAnalyzer::Utils.occurrences_in_files(call, engine.files) + if count == 0 + problem = true + icon = HugoAnalyzer::Analyzer::ICON_DANGER + elsif count == 1 + problem = true + icon = HugoAnalyzer::Analyzer::ICON_WARNING + else + problem = false + icon = HugoAnalyzer::Analyzer::ICON_OK + end file.json[:calls] = { fragment: fragment, - count: count + count: count, + problem: problem, + icon: icon } file end From 5bbc26163501897cdc7f72dc8c8aa8375ca10fd5 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Wed, 11 Feb 2026 16:46:17 +0100 Subject: [PATCH 26/42] refactor --- bin/hugo-analyzer/analyzer.rb | 18 +++--------- bin/hugo-analyzer/engines/base.rb | 4 +++ bin/hugo-analyzer/engines/complexity.rb | 6 ++-- bin/hugo-analyzer/engines/directories.rb | 33 ++++++++++++++-------- bin/hugo-analyzer/engines/partial_calls.rb | 6 ++-- 5 files changed, 35 insertions(+), 32 deletions(-) diff --git a/bin/hugo-analyzer/analyzer.rb b/bin/hugo-analyzer/analyzer.rb index 3d76eae2d..dbf41fc03 100644 --- a/bin/hugo-analyzer/analyzer.rb +++ b/bin/hugo-analyzer/analyzer.rb @@ -1,5 +1,6 @@ require_relative 'engines/base' require_relative 'engines/complexity' +require_relative 'engines/directories' require_relative 'engines/partial_calls' require_relative 'file' require_relative 'utils' @@ -9,29 +10,18 @@ class Analyzer LAYOUTS = './layouts/**/*' - ICON_DANGER = '❌' - ICON_WARNING = '⚠️' - ICON_OK = 'βœ…' - def self.run new.to_s end def to_s message = '' - message += engine_complexity.to_s - message += engine_partial_calls.to_s + message += Engines::Complexity.new(self).to_s + message += Engines::PartialCalls.new(self).to_s + message += Engines::Directories.new(self).to_s message end - def engine_complexity - @engine_complexity ||= Engines::Complexity.new(self) - end - - def engine_partial_calls - @engine_partial_calls ||= Engines::PartialCalls.new(self) - end - def paths @paths ||= Dir.glob(LAYOUTS) end diff --git a/bin/hugo-analyzer/engines/base.rb b/bin/hugo-analyzer/engines/base.rb index a8e473209..0363a1255 100644 --- a/bin/hugo-analyzer/engines/base.rb +++ b/bin/hugo-analyzer/engines/base.rb @@ -3,6 +3,10 @@ module Engines class Base attr_reader :engine + ICON_DANGER = '❌' + ICON_WARNING = '⚠️' + ICON_OK = 'βœ…' + def initialize(engine) @engine = engine end diff --git a/bin/hugo-analyzer/engines/complexity.rb b/bin/hugo-analyzer/engines/complexity.rb index 67e2541d2..23e526806 100644 --- a/bin/hugo-analyzer/engines/complexity.rb +++ b/bin/hugo-analyzer/engines/complexity.rb @@ -41,11 +41,11 @@ def analyze(file) score += HugoAnalyzer::Utils.occurences("#{keyword} ", file.data) end problem = score > WARNING - icon = HugoAnalyzer::Analyzer::ICON_OK + icon = ICON_OK if score > DANGER - icon = HugoAnalyzer::Analyzer::ICON_DANGER + icon = ICON_DANGER elsif score > WARNING - icon = HugoAnalyzer::Analyzer::ICON_WARNING + icon = ICON_WARNING end file.json[:complexity] = { score: score, diff --git a/bin/hugo-analyzer/engines/directories.rb b/bin/hugo-analyzer/engines/directories.rb index efa1bb5ea..3f1739286 100644 --- a/bin/hugo-analyzer/engines/directories.rb +++ b/bin/hugo-analyzer/engines/directories.rb @@ -2,13 +2,17 @@ module HugoAnalyzer module Engines class Directories < Base + DANGER = 20 + WARNING = 10 + def to_s message = "## Too many files in directory \n" - message += "| Files | Directory |\n" - message += "|---|---|\n" + message += "| State | Files | Directory |\n" + message += "|---|---|---|\n" analyzed_files.each do |file| directory = file.json[:directory] - message += "| #{directory[:count]} | #{directory[:path]} |\n" + next unless directory[:problem] + message += "| #{directory[:icon]} | #{directory[:count]} | #{file.short_path} |\n" end message end @@ -16,23 +20,28 @@ def to_s protected def should_analyze?(file) - !file.directory? && - file.path.include?(ROOT) + file.directory? end def analyze(file) - fragment = file.path.gsub(ROOT, '').gsub('.html', '') - call = "partial \"#{fragment}" - count = HugoAnalyzer::Utils.occurrences_in_files(call, engine.files) - file.json[:calls] = { - fragment: fragment, - count: count + count = Dir["#{file.path}/*"].length + problem = count > WARNING + icon = ICON_OK + if count > DANGER + icon = ICON_DANGER + elsif count > WARNING + icon = ICON_WARNING + end + file.json[:directory] = { + count: count, + icon: icon, + problem: problem } file end def sort! - @analyzed_files.sort_by! { |file| file.json[:calls][:count] } + @analyzed_files.sort_by! { |file| file.json[:directory][:count] } .reverse! end end diff --git a/bin/hugo-analyzer/engines/partial_calls.rb b/bin/hugo-analyzer/engines/partial_calls.rb index d7a7bc606..43932bda5 100644 --- a/bin/hugo-analyzer/engines/partial_calls.rb +++ b/bin/hugo-analyzer/engines/partial_calls.rb @@ -29,13 +29,13 @@ def analyze(file) count = HugoAnalyzer::Utils.occurrences_in_files(call, engine.files) if count == 0 problem = true - icon = HugoAnalyzer::Analyzer::ICON_DANGER + icon = ICON_DANGER elsif count == 1 problem = true - icon = HugoAnalyzer::Analyzer::ICON_WARNING + icon = ICON_WARNING else problem = false - icon = HugoAnalyzer::Analyzer::ICON_OK + icon = ICON_OK end file.json[:calls] = { fragment: fragment, From bbfd278f876b1e9fcd8a58c2ce385926475a5e4f Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Wed, 11 Feb 2026 16:59:20 +0100 Subject: [PATCH 27/42] refac --- bin/hugo-analyzer/engines/complexity.rb | 8 +++++--- bin/hugo-analyzer/engines/directories.rb | 8 +++++--- bin/hugo-analyzer/engines/partial_calls.rb | 8 +++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/bin/hugo-analyzer/engines/complexity.rb b/bin/hugo-analyzer/engines/complexity.rb index 23e526806..fa10b22be 100644 --- a/bin/hugo-analyzer/engines/complexity.rb +++ b/bin/hugo-analyzer/engines/complexity.rb @@ -15,12 +15,14 @@ class Complexity < Base def to_s message = "## Complexity\n" - message += "| State | Complexity | File |\n" - message += "|---|---|---|\n" + message += "| Id | State | Complexity | File |\n" + message += "|---|---|---|---|\n" + index = 1 analyzed_files.each do |file| complexity = file.json[:complexity] next unless complexity[:problem] - message += "| #{complexity[:icon]} | #{complexity[:score]} | #{file.short_path} |\n" + message += "| cpl-#{index} | #{complexity[:icon]} | #{complexity[:score]} | #{file.short_path} |\n" + index += 1 end message end diff --git a/bin/hugo-analyzer/engines/directories.rb b/bin/hugo-analyzer/engines/directories.rb index 3f1739286..7d8259e3f 100644 --- a/bin/hugo-analyzer/engines/directories.rb +++ b/bin/hugo-analyzer/engines/directories.rb @@ -7,12 +7,14 @@ class Directories < Base def to_s message = "## Too many files in directory \n" - message += "| State | Files | Directory |\n" - message += "|---|---|---|\n" + message += "| Id | State | Files | Directory |\n" + message += "|---|---|---|---|\n" + index = 1 analyzed_files.each do |file| directory = file.json[:directory] next unless directory[:problem] - message += "| #{directory[:icon]} | #{directory[:count]} | #{file.short_path} |\n" + message += "| dir-#{index} | #{directory[:icon]} | #{directory[:count]} | #{file.short_path} |\n" + index += 1 end message end diff --git a/bin/hugo-analyzer/engines/partial_calls.rb b/bin/hugo-analyzer/engines/partial_calls.rb index 43932bda5..8e56e8b6d 100644 --- a/bin/hugo-analyzer/engines/partial_calls.rb +++ b/bin/hugo-analyzer/engines/partial_calls.rb @@ -6,12 +6,14 @@ class PartialCalls < Base def to_s message = "## Partials calls\n" - message += "| State | Calls | Partial |\n" - message += "|---|---|---|\n" + message += "| Id | State | Calls | Partial |\n" + message += "|---|---|---|---|\n" + index = 1 analyzed_files.each do |file| calls = file.json[:calls] next unless calls[:problem] - message += "| #{calls[:icon]} | #{calls[:count]} | #{calls[:fragment]} |\n" + message += "| cal-#{index} | #{calls[:icon]} | #{calls[:count]} | #{calls[:fragment]} |\n" + index += 1 end message end From befad3253886d4acf6388bd2b3c95766f9fb097b Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Wed, 11 Feb 2026 17:21:00 +0100 Subject: [PATCH 28/42] lines --- bin/hugo-analyzer/analyzer.rb | 2 + bin/hugo-analyzer/engines/complexity.rb | 1 + bin/hugo-analyzer/engines/directories.rb | 3 +- bin/hugo-analyzer/engines/lines.rb | 52 ++++++++++++++++++++++ bin/hugo-analyzer/engines/partial_calls.rb | 3 +- 5 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 bin/hugo-analyzer/engines/lines.rb diff --git a/bin/hugo-analyzer/analyzer.rb b/bin/hugo-analyzer/analyzer.rb index dbf41fc03..97c9eb53a 100644 --- a/bin/hugo-analyzer/analyzer.rb +++ b/bin/hugo-analyzer/analyzer.rb @@ -1,6 +1,7 @@ require_relative 'engines/base' require_relative 'engines/complexity' require_relative 'engines/directories' +require_relative 'engines/lines' require_relative 'engines/partial_calls' require_relative 'file' require_relative 'utils' @@ -19,6 +20,7 @@ def to_s message += Engines::Complexity.new(self).to_s message += Engines::PartialCalls.new(self).to_s message += Engines::Directories.new(self).to_s + message += Engines::Lines.new(self).to_s message end diff --git a/bin/hugo-analyzer/engines/complexity.rb b/bin/hugo-analyzer/engines/complexity.rb index fa10b22be..43a167f5a 100644 --- a/bin/hugo-analyzer/engines/complexity.rb +++ b/bin/hugo-analyzer/engines/complexity.rb @@ -15,6 +15,7 @@ class Complexity < Base def to_s message = "## Complexity\n" + message = "Cyclomatic complexity should not be too high.\n" message += "| Id | State | Complexity | File |\n" message += "|---|---|---|---|\n" index = 1 diff --git a/bin/hugo-analyzer/engines/directories.rb b/bin/hugo-analyzer/engines/directories.rb index 7d8259e3f..5408881c8 100644 --- a/bin/hugo-analyzer/engines/directories.rb +++ b/bin/hugo-analyzer/engines/directories.rb @@ -6,7 +6,8 @@ class Directories < Base WARNING = 10 def to_s - message = "## Too many files in directory \n" + message = "## Directories \n" + message = "Directories should not contain too many files, it's probably a sign of mess.\n" message += "| Id | State | Files | Directory |\n" message += "|---|---|---|---|\n" index = 1 diff --git a/bin/hugo-analyzer/engines/lines.rb b/bin/hugo-analyzer/engines/lines.rb new file mode 100644 index 000000000..0cc0b0058 --- /dev/null +++ b/bin/hugo-analyzer/engines/lines.rb @@ -0,0 +1,52 @@ +module HugoAnalyzer + module Engines + class Lines < Base + + DANGER = 50 + WARNING = 25 + + def to_s + message = "## Too many lines \n" + message = "Files should not be too long, it's a sign of mess and a difficulty for overrides.\n" + message += "| Id | State | Lines | Path |\n" + message += "|---|---|---|---|\n" + index = 1 + analyzed_files.each do |file| + lines = file.json[:lines] + next unless lines[:problem] + message += "| lin-#{index} | #{lines[:icon]} | #{lines[:count]} | #{file.short_path} |\n" + index += 1 + end + message + end + + protected + + def should_analyze?(file) + !file.directory? + end + + def analyze(file) + count = file.data.lines.count + problem = count > WARNING + icon = ICON_OK + if count > DANGER + icon = ICON_DANGER + elsif count > WARNING + icon = ICON_WARNING + end + file.json[:lines] = { + count: count, + icon: icon, + problem: problem + } + file + end + + def sort! + @analyzed_files.sort_by! { |file| file.json[:lines][:count] } + .reverse! + end + end + end +end diff --git a/bin/hugo-analyzer/engines/partial_calls.rb b/bin/hugo-analyzer/engines/partial_calls.rb index 8e56e8b6d..c4e37a675 100644 --- a/bin/hugo-analyzer/engines/partial_calls.rb +++ b/bin/hugo-analyzer/engines/partial_calls.rb @@ -5,7 +5,8 @@ class PartialCalls < Base ROOT = './layouts/partials/' def to_s - message = "## Partials calls\n" + message = "## Partial called\n" + message = "Partials called once might be in the wrong place. Partials never called might be metaprogrammed, or obsolete." message += "| Id | State | Calls | Partial |\n" message += "|---|---|---|---|\n" index = 1 From 2b219b399f67d24f8453206af9f00ad08e9ef864 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Wed, 11 Feb 2026 17:22:30 +0100 Subject: [PATCH 29/42] cpx --- bin/hugo-analyzer/engines/complexity.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/hugo-analyzer/engines/complexity.rb b/bin/hugo-analyzer/engines/complexity.rb index 43a167f5a..ec53e7126 100644 --- a/bin/hugo-analyzer/engines/complexity.rb +++ b/bin/hugo-analyzer/engines/complexity.rb @@ -22,7 +22,7 @@ def to_s analyzed_files.each do |file| complexity = file.json[:complexity] next unless complexity[:problem] - message += "| cpl-#{index} | #{complexity[:icon]} | #{complexity[:score]} | #{file.short_path} |\n" + message += "| cpx-#{index} | #{complexity[:icon]} | #{complexity[:score]} | #{file.short_path} |\n" index += 1 end message From bb665de84fe69c758157917efa64ccdddc9e81da Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Wed, 11 Feb 2026 17:23:33 +0100 Subject: [PATCH 30/42] wip --- bin/hugo-analyzer/engines/complexity.rb | 2 +- bin/hugo-analyzer/engines/directories.rb | 2 +- bin/hugo-analyzer/engines/lines.rb | 2 +- bin/hugo-analyzer/engines/partial_calls.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/hugo-analyzer/engines/complexity.rb b/bin/hugo-analyzer/engines/complexity.rb index ec53e7126..9c553a163 100644 --- a/bin/hugo-analyzer/engines/complexity.rb +++ b/bin/hugo-analyzer/engines/complexity.rb @@ -15,7 +15,7 @@ class Complexity < Base def to_s message = "## Complexity\n" - message = "Cyclomatic complexity should not be too high.\n" + message += "Cyclomatic complexity should not be too high.\n" message += "| Id | State | Complexity | File |\n" message += "|---|---|---|---|\n" index = 1 diff --git a/bin/hugo-analyzer/engines/directories.rb b/bin/hugo-analyzer/engines/directories.rb index 5408881c8..23f137ceb 100644 --- a/bin/hugo-analyzer/engines/directories.rb +++ b/bin/hugo-analyzer/engines/directories.rb @@ -7,7 +7,7 @@ class Directories < Base def to_s message = "## Directories \n" - message = "Directories should not contain too many files, it's probably a sign of mess.\n" + message += "Directories should not contain too many files, it's probably a sign of mess.\n" message += "| Id | State | Files | Directory |\n" message += "|---|---|---|---|\n" index = 1 diff --git a/bin/hugo-analyzer/engines/lines.rb b/bin/hugo-analyzer/engines/lines.rb index 0cc0b0058..31c10e126 100644 --- a/bin/hugo-analyzer/engines/lines.rb +++ b/bin/hugo-analyzer/engines/lines.rb @@ -7,7 +7,7 @@ class Lines < Base def to_s message = "## Too many lines \n" - message = "Files should not be too long, it's a sign of mess and a difficulty for overrides.\n" + message += "Files should not be too long, it's a sign of mess and a difficulty for overrides.\n" message += "| Id | State | Lines | Path |\n" message += "|---|---|---|---|\n" index = 1 diff --git a/bin/hugo-analyzer/engines/partial_calls.rb b/bin/hugo-analyzer/engines/partial_calls.rb index c4e37a675..f66f16e8d 100644 --- a/bin/hugo-analyzer/engines/partial_calls.rb +++ b/bin/hugo-analyzer/engines/partial_calls.rb @@ -6,7 +6,7 @@ class PartialCalls < Base def to_s message = "## Partial called\n" - message = "Partials called once might be in the wrong place. Partials never called might be metaprogrammed, or obsolete." + message += "Partials called once might be in the wrong place. Partials never called might be metaprogrammed, or obsolete.\n" message += "| Id | State | Calls | Partial |\n" message += "|---|---|---|---|\n" index = 1 From 6a28707f0eff6efb491ffb416018875c4b4d7461 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Wed, 11 Feb 2026 17:24:32 +0100 Subject: [PATCH 31/42] messages --- bin/hugo-analyzer/analyzer.rb | 2 +- bin/hugo-analyzer/engines/complexity.rb | 2 +- bin/hugo-analyzer/engines/directories.rb | 2 +- bin/hugo-analyzer/engines/lines.rb | 2 +- bin/hugo-analyzer/engines/partial_calls.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/hugo-analyzer/analyzer.rb b/bin/hugo-analyzer/analyzer.rb index 97c9eb53a..1e3eb28ee 100644 --- a/bin/hugo-analyzer/analyzer.rb +++ b/bin/hugo-analyzer/analyzer.rb @@ -16,7 +16,7 @@ def self.run end def to_s - message = '' + message = "## Hugo analyzer\n" message += Engines::Complexity.new(self).to_s message += Engines::PartialCalls.new(self).to_s message += Engines::Directories.new(self).to_s diff --git a/bin/hugo-analyzer/engines/complexity.rb b/bin/hugo-analyzer/engines/complexity.rb index 9c553a163..db10d3d83 100644 --- a/bin/hugo-analyzer/engines/complexity.rb +++ b/bin/hugo-analyzer/engines/complexity.rb @@ -14,7 +14,7 @@ class Complexity < Base WARNING = 5 def to_s - message = "## Complexity\n" + message = "### Complexity\n" message += "Cyclomatic complexity should not be too high.\n" message += "| Id | State | Complexity | File |\n" message += "|---|---|---|---|\n" diff --git a/bin/hugo-analyzer/engines/directories.rb b/bin/hugo-analyzer/engines/directories.rb index 23f137ceb..7135979bf 100644 --- a/bin/hugo-analyzer/engines/directories.rb +++ b/bin/hugo-analyzer/engines/directories.rb @@ -6,7 +6,7 @@ class Directories < Base WARNING = 10 def to_s - message = "## Directories \n" + message = "### Directories \n" message += "Directories should not contain too many files, it's probably a sign of mess.\n" message += "| Id | State | Files | Directory |\n" message += "|---|---|---|---|\n" diff --git a/bin/hugo-analyzer/engines/lines.rb b/bin/hugo-analyzer/engines/lines.rb index 31c10e126..d1fb6e1c5 100644 --- a/bin/hugo-analyzer/engines/lines.rb +++ b/bin/hugo-analyzer/engines/lines.rb @@ -6,7 +6,7 @@ class Lines < Base WARNING = 25 def to_s - message = "## Too many lines \n" + message = "### Too many lines \n" message += "Files should not be too long, it's a sign of mess and a difficulty for overrides.\n" message += "| Id | State | Lines | Path |\n" message += "|---|---|---|---|\n" diff --git a/bin/hugo-analyzer/engines/partial_calls.rb b/bin/hugo-analyzer/engines/partial_calls.rb index f66f16e8d..b7c328651 100644 --- a/bin/hugo-analyzer/engines/partial_calls.rb +++ b/bin/hugo-analyzer/engines/partial_calls.rb @@ -5,7 +5,7 @@ class PartialCalls < Base ROOT = './layouts/partials/' def to_s - message = "## Partial called\n" + message = "### Partial called\n" message += "Partials called once might be in the wrong place. Partials never called might be metaprogrammed, or obsolete.\n" message += "| Id | State | Calls | Partial |\n" message += "|---|---|---|---|\n" From d332163ef7c278ee99857cdedaf7fb51f780b7d4 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Wed, 11 Feb 2026 17:28:17 +0100 Subject: [PATCH 32/42] title --- bin/hugo-analyzer/engines/partial_calls.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/hugo-analyzer/engines/partial_calls.rb b/bin/hugo-analyzer/engines/partial_calls.rb index b7c328651..e9dace1e6 100644 --- a/bin/hugo-analyzer/engines/partial_calls.rb +++ b/bin/hugo-analyzer/engines/partial_calls.rb @@ -5,7 +5,7 @@ class PartialCalls < Base ROOT = './layouts/partials/' def to_s - message = "### Partial called\n" + message = "### Partials calls\n" message += "Partials called once might be in the wrong place. Partials never called might be metaprogrammed, or obsolete.\n" message += "| Id | State | Calls | Partial |\n" message += "|---|---|---|---|\n" From c66e706f0c5c84f8b0105792c1c559f2570809cc Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Thu, 12 Feb 2026 13:39:45 +0100 Subject: [PATCH 33/42] wip --- bin/hugo-analyzer/analyzer.rb | 4 ++-- bin/hugo-analyzer/engines/directories.rb | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/hugo-analyzer/analyzer.rb b/bin/hugo-analyzer/analyzer.rb index 1e3eb28ee..13a417143 100644 --- a/bin/hugo-analyzer/analyzer.rb +++ b/bin/hugo-analyzer/analyzer.rb @@ -17,10 +17,10 @@ def self.run def to_s message = "## Hugo analyzer\n" - message += Engines::Complexity.new(self).to_s - message += Engines::PartialCalls.new(self).to_s message += Engines::Directories.new(self).to_s + message += Engines::PartialCalls.new(self).to_s message += Engines::Lines.new(self).to_s + message += Engines::Complexity.new(self).to_s message end diff --git a/bin/hugo-analyzer/engines/directories.rb b/bin/hugo-analyzer/engines/directories.rb index 7135979bf..8760a7bdc 100644 --- a/bin/hugo-analyzer/engines/directories.rb +++ b/bin/hugo-analyzer/engines/directories.rb @@ -27,6 +27,7 @@ def should_analyze?(file) end def analyze(file) + # TODO only count files count = Dir["#{file.path}/*"].length problem = count > WARNING icon = ICON_OK From ea17a7e51ed9b91cb1a0308de6607e759765eab3 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Thu, 12 Feb 2026 13:43:35 +0100 Subject: [PATCH 34/42] call --- bin/hugo-analyzer/engines/directories.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/hugo-analyzer/engines/directories.rb b/bin/hugo-analyzer/engines/directories.rb index 8760a7bdc..1037c361b 100644 --- a/bin/hugo-analyzer/engines/directories.rb +++ b/bin/hugo-analyzer/engines/directories.rb @@ -27,8 +27,7 @@ def should_analyze?(file) end def analyze(file) - # TODO only count files - count = Dir["#{file.path}/*"].length + count = Dir["#{file.path}/*.*"].length problem = count > WARNING icon = ICON_OK if count > DANGER From 2841036b7d4fd2e51ac593cd58a29397061f83d1 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Thu, 12 Feb 2026 14:03:35 +0100 Subject: [PATCH 35/42] exclusions --- .github/workflows/analysis.yml | 2 +- .hugolint | 4 ++++ bin/hugo-analyzer.rb | 2 -- bin/hugolint.rb | 2 ++ bin/{hugo-analyzer => hugolint}/analyzer.rb | 10 ++++++-- .../engines/base.rb | 24 ++++++++++++++----- .../engines/complexity.rb | 5 ++-- .../engines/directories.rb | 3 ++- .../engines/lines.rb | 3 ++- .../engines/partial_calls.rb | 5 ++-- bin/{hugo-analyzer => hugolint}/file.rb | 2 +- bin/{hugo-analyzer => hugolint}/utils.rb | 2 +- 12 files changed, 45 insertions(+), 19 deletions(-) create mode 100644 .hugolint delete mode 100644 bin/hugo-analyzer.rb create mode 100644 bin/hugolint.rb rename bin/{hugo-analyzer => hugolint}/analyzer.rb (79%) rename bin/{hugo-analyzer => hugolint}/engines/base.rb (52%) rename bin/{hugo-analyzer => hugolint}/engines/complexity.rb (92%) rename bin/{hugo-analyzer => hugolint}/engines/directories.rb (97%) rename bin/{hugo-analyzer => hugolint}/engines/lines.rb (97%) rename bin/{hugo-analyzer => hugolint}/engines/partial_calls.rb (93%) rename bin/{hugo-analyzer => hugolint}/file.rb (94%) rename bin/{hugo-analyzer => hugolint}/utils.rb (94%) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index e3b553ca0..9ee4dae40 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -35,7 +35,7 @@ jobs: - name: Complexity run: | - ruby bin/hugo-analyzer.rb >> report.txt || true + ruby bin/hugolint.rb >> report.txt || true - name: Comment pull request uses: mshick/add-pr-comment@v2 diff --git a/.hugolint b/.hugolint new file mode 100644 index 000000000..0e11cc8b1 --- /dev/null +++ b/.hugolint @@ -0,0 +1,4 @@ +engines: + directories: + exclude: + - partials/blocks/templates \ No newline at end of file diff --git a/bin/hugo-analyzer.rb b/bin/hugo-analyzer.rb deleted file mode 100644 index 9fc5ba5e8..000000000 --- a/bin/hugo-analyzer.rb +++ /dev/null @@ -1,2 +0,0 @@ -require_relative 'hugo-analyzer/analyzer' -puts HugoAnalyzer::Analyzer.run diff --git a/bin/hugolint.rb b/bin/hugolint.rb new file mode 100644 index 000000000..b17729295 --- /dev/null +++ b/bin/hugolint.rb @@ -0,0 +1,2 @@ +require_relative 'hugolint/analyzer' +puts Hugolint::Analyzer.run diff --git a/bin/hugo-analyzer/analyzer.rb b/bin/hugolint/analyzer.rb similarity index 79% rename from bin/hugo-analyzer/analyzer.rb rename to bin/hugolint/analyzer.rb index 13a417143..8c1556f2e 100644 --- a/bin/hugo-analyzer/analyzer.rb +++ b/bin/hugolint/analyzer.rb @@ -5,11 +5,13 @@ require_relative 'engines/partial_calls' require_relative 'file' require_relative 'utils' +require 'yaml' -module HugoAnalyzer +module Hugolint class Analyzer LAYOUTS = './layouts/**/*' + CONFIG = '.hugolint' def self.run new.to_s @@ -29,7 +31,11 @@ def paths end def files - @files ||= paths.map { |path| HugoAnalyzer::File.new(path) } + @files ||= paths.map { |path| Hugolint::File.new(path) } + end + + def config + @config ||= YAML.load_file(CONFIG) end end end diff --git a/bin/hugo-analyzer/engines/base.rb b/bin/hugolint/engines/base.rb similarity index 52% rename from bin/hugo-analyzer/engines/base.rb rename to bin/hugolint/engines/base.rb index 0363a1255..1d22a2af8 100644 --- a/bin/hugo-analyzer/engines/base.rb +++ b/bin/hugolint/engines/base.rb @@ -1,20 +1,20 @@ -module HugoAnalyzer +module Hugolint module Engines class Base - attr_reader :engine + attr_reader :analyzer ICON_DANGER = '❌' ICON_WARNING = '⚠️' ICON_OK = 'βœ…' - def initialize(engine) - @engine = engine + def initialize(analyzer) + @analyzer = analyzer end def analyzed_files unless @analyzed_files @analyzed_files = [] - engine.files.each do |file| + analyzer.files.each do |file| next unless should_analyze?(file) @analyzed_files << analyze(file) end @@ -29,7 +29,7 @@ def to_s protected def should_analyze?(file) - true + !files_excluded.include?(file.short_path) end def analyze(file) @@ -37,6 +37,18 @@ def analyze(file) def sort! end + + def engine_identifier + self.class.name.split('::').last.downcase + end + + def engine_config + @engine_config ||= analyzer.config.dig('engines', engine_identifier) + end + + def files_excluded + @files_excluded ||= engine_config&.dig('exclude') || [] + end end end end diff --git a/bin/hugo-analyzer/engines/complexity.rb b/bin/hugolint/engines/complexity.rb similarity index 92% rename from bin/hugo-analyzer/engines/complexity.rb rename to bin/hugolint/engines/complexity.rb index db10d3d83..2204bca2c 100644 --- a/bin/hugo-analyzer/engines/complexity.rb +++ b/bin/hugolint/engines/complexity.rb @@ -1,4 +1,4 @@ -module HugoAnalyzer +module Hugolint module Engines class Complexity < Base @@ -31,6 +31,7 @@ def to_s protected def should_analyze?(file) + super && !file.directory? end @@ -41,7 +42,7 @@ def sort! def analyze(file) score = 1 KEYWORDS.each do |keyword| - score += HugoAnalyzer::Utils.occurences("#{keyword} ", file.data) + score += Hugolint::Utils.occurences("#{keyword} ", file.data) end problem = score > WARNING icon = ICON_OK diff --git a/bin/hugo-analyzer/engines/directories.rb b/bin/hugolint/engines/directories.rb similarity index 97% rename from bin/hugo-analyzer/engines/directories.rb rename to bin/hugolint/engines/directories.rb index 1037c361b..7efc95f80 100644 --- a/bin/hugo-analyzer/engines/directories.rb +++ b/bin/hugolint/engines/directories.rb @@ -1,4 +1,4 @@ -module HugoAnalyzer +module Hugolint module Engines class Directories < Base @@ -23,6 +23,7 @@ def to_s protected def should_analyze?(file) + super && file.directory? end diff --git a/bin/hugo-analyzer/engines/lines.rb b/bin/hugolint/engines/lines.rb similarity index 97% rename from bin/hugo-analyzer/engines/lines.rb rename to bin/hugolint/engines/lines.rb index d1fb6e1c5..46a93b55a 100644 --- a/bin/hugo-analyzer/engines/lines.rb +++ b/bin/hugolint/engines/lines.rb @@ -1,4 +1,4 @@ -module HugoAnalyzer +module Hugolint module Engines class Lines < Base @@ -23,6 +23,7 @@ def to_s protected def should_analyze?(file) + super && !file.directory? end diff --git a/bin/hugo-analyzer/engines/partial_calls.rb b/bin/hugolint/engines/partial_calls.rb similarity index 93% rename from bin/hugo-analyzer/engines/partial_calls.rb rename to bin/hugolint/engines/partial_calls.rb index e9dace1e6..aa53c1c70 100644 --- a/bin/hugo-analyzer/engines/partial_calls.rb +++ b/bin/hugolint/engines/partial_calls.rb @@ -1,4 +1,4 @@ -module HugoAnalyzer +module Hugolint module Engines class PartialCalls < Base @@ -22,6 +22,7 @@ def to_s protected def should_analyze?(file) + super && !file.directory? && file.path.include?(ROOT) end @@ -29,7 +30,7 @@ def should_analyze?(file) def analyze(file) fragment = file.path.gsub(ROOT, '').gsub('.html', '') call = "partial \"#{fragment}" - count = HugoAnalyzer::Utils.occurrences_in_files(call, engine.files) + count = Hugolint::Utils.occurrences_in_files(call, analyzer.files) if count == 0 problem = true icon = ICON_DANGER diff --git a/bin/hugo-analyzer/file.rb b/bin/hugolint/file.rb similarity index 94% rename from bin/hugo-analyzer/file.rb rename to bin/hugolint/file.rb index 2796d4714..e852c5ca8 100644 --- a/bin/hugo-analyzer/file.rb +++ b/bin/hugolint/file.rb @@ -1,4 +1,4 @@ -module HugoAnalyzer +module Hugolint class File attr_reader :path, :json diff --git a/bin/hugo-analyzer/utils.rb b/bin/hugolint/utils.rb similarity index 94% rename from bin/hugo-analyzer/utils.rb rename to bin/hugolint/utils.rb index 703fe8570..ba1579086 100644 --- a/bin/hugo-analyzer/utils.rb +++ b/bin/hugolint/utils.rb @@ -1,4 +1,4 @@ -module HugoAnalyzer +module Hugolint class Utils def self.occurences(needle, haystack) return 0 if haystack.empty? From f19bb0bc88c3c195052e5e453815ba1e51f848d2 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Thu, 12 Feb 2026 14:07:39 +0100 Subject: [PATCH 36/42] lint --- .hugolint | 8 +++++++- bin/hugolint/analyzer.rb | 4 ++-- bin/hugolint/engines/{partial_calls.rb => calls.rb} | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) rename bin/hugolint/engines/{partial_calls.rb => calls.rb} (98%) diff --git a/.hugolint b/.hugolint index 0e11cc8b1..24f88686a 100644 --- a/.hugolint +++ b/.hugolint @@ -1,4 +1,10 @@ engines: directories: exclude: - - partials/blocks/templates \ No newline at end of file + - partials/blocks/templates + complexity: + exclude: + lines: + exclude: + calls: + exclude: diff --git a/bin/hugolint/analyzer.rb b/bin/hugolint/analyzer.rb index 8c1556f2e..8b586ea09 100644 --- a/bin/hugolint/analyzer.rb +++ b/bin/hugolint/analyzer.rb @@ -2,7 +2,7 @@ require_relative 'engines/complexity' require_relative 'engines/directories' require_relative 'engines/lines' -require_relative 'engines/partial_calls' +require_relative 'engines/calls' require_relative 'file' require_relative 'utils' require 'yaml' @@ -20,7 +20,7 @@ def self.run def to_s message = "## Hugo analyzer\n" message += Engines::Directories.new(self).to_s - message += Engines::PartialCalls.new(self).to_s + message += Engines::Calls.new(self).to_s message += Engines::Lines.new(self).to_s message += Engines::Complexity.new(self).to_s message diff --git a/bin/hugolint/engines/partial_calls.rb b/bin/hugolint/engines/calls.rb similarity index 98% rename from bin/hugolint/engines/partial_calls.rb rename to bin/hugolint/engines/calls.rb index aa53c1c70..3610010ab 100644 --- a/bin/hugolint/engines/partial_calls.rb +++ b/bin/hugolint/engines/calls.rb @@ -1,6 +1,6 @@ module Hugolint module Engines - class PartialCalls < Base + class Calls < Base ROOT = './layouts/partials/' From 82ada469534f819720f2a612f88919a89e284fd6 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Thu, 12 Feb 2026 14:08:39 +0100 Subject: [PATCH 37/42] calls --- .hugolint | 1 + 1 file changed, 1 insertion(+) diff --git a/.hugolint b/.hugolint index 24f88686a..f4e1e41bd 100644 --- a/.hugolint +++ b/.hugolint @@ -8,3 +8,4 @@ engines: exclude: calls: exclude: + - blocks/templates/categories From f5a3200bd7ffe5a2651851e83499322f14677782 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Thu, 12 Feb 2026 14:17:21 +0100 Subject: [PATCH 38/42] fix --- .hugolint | 2 +- bin/hugolint/engines/calls.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.hugolint b/.hugolint index f4e1e41bd..05c9021a8 100644 --- a/.hugolint +++ b/.hugolint @@ -8,4 +8,4 @@ engines: exclude: calls: exclude: - - blocks/templates/categories + - partials/blocks/templates/categories.html diff --git a/bin/hugolint/engines/calls.rb b/bin/hugolint/engines/calls.rb index 3610010ab..edfa58ee5 100644 --- a/bin/hugolint/engines/calls.rb +++ b/bin/hugolint/engines/calls.rb @@ -7,13 +7,13 @@ class Calls < Base def to_s message = "### Partials calls\n" message += "Partials called once might be in the wrong place. Partials never called might be metaprogrammed, or obsolete.\n" - message += "| Id | State | Calls | Partial |\n" - message += "|---|---|---|---|\n" + message += "| Id | State | Calls | Fragment | Partial |\n" + message += "|---|---|---|---|---|\n" index = 1 analyzed_files.each do |file| calls = file.json[:calls] next unless calls[:problem] - message += "| cal-#{index} | #{calls[:icon]} | #{calls[:count]} | #{calls[:fragment]} |\n" + message += "| cal-#{index} | #{calls[:icon]} | #{calls[:count]} | #{calls[:fragment]} | #{file.short_path} |\n" index += 1 end message From 999338607718e0b3e94ace85403d471f0a2f2c15 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Thu, 12 Feb 2026 14:27:20 +0100 Subject: [PATCH 39/42] credit --- layouts/partials/AddCreditMention.html | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/layouts/partials/AddCreditMention.html b/layouts/partials/AddCreditMention.html index 58804e863..150036d45 100644 --- a/layouts/partials/AddCreditMention.html +++ b/layouts/partials/AddCreditMention.html @@ -1,13 +1,7 @@ -{{ $credit := .credit }} -{{ $first_paragraph := "" }} +{{ $credit := . }} -{{ $sr_only_text := printf "%s" (i18n "commons.accessibility.credits") }} -{{ $credit = replace $credit "

        " (printf "

        %s" $sr_only_text) 1 }} - -{{ if .before }} - {{ $credit = replace $credit "

        " "

        " 1 }} -{{ else if .after }} - {{ $credit = replace $credit "

        " "

        " 1 }} -{{ end }} +{{ $sr_only_text := printf "%s" (i18n "commons.accessibility.credits") }} +{{ $icon := "Β©" }} +{{ $credit = replace $credit "

        " (printf "

        %s%s" $sr_only_text $icon) 1 }} {{ return ($credit | safeHTML) }} \ No newline at end of file From fa35a6ed1d3142800b6568c63da88b73ee73b4a4 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Thu, 12 Feb 2026 14:29:58 +0100 Subject: [PATCH 40/42] llint --- .hugolint | 1 + 1 file changed, 1 insertion(+) diff --git a/.hugolint b/.hugolint index 05c9021a8..72aefe962 100644 --- a/.hugolint +++ b/.hugolint @@ -8,4 +8,5 @@ engines: exclude: calls: exclude: + - partials/projects/single/sidebar.html - partials/blocks/templates/categories.html From 0eb265484bb315bf6fef7038d26c82327c9a42b1 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Fri, 13 Feb 2026 11:54:18 +0100 Subject: [PATCH 41/42] lines --- bin/hugolint/engines/lines.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/hugolint/engines/lines.rb b/bin/hugolint/engines/lines.rb index 46a93b55a..3b9b046e8 100644 --- a/bin/hugolint/engines/lines.rb +++ b/bin/hugolint/engines/lines.rb @@ -2,8 +2,8 @@ module Hugolint module Engines class Lines < Base - DANGER = 50 - WARNING = 25 + DANGER = 70 + WARNING = 35 def to_s message = "### Too many lines \n" From 8fdf05f4adbd2a99163320964694baed0ca2a2d0 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Fri, 13 Feb 2026 13:34:59 +0100 Subject: [PATCH 42/42] helper calls --- bin/hugolint/engines/calls.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/hugolint/engines/calls.rb b/bin/hugolint/engines/calls.rb index edfa58ee5..1cade8d6f 100644 --- a/bin/hugolint/engines/calls.rb +++ b/bin/hugolint/engines/calls.rb @@ -31,10 +31,13 @@ def analyze(file) fragment = file.path.gsub(ROOT, '').gsub('.html', '') call = "partial \"#{fragment}" count = Hugolint::Utils.occurrences_in_files(call, analyzer.files) + # Les fichiers ont le droit d'Γͺtre utilisΓ©s 1 seule fois, + # si et seulement si ce ne sont pas des helpers Γ  la racine + is_helper = !fragment.include?('/') if count == 0 problem = true icon = ICON_DANGER - elsif count == 1 + elsif count == 1 && is_helper problem = true icon = ICON_WARNING else