CopSource target Ruby version depends on the current directory #1226
Labels
No labels
P0
P1
P2
P3
bug
category/code-change
category/cross-repo
category/eval-run
category/investigation
category/no-test-target
category/owner-ruling
category/prose-artifact
category/recurring-chore
category/structure
category/umbrella
crc-refactor
create
delete
enhancement
filed-by/agent
filed-by/user
frozen
lint-rule
needs-info
needs-triage
next
plugin/cc-architect
plugin/os
plugin/os-adr
plugin/os-aidd-lint
plugin/os-backlog
plugin/os-context
plugin/os-doc-hygiene
plugin/os-sdlc
plugin/os-vault
project/cc-os
ready-for-agent
ready-for-human
recurring
review
rule-proposal
update
waiting
wayfinder:grilling
wayfinder:map
wayfinder:map
wayfinder:research
wayfinder:task
wayfinder:task
wontfix
worklist/deviations
worklist/lint-rule
worklist/new-implement-build
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
jared/cc-os#1226
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
OsSdlc::CopSource.target_version(plugins/os-sdlc/lib/os_sdlc/cop_source.rb:11) reads the Ruby version from the current directory when the path has no RuboCop config. RuboCop then defaults to 2.7. Ruby 2.7 cannot parse endless defs. Cop tests with tmpdir fixtures become flaky (seen in fast-batch-5, UnusedPrivateMethodTest).Reproduce
ruby -I plugins/os-sdlc/lib -e 'require "os_sdlc"; p OsSdlc::CopSource.target_version("/tmp/x.rb")'— run it once from/tmpand once fromplugins/os-sdlc. The values differ by directory.Approach
Fix the version for paths with no config.
cop_source.rb:11stays the one place that picks the version. When no config file applies to the path, return one fixed version (the plugin's own TargetRubyVersion). Never read it from the current directory.Required work:
Dir.pwdinplugins/os-sdlc/lib/os_sdlc/cop_source.rbAcceptance criteria
CopSource.target_versionruns from any directory, then it returns the same version.CopSource.parseruns from any directory, then it parses without error.CopSource.target_versionruns, then it returns the version from that config.Owner sketch
Origin
VERDICT: CREATE
Occurrence: seen again in fast-batch-15 finding B (commit
2fea2e8a, parent #1330).Occurrence: Read the target Ruby version from the target root in Detector::CopSites
Seen: plugins/os-sdlc/lib/os_sdlc/detector (CopSites line 26 calls CopSource.target_version)
Run: Session 6c6b6eae-4ebd-4ac4-9b32-535875a6b39b, fast-batch-15 ruling R2
Adds: in-process, RuboCop memoizes the suite cwd (PathUtil.pwd, ConfigFinder.project_root), so CopSites returns an empty cop cell with no error. DetectorHoldersBinTest keeps one Open3 run with a constraint comment (
2fea2e8a) until this is fixed; remove that run when it is.jared referenced this issue2026-10-26 22:19:22 +00:00
jared referenced this issue2026-11-07 18:59:04 +00:00
Occurrence: Parse files that cops read with the running cop's Ruby version, not the working directory's
Seen: plugins/os-sdlc/lib/os_sdlc/cops/structural/cop_source.rb (CopSource.from_file, CopSource.target_version)
Run: Session 3f3909e3-ad19-4d05-8792-564a9aa15708 (#1669 diagnosis)
Adds: Probe numbers. From the cc-os root, target_version(nil) gives 2.7 (TargetRuby::Default), and parse("module T\n def self.f = 1\nend\n") gives valid=false, ast=nil (unexpected token tEQL). From plugins/os-sdlc it gives 4.0 (TargetRuby::BundlerLockFile) and a valid AST. 12 cop tests in #1669 fail from the cc-os root for this reason. #1669 pins the version in test fixtures only. A file read through from_file (AdapterBuiltOutsideEntry::AdapterConstant.scanned) in a project with no .rubocop.yml is still parsed with the working directory's version.