Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions .github/scripts/validate-services-catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,14 @@ def error(errors, service, message)
end

depends_on = service.fetch("depends_on", [])
unless depends_on.is_a?(Array)
error(errors, name, "depends_on must be a list when present")
next
end

depends_on.each do |dependency|
unless services.key?(dependency)
error(errors, name, "depends_on references unknown service #{dependency.inspect}")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ruby unless...else is a readability anti-pattern

Low Severity

The unless...else construct at the depends_on type check is a universally discouraged Ruby anti-pattern (flagged by RuboCop's Style/UnlessElse rule). It forces the reader to mentally double-negate: "unless it's an array → error; else → iterate." Flipping to if depends_on.is_a?(Array) with the branches swapped is clearer and idiomatic.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3b38b5c. Configure here.

if depends_on.is_a?(Array)
depends_on.each do |dependency|
unless services.key?(dependency)
error(errors, name, "depends_on references unknown service #{dependency.inspect}")
end
end
else
error(errors, name, "depends_on must be a list when present")
end

next unless service.key?("proto_consumer")
Expand Down
11 changes: 10 additions & 1 deletion .github/workflow-templates/codex-label-churn-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@ jobs:
gh api "repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/events" --paginate
echo
echo "# Workflows that mention labels"
rg -n "add-label|remove-label|gh pr edit|issues.addLabels|issues.removeLabel|labels" .github/workflows scripts || true
search_paths=()
for path in .github/workflows scripts; do
if [ -e "${path}" ]; then
search_paths+=("${path}")
fi
done

if [ "${#search_paths[@]}" -gt 0 ]; then
grep -RInE "add-label|remove-label|gh pr edit|issues.addLabels|issues.removeLabel|labels" "${search_paths[@]}" || true
fi
} > codex-label-churn-evidence.md

- name: Run Codex label audit
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codex-rails-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ jobs:
run: |
set -euo pipefail
shopt -s globstar nullglob
tests=(test/**/*_test.rb test/*_test.rb)
tests=(test/**/*_test.rb)
if [ "${#tests[@]}" -eq 0 ]; then
echo "No Ruby tests found."
exit 0
Expand Down
12 changes: 12 additions & 0 deletions test/validate_services_catalog_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ def test_invalid_enum_values_fail
assert_match(/identity: runtime must be one of gke, none, standalone/, stderr)
end

def test_proto_consumer_is_validated_even_when_depends_on_type_is_invalid
catalog = minimal_catalog
catalog["services"]["identity"]["depends_on"] = "proto"
catalog["services"]["identity"]["proto_consumer"] = "yes"

stdout, stderr, status = run_validator(catalog)

refute status.success?, stdout
assert_match(/identity: depends_on must be a list when present/, stderr)
assert_match(/identity: proto_consumer must be true or false when present/, stderr)
end

private

def run_validator(catalog)
Expand Down
Loading