Closed
Conversation
a249bde to
da179ae
Compare
Contributor
Author
|
Agent produced no changes. |
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.
Refs #173
Task prompt (6722 tokens)
Fix Rails/TimeZone — 0 FP, 62 FN
Instructions
You are fixing ONE cop in nitrocop, a Rust Ruby linter that uses Prism for parsing.
Current state: 36,366 matches, 0 false positives, 62 false negatives.
Focus on: FN (RuboCop flags code nitrocop misses).
⚠ 36,366 existing matches must not regress. Validate with
check_cop.pybefore committing.Workflow
behavior on BOTH the specific FP case AND the general pattern:
tests/fixtures/cops/rails/time_zone/offense.rbwith^annotationtests/fixtures/cops/rails/time_zone/no_offense.rbcargo test --lib -- cop::rails::time_zonesrc/cop/rails/time_zone.rscargo test --lib -- cop::rails::time_zone///doc comment on the cop struct documenting what you found and fixedFixture Format
Mark offenses with
^markers on the line AFTER the offending source line.The
^characters must align with the offending columns. The message format isRails/TimeZone: <message text>.See the Current Fixture sections below for real examples from this cop.
If your test passes immediately
If you add a test case and it passes without code changes, the corpus mismatch is
caused by config/context differences, not a detection bug.
Do NOT loop trying to make the test fail. Instead:
src/config/or the cop's config handling, not detection logica
///comment on the cop struct and commitCRITICAL: Avoid regressions in the opposite direction
When fixing FPs, your change MUST NOT suppress legitimate detections. When fixing FNs,
your change MUST NOT flag code that RuboCop accepts. A fix that eliminates a few issues
in one direction but introduces hundreds in the other is a catastrophic regression.
Before exempting a category of patterns, verify with RuboCop that the general case
is still an offense:
If RuboCop flags the general pattern but not your specific case, the difference is in
a narrow context (e.g., enclosing structure, receiver type, argument count) — your fix
must target that specific context, not the broad category.
Rule of thumb: if your fix adds an early
returnorcontinuethat skips a wholenode type, operator class, or naming pattern, it's probably too broad. Prefer adding a
condition that matches the SPECIFIC differentiating context.
Rules
src/cop/rails/time_zone.rsandtests/fixtures/cops/rails/time_zone/cargo test --lib -- cop::rails::time_zoneto verify your fix (do NOT run the full test suite)python3 scripts/check_cop.py Rails/TimeZone --rerun --clone --sample 15before committing to catch regressionsgit stashPrism Notes
{}) and KeywordHashNode (keyword argsfoo(a: 1)). If you handle one, check if you need the other.Foo) and ConstantPathNode (qualifiedFoo::Bar). If you handle one, check if you need the other.Current Fixture: offense.rb
tests/fixtures/cops/rails/time_zone/offense.rbCurrent Fixture: no_offense.rb
tests/fixtures/cops/rails/time_zone/no_offense.rbKey Source Files
src/cop/rails/time_zone.rsvendor/rubocop-rails/lib/rubocop/cop/rails/time_zone.rbvendor/rubocop-rails/spec/rubocop/cop/rails/time_zone_spec.rbRead these files before making changes.
Start Here
Use the existing corpus data to focus on the most concentrated regressions first.
Helpful local commands:
python3 scripts/investigate_cop.py Rails/TimeZone --repos-onlypython3 scripts/investigate_cop.py Rails/TimeZone --contextpython3 scripts/verify_cop_locations.py Rails/TimeZoneTop FN repos:
cjstewart88__Tubalr__f6956c8(14 FN) — exampleheroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/generator/darkfish.rb:316liaoziyang__stackneveroverflow__8f4dce2(14 FN) — examplevendor/bundle/ruby/2.3.0/gems/rdoc-4.3.0/lib/rdoc/generator/darkfish.rb:630pitluga__supply_drop__d64c50c(12 FN) — exampleexamples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/util/autoload/file_cache.rb:58Representative FN examples:
cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/generator/darkfish.rb:316— Do not useTime.parsewithout zone. Use one ofTime.zone.parse,Time.current,Time.parse.in_time_zone,Time.parse.utc,Time.parse.getlocal,Time.parse.xmlschema,Time.parse.iso8601,Time.parse.jisx0301,Time.parse.rfc3339,Time.parse.httpdate,Time.parse.to_i,Time.parse.to_finstead.cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/generator/darkfish.rb:322— Do not useTime.nowwithout zone. Use one ofTime.zone.now,Time.current,Time.now.in_time_zone,Time.now.utc,Time.now.getlocal,Time.now.xmlschema,Time.now.iso8601,Time.now.jisx0301,Time.now.rfc3339,Time.now.httpdate,Time.now.to_i,Time.now.to_finstead.cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/rdoc.rb:186— Do not useTime.parsewithout zone. Use one ofTime.zone.parse,Time.current,Time.parse.in_time_zone,Time.parse.utc,Time.parse.getlocal,Time.parse.xmlschema,Time.parse.iso8601,Time.parse.jisx0301,Time.parse.rfc3339,Time.parse.httpdate,Time.parse.to_i,Time.parse.to_finstead.Pre-diagnostic Results
Diagnosis Summary
Each example was tested by running nitrocop on the extracted source in isolation
with
--force-default-configto determine if the issue is a code bug or config issue.Note: source context is truncated and may not parse perfectly. If a diagnosis
seems wrong (e.g., your test passes immediately for a 'CODE BUG'), treat it as
a config/context issue instead.
FN #1:
cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/generator/darkfish.rb:316NOT DETECTED — CODE BUG
The cop fails to detect this pattern. Fix the detection logic.
Enclosing structure: method body (line:
def get_svninfo klass)The offense is inside this structure — the cop may need
to handle this context to detect the pattern.
Message:
Do not useTime.parsewithout zone. Use one ofTime.zone.parse,Time.current,Time.parse.in_time_zone,Time.parse.utc,Time.parse.getlocal,Time.parse.xmlschema,Time.parse.iso8601,Time.parse.jisx0301,Time.parse.rfc3339,Time.parse.httpdate,Time.parse.to_i,Time.parse.to_finstead.Ready-made test snippet (add to offense.rb, adjust
^count):Full source context:
FN #2:
cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/generator/darkfish.rb:322NOT DETECTED — CODE BUG
The cop fails to detect this pattern. Fix the detection logic.
Enclosing structure: block ({..}) (line:
return {)The offense is inside this structure — the cop may need
to handle this context to detect the pattern.
Message:
Do not useTime.nowwithout zone. Use one ofTime.zone.now,Time.current,Time.now.in_time_zone,Time.now.utc,Time.now.getlocal,Time.now.xmlschema,Time.now.iso8601,Time.now.jisx0301,Time.now.rfc3339,Time.now.httpdate,Time.now.to_i,Time.now.to_finstead.Ready-made test snippet (add to offense.rb, adjust
^count):Full source context:
FN #3:
cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/rdoc.rb:186NOT DETECTED — CODE BUG
The cop fails to detect this pattern. Fix the detection logic.
Enclosing structure: unless branch (line:
unless force then)The offense is inside this structure — the cop may need
to handle this context to detect the pattern.
Message:
Do not useTime.parsewithout zone. Use one ofTime.zone.parse,Time.current,Time.parse.in_time_zone,Time.parse.utc,Time.parse.getlocal,Time.parse.xmlschema,Time.parse.iso8601,Time.parse.jisx0301,Time.parse.rfc3339,Time.parse.httpdate,Time.parse.to_i,Time.parse.to_finstead.Ready-made test snippet (add to offense.rb, adjust
^count):Full source context:
FN #4:
cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/rdoc.rb:190NOT DETECTED — CODE BUG
The cop fails to detect this pattern. Fix the detection logic.
Enclosing structure: block (do..end) (line:
io.each do |line|)The offense is inside this structure — the cop may need
to handle this context to detect the pattern.
Message:
Do not useTime.parsewithout zone. Use one ofTime.zone.parse,Time.current,Time.parse.in_time_zone,Time.parse.utc,Time.parse.getlocal,Time.parse.xmlschema,Time.parse.iso8601,Time.parse.jisx0301,Time.parse.rfc3339,Time.parse.httpdate,Time.parse.to_i,Time.parse.to_finstead.Ready-made test snippet (add to offense.rb, adjust
^count):Full source context:
FN #5:
cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/rdoc.rb:432NOT DETECTED — CODE BUG
The cop fails to detect this pattern. Fix the detection logic.
Message:
Do not useTime.nowwithout zone. Use one ofTime.zone.now,Time.current,Time.now.in_time_zone,Time.now.utc,Time.now.getlocal,Time.now.xmlschema,Time.now.iso8601,Time.now.jisx0301,Time.now.rfc3339,Time.now.httpdate,Time.now.to_i,Time.now.to_finstead.Ready-made test snippet (add to offense.rb, adjust
^count):Full source context:
FN #6:
cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/stats.rb:37NOT DETECTED — CODE BUG
The cop fails to detect this pattern. Fix the detection logic.
Message:
Do not useTime.nowwithout zone. Use one ofTime.zone.now,Time.current,Time.now.in_time_zone,Time.now.utc,Time.now.getlocal,Time.now.xmlschema,Time.now.iso8601,Time.now.jisx0301,Time.now.rfc3339,Time.now.httpdate,Time.now.to_i,Time.now.to_finstead.Ready-made test snippet (add to offense.rb, adjust
^count):Full source context:
FN #7:
cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/stats.rb:408NOT DETECTED — CODE BUG
The cop fails to detect this pattern. Fix the detection logic.
Message:
Do not useTime.nowwithout zone. Use one ofTime.zone.now,Time.current,Time.now.in_time_zone,Time.now.utc,Time.now.getlocal,Time.now.xmlschema,Time.now.iso8601,Time.now.jisx0301,Time.now.rfc3339,Time.now.httpdate,Time.now.to_i,Time.now.to_finstead.Ready-made test snippet (add to offense.rb, adjust
^count):Full source context:
FN #8:
cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.9.4/lib/rdoc/generator/darkfish.rb:316NOT DETECTED — CODE BUG
The cop fails to detect this pattern. Fix the detection logic.
Enclosing structure: method body (line:
def get_svninfo klass)The offense is inside this structure — the cop may need
to handle this context to detect the pattern.
Message:
Do not useTime.parsewithout zone. Use one ofTime.zone.parse,Time.current,Time.parse.in_time_zone,Time.parse.utc,Time.parse.getlocal,Time.parse.xmlschema,Time.parse.iso8601,Time.parse.jisx0301,Time.parse.rfc3339,Time.parse.httpdate,Time.parse.to_i,Time.parse.to_finstead.Ready-made test snippet (add to offense.rb, adjust
^count):Full source context:
Omitted 7 additional diagnosed FN example(s) for brevity.