Add the AGENTS.md details that cost time to rediscover - #1120
Open
tas50 wants to merge 1 commit into
Open
Conversation
AGENTS.md points at DEVELOPER_GUIDE.md and WRITING_RULES.md rather than duplicating them, which is right, but a few things aren't in any of the three and are the kind of thing you only find by hitting them. - A cop's name comes from its module nesting, not its file path. The guides write the path as `<department>`, which is accurate for six of the eight directories and wrong for `deprecation/` (Chef/Deprecations) and `redundant/` (Chef/RedundantCode). Added the mapping table, including the chefstyle tree, whose cops are named Chef/Ruby and validate against config/chefstyle.yml. - `rake generate_cops_yml_documentation` is not idempotent on current Ruby. Psych 5.3 stopped emitting a trailing space after empty `examples:` and `version_added:` keys, so the task rewrites 12 files that predate the change and belong to nobody's PR. Documented rather than regenerated, since the fix is a whitespace-only commit across the generated tree. - CI runs linelint over every file; `rake style` only inspects Ruby. A YAML or Markdown file missing its trailing newline passes locally and fails on the PR. - The negative-case requirement is enforced by a repo-wide spec, so it fails as a list of paths rather than in the spec you just wrote. Named the file. - Chef/Effortless is slated for removal, so new cops shouldn't go there. - Labels can't be applied from a fork; `gh pr create --label` opens the PR and then fails on AddLabelsToLabelable, which reads like the PR failed too. Verified: `bundle exec rake` exits 0 (1239 examples, 0 failures; the 11 refactor-severity offenses are pre-existing on main and unchanged here). Every claim was checked against the tree rather than inferred, and AGENTS.md ends in a single newline for linelint. Signed-off-by: Tim Smith <tsmith84@proton.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AGENTS.md deliberately points at DEVELOPER_GUIDE.md and WRITING_RULES.md instead of duplicating them. This adds only the things that are in none of the three and that you find by hitting them.
What was added
A cop's name comes from its module nesting, not its file path.
rake validate_configwalks the constants underRuboCop::Cop::Chef, so the directory is convention. The guides write the path as<department>, which holds for six of the eight directories and not for these:lib/rubocop/cop/chef/deprecation/Chef/Deprecationslib/rubocop/cop/chef/redundant/Chef/RedundantCodelib/rubocop/cop/inspec/deprecation/InSpec/Deprecationslib/rubocop/cop/chefstyle/ruby/Chef/Ruby, validated againstconfig/chefstyle.ymlrake generate_cops_yml_documentationis not idempotent on current Ruby. On a clean checkout it rewrites 12 files with whitespace-only changes: Psych 5.3 stopped emitting a trailing space after an emptyexamples:orversion_added:key, and those files were generated before that. An agent following the documented "run this after adding a cop" step gets 12 files of churn mixed into their diff. Documented with a way out (git checkout -- docs-chef-io/after staging your own file) rather than fixed, since regenerating is a whitespace-only commit across the generated tree — happy to send that separately if wanted.CI runs linelint over every file,
rake styleonly over Ruby.Layout/TrailingEmptyLinescovers.rb, but aconfig/cookstyle.ymlentry or a Markdown file missing its trailing newline passesrakeand fails on the PR.Smaller ones: the negative-case rule is enforced by
spec/negative_case_coverage_spec.rb, so it fails as a repo-wide list of paths rather than in your own spec;Chef/Effortlessis slated for removal so new cops shouldn't go there; and new cop files need norequire, sincelib/cookstyle.rbglobs the tree.Labels can't be applied from a fork.
gh pr create --labelopens the PR and then fails onAddLabelsToLabelable, which reads like the whole command failed and invites a retry that would open a second PR.Verification
bundle exec rakeexits 0 — 1239 examples, 0 failures;validate_configclean. The 11 refactor-severity offensesrake stylereports are pre-existing onmain(identical with this change stashed) and don't affect the exit code.cookstyle --list-target-filesreturns 0 Markdown/YAML files out of 567.AGENTS.mdends in exactly one newline.Labels
I don't have write access, so I couldn't apply these:
Aspect: Documentation,Expeditor: Skip All.Unrelated things noticed, not touched
Per the Scope section of AGENTS.md, flagging rather than fixing:
tasks/prof.rake:14—Rake::Task[:run]is a global lookup, not namespaced, sorake prof:slow_copsandrake prof:walkabort withDon't know how to build task 'run'. Should beRake::Task['prof:run']. DEVELOPER_GUIDE.md documents both as working.Rakefile— the RSpec task setsspec.pattern = FileList['spec/cop/**/*.rb'], but specs live inspec/rubocop/cop/. It is inert today: the empty FileList makesRSpec::Core::RakeTaskomit--pattern, so rspec falls back tospec/and runs everything. Worth knowing that a naive fix tospec/rubocop/cop/**/*_spec.rbwould silently dropspec/negative_case_coverage_spec.rb.cookstyle.gemspec—required_ruby_version = '>= 2.7'while CI tests 3.1, 3.4, and 4.0.