Skip to content

chore: fix the SonarQube Cloud findings that fit the code style - #83

Merged
somethingwithproof merged 2 commits into
mainfrom
chore/sonar-findings
Nov 15, 2026
Merged

somethingwithproof merged 2 commits into
mainfrom
chore/sonar-findings

Conversation

@somethingwithproof

@somethingwithproof somethingwithproof commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Fixes the SonarQube Cloud findings on main that don't conflict with the Cacti code style: 352 of the 913.

  • php:S103, 337 of 344: lines over 120 characters are wrapped in the existing style. That means tabs, braces on the same line, one argument or array element per line, and SQL broken at whitespace. A long literal is joined back with . so the text is unchanged. A token comparison against main, folding joined literals, matches every file except two strings containing variables, whose text I checked by hand. Seven lines stay long, because each is a translated string alone on its line, and splitting it would change its translation key.
  • shell:S7679, 5: generate() in locales/build_gettext.sh gives its output path a name instead of using $1 throughout.
  • php:S122, 3: test fixtures that ran two statements in a one-line closure now put each on its own line.

Two follow-ons from the wrapping:

  • The placeholder rule in SourceRulesTest now allows a line break after __(. Without that it silently skipped wrapped strings, checking 98 instead of 112.
  • cacti.pot is regenerated. It has the same strings, in the order the wrapped sources now give.

Not changed: php:S100 (Cacti calls plugin_cloud_install and the other hook functions by exact name), php:S105 (the repo's .editorconfig and Cacti core use tabs), php:S1808 (Cacti puts braces on the same line), and php:S101 (AwsSigV4 is AWS's name). These need deactivating in the project's quality profile.

Tests, run locally on Cacti 1.2.31 and 1.2.x:

  • Unit: 194 passed.
  • Integration: 14 passed.
  • Page permissions: 21 checks passed.
  • PHP 8.0 entry-point lint and PHPStan are clean.
  • The REUSE and gettext checks pass.

Summary by Gitar

  • Line wrapping:
    • Wrapped over-long PHP lines across the codebase in Cacti style, with long literals rejoined by .
  • Translation placeholder rule:
    • Allowed a line break after __( in SourceRulesTest so wrapped strings are still checked
  • Localization:
    • Regenerated cacti.pot to match the reordered wrapped sources

This will update automatically on new commits.

- build_gettext.sh names generate()'s output path instead of reusing
  $1 (shell:S7679).
- Test fixtures that ran two statements in a one-line closure now put
  each on its own line (php:S122).

Refs #38

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The gettext generation script stores its output path in a variable and uses it in the extraction and normalization commands. Unit test fixture closures are reformatted without changes to their setup or expectations.

Changes: Gettext output path

Layer / File(s) Summary
Use the output path variable
locales/build_gettext.sh
generate assigns the output argument to out. The extraction and normalization commands use that variable.

Test fixture formatting

Layer / File(s) Summary
Reformat fixture closures
tests/Unit/HealthWarningsTest.php, tests/Unit/VaultTest.php
Fixture closures use multiline formatting. Their setup, returned paths, and test expectations remain unchanged.

Estimated code review effort: 1 (Trivial) | ~4 minutes

Change: Other

Merge Risk: Minimal · up to ae04d

This change only tidies a shell script and test fixtures to resolve static-analysis findings. It does not change runtime behavior and is low risk to merge.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description gives a clear, detailed account of the changes: SonarQube rule fixes (php:S103, shell:S7679, php:S122), the follow-on SourceRulesTest change, the regenerated cacti.pot, the rules left … Restructure the description to match the template headings: Summary, Issue, Requirements affected, Verification, and Checklist. Under Issue, add 'Refs #38' (or the correct issue number). Under Requirements affected, add requirement IDs or w…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names a real part of the change: it says the PR fixes SonarQube Cloud findings. The changeset fixes 8 of those findings, five shell:S7679 in build_gettext.sh and three php:S122 in test closu…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names a real part of the change: it says the PR fixes SonarQube Cloud findings. The changeset fixes 8 of those findings, five shell:S7679 in build_gettext.sh and three php:S122 in test closures. The title does not say which findings or which rules. It is accurate but broad, so it is a partial match. The title uses the 'chore:' prefix, which is a conventional commit type and not vague wording.

Full details: Description check

Explanation

The description gives a clear, detailed account of the changes: SonarQube rule fixes (php:S103, shell:S7679, php:S122), the follow-on SourceRulesTest change, the regenerated cacti.pot, the rules left unchanged with reasons, and the test results. It does not follow the repository template. It has no '## Issue' section with a Closes or Refs reference (the objectives mention issue #38 only in the commit message), no '## Requirements affected' section, and no checklist. The Verification content is present, but it does not list tool versions for the lint and PHPStan runs. The Summary content is effectively present, but under no template heading.

Resolution

Restructure the description to match the template headings: Summary, Issue, Requirements affected, Verification, and Checklist. Under Issue, add 'Refs #38' (or the correct issue number). Under Requirements affected, add requirement IDs or write 'none'. Under Verification, add tool versions for PHP lint, PHPStan, and the REUSE and gettext checks. Under Checklist, confirm that commits are signed off (git commit -s), state whether docs/PLAN.md and docs/REQUIREMENTS.md changed, and state whether a decision record under docs/decisions/ is needed.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the scripts at dawn,
Then hops through fixtures neatly drawn.
The paths stay put, the tests stay true,
The output flows through out anew.
One soft thump, and review is through.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 430fb82d-d0b1-40a0-8027-90cf01a83e1e
Commits

Reviewing files that changed from the base of the PR and between b3730b1 and ae04d1a.

Files selected for processing: 3

  • locales/build_gettext.sh
  • tests/Unit/HealthWarningsTest.php
  • tests/Unit/VaultTest.php

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@gitar-bot

gitar-bot Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Gitar is working

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

Gitar

SonarQube Cloud's php:S103 flagged 344 lines over 120 characters. They
are wrapped in the existing style: tabs, braces on the same line, one
argument or array element per line, SQL broken at whitespace, and long
literals joined with the same resulting text. A token comparison
against main, folding joined literals, matches for every file but two
interpolated strings, which keep their text.

Seven lines stay long: each is a translated string alone on its line,
and splitting it would change its translation key.

The placeholder rule in SourceRulesTest now allows a line break after
__(, which the wrapping introduced; without it the rule silently
skipped those strings. The translation template is regenerated: the
same strings, in the order the wrapped sources now give.

Refs #38

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@sonarqubecloud

Copy link
Copy Markdown

@somethingwithproof
somethingwithproof merged commit d53d9ad into main Nov 15, 2026
17 checks passed
@somethingwithproof
somethingwithproof deleted the chore/sonar-findings branch November 15, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant