Skip to content

fix(lint): stop the PlatformIO checker gating on git-ignored files - #3806

Merged
zackees merged 1 commit into
masterfrom
fix/lint-skip-gitignored
Aug 1, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/lint-skip-gitignored

Conversation

@zackees

@zackees zackees commented Aug 1, 2026 •

Copy link
Copy Markdown
Member

bash lint fails on a root tmp.sh — a local debugging scratch script containing pio run -v:

tmp.sh:
  Line 14: [pio_run] Forbidden: `pio run` as build invocation.
❌ PlatformIO-internal-usage: 1 violation(s) (gating).

That file is matched by .gitignore:87 (tmp.*). It cannot be committed and CI never sees it — so the lint fails for something no reviewer will ever look at, and the only way to make it pass is to delete a file belonging to whoever is mid-debug.

Fix

_collect_files() walked the tree pruning only _SKIP_DIRS, with no notion of gitignore. It now asks git check-ignore --stdin once for the whole candidate list and drops what git ignores.

Three details worth keeping:

  • Repo-relative POSIX paths are fed in. check-ignore echoes back exactly the spelling it was given, so feeding the walk's absolute Windows paths made the results unmappable — my first cut silently filtered nothing, and I only caught it because the violation persisted.
  • Fails open. No git, not a checkout, or check-ignore erroring just means a few extra files get scanned — never a missed violation.
  • Uses RunningProcess, not stdlib subprocess, per the ban added in feat(lint): ban stdlib subprocess in favor of RunningProcess; hard-fail the deadlock shape #3792.

Verified both directions

case result
gitignored tmp.sh with pio run -v skipped — no failure
tracked ci/tmp_probe_tracked.sh with pio run -v still caught, exit 1

The second matters more than the first: it would be easy to "fix" this by filtering too aggressively and quietly disabling the checker.

bash lint fully green (all 7 stages).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Updated linting checks to skip files ignored by Git.
    • Improved resilience when Git is unavailable or encounters an error.

`bash lint` failed on a root `tmp.sh` -- a local debugging scratch script
containing `pio run -v`:

    tmp.sh:
      Line 14: [pio_run] Forbidden: `pio run` as build invocation.
    ❌ PlatformIO-internal-usage: 1 violation(s) (gating).

That file is matched by `.gitignore:87` (`tmp.*`). It cannot be committed and
CI never sees it, so gating on it fails the lint for something no reviewer
will ever look at, with no way to fix it other than deleting a file that
belongs to whoever is debugging.

`_collect_files()` walked the tree pruning only `_SKIP_DIRS`, with no notion
of gitignore. It now asks `git check-ignore --stdin` once for the whole
candidate list and drops what git ignores.

Details worth keeping:
  - Repo-relative POSIX paths are fed in, because check-ignore echoes back
    exactly the spelling it was given; feeding the walk's absolute Windows
    paths made the results unmappable and the first cut silently filtered
    nothing.
  - Fails open. No git, not a checkout, or check-ignore erroring just means a
    few extra files get scanned -- never a missed violation.
  - Uses `RunningProcess` rather than stdlib subprocess, per the ban added in
    #3792.

Verified both directions: the ignored `tmp.sh` is now skipped, and a tracked
`ci/tmp_probe_tracked.sh` containing `pio run -v` is still caught and still
exits 1.

`bash lint` fully green.

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The lint file collector now queries Git to identify ignored paths and excludes them from scanning. Git operational errors leave the collected file set unchanged.

Changes

Lint file collection

Layer / File(s) Summary
Git-ignore detection and collection filtering
ci/lint_platformio/run_all_checkers.py
Adds _git_ignored, documents Git-ignored file exclusion, and filters ignored paths from _collect_files.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preventing git-ignored files from gating the PlatformIO lint checker.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/lint-skip-gitignored

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

Comment @coderabbitai help to get the list of available commands.

@zackees
zackees merged commit 28d6f37 into master Aug 1, 2026
10 of 12 checks passed
@zackees
zackees deleted the fix/lint-skip-gitignored branch August 1, 2026 05:32
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Aug 1, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (2)
ci/lint_platformio/run_all_checkers.py (2)

162-164: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use an explicit loop for the new filter.

Line [164] adds a list comprehension. Build a named output list with an explicit loop and preserve the current sorted order.

As per coding guidelines, Python code must use explicit loops instead of list comprehensions for clarity and debuggability.

Proposed refactor
     ignored = _git_ignored(root, files)
     if ignored:
-        files = [f for f in files if f not in ignored]
+        filtered_files: list[str] = []
+        for file_path in files:
+            if file_path not in ignored:
+                filtered_files.append(file_path)
+        files = filtered_files
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ci/lint_platformio/run_all_checkers.py` around lines 162 - 164, Replace the
list comprehension in the ignored-file filtering block with a named output list
and an explicit loop that appends each file not present in ignored. Preserve the
existing sorted order and assign the accumulated list back to files.

Source: Coding guidelines


105-106: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Move required imports to the module import block.

running-process is declared in pyproject.toml, so from running_process import RunningProcess belongs at the top with the third-party imports. Move handle_keyboard_interrupt from the KeyboardInterrupt handler to the local-import section under from ci.util.check_files import.... Keep the exception handler empty-body-style or add one statement and remove # noqa: PLC0415 - lazy.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ci/lint_platformio/run_all_checkers.py` around lines 105 - 106, Move
RunningProcess from the lazy import inside the try block to the module-level
third-party import section, removing the PLC0415 suppression. Move
handle_keyboard_interrupt from the KeyboardInterrupt handler into the
local-import section below ci.util.check_files, then leave the handler with an
empty-body style or a single statement.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ci/lint_platformio/run_all_checkers.py`:
- Around line 142-150: Update the _collect_files docstring to qualify
Git-ignored file exclusion as best effort, explicitly noting that when Git is
unavailable or _git_ignored() fails and returns an empty set, those files are
retained.
- Around line 105-120: Update the git check-ignore handling around
RunningProcess.run to inspect result.returncode before filtering stdout,
returning an empty set for every status except Git’s expected no-match status.
Narrow the surrounding broad exception handling while preserving separate
KeyboardInterrupt handling, and keep the fail-open behavior for unexpected
failures.
- Around line 92-101: Update the path-mapping and Git ignore-checking flow
around rel_to_abs to use NUL-delimited input and output with git 4check-ignore
--stdin -z, parsing records without splitlines() or strip() so filenames
containing newlines or surrounding whitespace remain unchanged. Replace
unconditional backslash normalization with platform-specific separator
normalization only where required, preserving valid POSIX backslashes and
ensuring returned paths still map to the absolute paths collected by the walk.

---

Nitpick comments:
In `@ci/lint_platformio/run_all_checkers.py`:
- Around line 162-164: Replace the list comprehension in the ignored-file
filtering block with a named output list and an explicit loop that appends each
file not present in ignored. Preserve the existing sorted order and assign the
accumulated list back to files.
- Around line 105-106: Move RunningProcess from the lazy import inside the try
block to the module-level third-party import section, removing the PLC0415
suppression. Move handle_keyboard_interrupt from the KeyboardInterrupt handler
into the local-import section below ci.util.check_files, then leave the handler
with an empty-body style or a single statement.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 372f884b-0864-407d-94d8-44c5b972964f

📥 Commits

Reviewing files that changed from the base of the PR and between 33b4b6c and a641f36.

📒 Files selected for processing (1)
  • ci/lint_platformio/run_all_checkers.py

Comment on lines +92 to +101
# Feed repo-relative POSIX paths: git echoes back exactly the spelling it
# was given, so anything else makes the returned names impossible to map
# onto the absolute paths the walk produced.
rel_to_abs: dict[str, str] = {}
for absolute in paths:
try:
rel = os.path.relpath(absolute, root).replace("\\", "/")
except ValueError:
continue # different drive on Windows; cannot be repo-relative
rel_to_abs[rel] = absolute

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
git -C "$tmp" init -q
printf '%s\n' '*.sh' >"$tmp/.gitignore"
touch "$tmp/ leading.sh" "$tmp/trailing.sh " "$tmp/back\\slash.sh"

printf '%s\0' ' leading.sh' 'trailing.sh ' 'back\slash.sh' |
  git -C "$tmp" check-ignore --stdin -z |
  od -An -tc

Repository: FastLED/FastLED

Length of output: 194


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate file =="
fd -a 'run_all_checkers\.py$' . || true
echo "== git status =="
git status --short
echo "== file excerpt =="
sed -n '1,180p' ci/lint_platformio/run_all_checkers.py

Repository: FastLED/FastLED

Length of output: 5891


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Python availability/source tools =="
uv run python --version || echo "uv unavailable"
python3 --version || true

echo "== simulate newline-delimited path protocol edge cases =="
uv run python3 <<'PY'
import os
paths = [
    "/tmp/a leading.sh",
    "/tmp/trailing.sh ",
    "/tmp/back\\slash.sh",
    "/tmp/contains\nnewline.sh",
]
root = "/tmp"
rel_to_abs = {}
for absolute in paths:
    try:
        rel = os.path.relpath(absolute, root).replace("\\", "/")
    except ValueError:
        continue
    rel_to_abs[rel] = absolute

git_echoes = "\n".join(paths) + "\n"
ignored = set()
for line in git_echoes.splitlines():
    rel = line.strip().replace("\\", "/")
    if rel in rel_to_abs:
        ignored.add(rel_to_abs[rel])

print("total_paths", len(paths))
print("ignored_count", len(ignored))
print("remaining", sorted(rel_to_abs[rel] for rel in rel_to_abs if rel_to_abs[rel] not in ignored))
for p in paths:
    print(p.startswith("/") and p.endswith("/bin/sh") and bool(match))
PY

echo "== simulate NUL-delimited path protocol edge cases =="
uv run python3 <<'PY'
import os
paths = [
    "/tmp/a leading.sh",
    "/tmp/trailing.sh ",
    "/tmp/back\\slash.sh",
    "/tmp/contains\nnewline.sh",
]
root = "/tmp"
rel_to_abs = {}
for absolute in paths:
    try:
        rel = os.path.relpath(absolute, root)
        if os.path.sep == "\\":
            rel = rel.replace("\\", "/")
    except ValueError:
        continue
    rel_to_abs[rel] = absolute

git_echoes = "".join(p + "\0" for p in paths)
ignored = set()
for rel in git_echoes.split("\0"):
    if not rel:
        continue
    if rel in rel_to_abs:
        ignored.add(rel_to_abs[rel])

print("total_paths", len(paths))
print("ignored_count", len(ignored))
print("remaining", sorted(rel_to_abs[rel] for rel in rel_to_abs if rel_to_abs[rel] not in ignored))
PY

echo "== deterministic path string effects =="
uv run python3 <<'PY'
import os
print("current_sep=", repr(os.pathsep), "pathsep")
sample = r"back\slash.sh leading.sh trailing.sh "
print("replace_all_slash=", sample.strip().replace("\\", "/"))
sep = os.path.sep
print("sep=", repr(sep))
normalized = sample.strip()
if sep == "\\":
    normalized = normalized.replace("\\", "/")
print("conditional_slash=", normalized)
PY

Repository: FastLED/FastLED

Length of output: 355


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== simulate newline-delimited path protocol edge cases =="
python3 <<'PY'
import os
paths = [
    "/tmp/a leading.sh",
    "/tmp/trailing.sh ",
    "/tmp/back\\slash.sh",
    "/tmp/contains\nnewline.sh",
]
root = "/tmp"
rel_to_abs = {}
for absolute in paths:
    try:
        rel = os.path.relpath(absolute, root).replace("\\", "/")
    except ValueError:
        continue
    rel_to_abs[rel] = absolute

git_echoes = "\n".join(paths) + "\n"
ignored = set()
for line in git_echoes.splitlines():
    rel = line.strip().replace("\\", "/")
    if rel in rel_to_abs:
        ignored.add(rel_to_abs[rel])

print("total_paths", len(paths))
print("ignored_count", len(ignored))
print("remaining", sorted(rel_to_abs[rel] for rel in rel_to_abs if rel_to_abs[rel] not in ignored))
for p in paths:
    print(p.startswith("/") and p.endswith("/bin/sh") and bool(match))
PY

echo "== simulate NUL-delimited path protocol edge cases =="
python3 <<'PY'
import os
paths = [
    "/tmp/a leading.sh",
    "/tmp/trailing.sh ",
    "/tmp/back\\slash.sh",
    "/tmp/contains\nnewline.sh",
]
root = "/tmp"
rel_to_abs = {}
for absolute in paths:
    try:
        rel = os.path.relpath(absolute, root)
        if os.path.sep == "\\":
            rel = rel.replace("\\", "/")
    except ValueError:
        continue
    rel_to_abs[rel] = absolute

git_echoes = "".join(p + "\0" for p in paths)
ignored = set()
for rel in git_echoes.split("\0"):
    if not rel:
        continue
    if rel in rel_to_abs:
        ignored.add(rel_to_abs[rel])

print("total_paths", len(paths))
print("ignored_count", len(ignored))
print("remaining", sorted(rel_to_abs[rel] for rel in rel_to_abs if rel_to_abs[rel] not in ignored))
PY

echo "== deterministic path string effects =="
python3 <<'PY'
import os
sample = r"back\slash.sh leading.sh trailing.sh "
print("strip_replace=", sample.strip().replace("\\", "/"))
sep = os.path.sep
normalized = sample.strip()
if sep == "\\":
    normalized = normalized.replace("\\", "/")
print("conditional_replace=", normalized)
PY

echo "== check git availability =="
hash git || true
git --version || true

echo "== deterministic git check-ignore probe if available =="
if hash git >/dev/null 2>&1; then
  tmp="$(mktemp -d)"
  trap 'rm -rf "$tmp"' EXIT
  cd "$tmp"
  git init -q
  printf '%s\n' '*.sh' > .gitignore
  touch "$tmp/ leading.sh" "$tmp/trailing.sh " "$tmp/back\\slash.sh"
  printf '%s\0' ' leading.sh' 'trailing.sh ' 'back\slash.sh' |
    git check-ignore --stdin -z |
    xargs -0 printf '<%s>\n' || true
fi

Repository: FastLED/FastLED

Length of output: 854


🏁 Script executed:

#!/bin/bash
set -euo pipefail

tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
cd "$tmp"

git init -q
printf '%s\n' '*.sh' > .gitignore

for name in " leading.sh" "trailing.sh " "back\\slash.sh"; do
  printf '%s' "$(printf '%s' "$name" | od -An -tc)"
done
echo

echo "== quote-ignore probe =="
printf '%s\0' ' leading.sh' 'trailing.sh ' 'back\slash.sh' |
  git check-ignore --stdin -z > out
printf 'bytes=%d\n' "$(wc -c < out)"
python3 - <<'PY'
import sys, os
data = open("out", "rb").read()
for segment in data.split(b"\0"):
    print(repr(segment.decode()))
PY

echo "== default ignore probe =="
printf '%s\n' ' leading.sh' 'trailing.sh ' 'back\\slash.sh' |
  git check-ignore --stdin > out2
wc -c < out2
sed -n '1,10p' out2

Repository: FastLED/FastLED

Length of output: 394


Use a lossless Git path protocol.

The newline/splitlines() round trip cannot carry filenames containing newlines, and strip() changes filenames with leading or trailing whitespace. The unconditional backslash replacement can rename valid POSIX paths such as back\slash.sh. Pass NUL-delimited input to git 4check-ignore --stdin -z, parse NUL-delimited output, and only normalize separators on platforms that require it.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ci/lint_platformio/run_all_checkers.py` around lines 92 - 101, Update the
path-mapping and Git ignore-checking flow around rel_to_abs to use NUL-delimited
input and output with git 4check-ignore --stdin -z, parsing records without
splitlines() or strip() so filenames containing newlines or surrounding
whitespace remain unchanged. Replace unconditional backslash normalization with
platform-specific separator normalization only where required, preserving valid
POSIX backslashes and ensuring returned paths still map to the absolute paths
collected by the walk.

Comment on lines +105 to +120
try:
from running_process import RunningProcess # noqa: PLC0415 - lazy

# `git check-ignore --stdin` echoes back only the ignored paths and
# exits 1 when none match, so check=False.
result = RunningProcess.run(
["git", "check-ignore", "--stdin"],
input="\n".join(rel_to_abs) + "\n",
capture_output=True,
text=True,
encoding="utf-8",
errors="replace",
cwd=str(root),
check=False,
timeout=60,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
git -C "$tmp" init -q

set +e
printf '%s\n' missing.sh | git -C "$tmp" check-ignore --stdin >/dev/null
no_match=$?
printf '%s\n' missing.sh | git -C "$tmp/not-a-repo" check-ignore --stdin >/dev/null
command_error=$?
set -e

test "$no_match" -eq 1
test "$command_error" -ne 0
rg -n -C 4 'RunningProcess\.run|check=False|returncode' ci/lint_platformio/run_all_checkers.py

Repository: FastLED/FastLED

Length of output: 971


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== file excerpt =="
sed -n '80,145p' ci/lint_platformio/run_all_checkers.py | cat -n -v

echo
echo "== locate running_process =="
fd -a 'running_process.py' . | sed 's#^\./##'

echo
echo "== RunningProcess implementation excerpt =="
f="$(fd 'running_process.py' . | head -n 1)"
if [ -n "${f:-}" ]; then
  wc -l "$f"
  sed -n '1,180p' "$f" | cat -n -v
fi

echo
echo "== usages of _git_ignored and filtered files =="
rg -n '_git_ignored|_collect_files|check=False|RunningProcess\.run' ci/lint_platformio/run_all_checkers.py

Repository: FastLED/FastLED

Length of output: 10040


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate actual running_process.py =="
git ls-files '*running_process*' | sed -n '1,20p'

echo
echo "== RunProcess import and definition outline =="
ast-grep outline ci/util/running_process.py --view expanded 2>/dev/null || true

echo
echo "== RunningProcess.run definition =="
rg -n -C 8 'class RunningProcess|def run\(' ci/util/running_process.py | sed -n '1,220p'

echo
echo "== process result/status usages in ci/util/running_process.py =="
rg -n 'stdout|returncode|wait\(|check' ci/util/running_process.py | sed -n '1,140p'

echo
echo "== changed diff context =="
git diff -- ci/lint_platformio/run_all_platformio.py ci/lint_platformio/run_all_checkers.py 2>/dev/null | sed -n '1,220p' || git diff -- ci/lint_platformio/run_all_checkers.py | sed -n '1,220p'

Repository: FastLED/FastLED

Length of output: 517


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== repo root files likely named running_process =="
git ls-files | grep -E '(^|/)running_process[^/]*\.(py|pyi)$|running_process' | sed -n '1,80p'

echo
echo "== search RunningProcess.run occurrences =="
rg -n 'class RunningProcess|^\s*def run\(|RunningProcess\.run|`@staticmethod`|`@classmethod`' -g '*py*' -g '*pyi*' . | sed -n '1,220p'

echo
echo "== import resolution hints =="
rg -n 'from running_process import|import running_process' -g '*py' ci . | sed -n '1,120p'

Repository: FastLED/FastLED

Length of output: 15359


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
import importlib.util
import sys
from pathlib import Path

# Use local ci runner, but do not import normal repo top-levels.
# Print module search paths and whether running_process can be resolved
# without running repository code.
print("cwd=", Path.cwd(), file=sys.stderr)
print("sys.path examples=", sys.path[:3], file=sys.stderr)

try:
    spec = importlib.util.find_spec("running_process")
    print("running_process_spec_found=", bool(spec), file=sys.stderr)
    if spec:
        print("running_process_origin=", getattr(spec, "origin", None), file=sys.stderr)
except Exception as exc:
    print("running_process_spec_error=", type(exc).__name__, str(exc), file=sys.stderr)
PY

Repository: FastLED/FastLED

Length of output: 286


Check Git result status before filtering.

RunningProcess.run(..., check=False) can return a non-zero result instead of raising. This code parses stdout without checking that result, so partial Git output can remove only part of files and violate the fail-open contract. Check result.returncode and return an empty set for any status other than Git’s normal no-match status. Also narrow the broad except Exception; keep KeyboardInterrupt handling separately.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ci/lint_platformio/run_all_checkers.py` around lines 105 - 120, Update the
git check-ignore handling around RunningProcess.run to inspect result.returncode
before filtering stdout, returning an empty set for every status except Git’s
expected no-match status. Narrow the surrounding broad exception handling while
preserving separate KeyboardInterrupt handling, and keep the fail-open behavior
for unexpected failures.

Source: Linters/SAST tools

Comment on lines 142 to +150
def _collect_files(root: Path) -> list[str]:
"""Walk the repo and collect files of interest, pruning skip dirs."""
"""Walk the repo and collect files of interest, pruning skip dirs.

Git-ignored files are excluded. They cannot reach CI -- a developer's
local scratch script is not repository content -- so gating on them just
fails `bash lint` for something the reviewer will never see. This bit
people with a root `tmp.sh` containing `pio run -v`: ignored by
.gitignore, invisible to CI, and yet a hard lint failure locally.
"""

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Document the fail-open condition.

The docstring states that Git-ignored files are excluded. When Git is unavailable or errors, _git_ignored() returns an empty set and _collect_files() keeps those files. Qualify this behavior as best effort.

Proposed wording
-    Git-ignored files are excluded. They cannot reach CI -- a developer's
+    Git-ignored files are excluded when Git succeeds. If Git is unavailable,
+    the collected file set remains unchanged. A developer's
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def _collect_files(root: Path) -> list[str]:
"""Walk the repo and collect files of interest, pruning skip dirs."""
"""Walk the repo and collect files of interest, pruning skip dirs.
Git-ignored files are excluded. They cannot reach CI -- a developer's
local scratch script is not repository content -- so gating on them just
fails `bash lint` for something the reviewer will never see. This bit
people with a root `tmp.sh` containing `pio run -v`: ignored by
.gitignore, invisible to CI, and yet a hard lint failure locally.
"""
def _collect_files(root: Path) -> list[str]:
"""Walk the repo and collect files of interest, pruning skip dirs.
Git-ignored files are excluded when Git succeeds. If Git is unavailable,
the collected file set remains unchanged. A developer's local scratch
script is not repository content -- a developer's local scratch script
is not repository content -- so gating on them just fails `bash lint` for
something the reviewer will never see. This bit people with a root
`tmp.sh` containing `pio run -v`: ignored by `.gitignore`, invisible to CI,
and yet a hard lint failure locally.
"""
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ci/lint_platformio/run_all_checkers.py` around lines 142 - 150, Update the
_collect_files docstring to qualify Git-ignored file exclusion as best effort,
explicitly noting that when Git is unavailable or _git_ignored() fails and
returns an empty set, those files are retained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant