Skip to content

[bot] Fix Rails/TimeZone#211

Closed
6[bot] wants to merge 1 commit intomainfrom
fix/rails-time_zone-23575949147
Closed

[bot] Fix Rails/TimeZone#211
6[bot] wants to merge 1 commit intomainfrom
fix/rails-time_zone-23575949147

Conversation

@6
Copy link
Copy Markdown
Contributor

@6 6 bot commented Mar 26, 2026

Status: Agent is working on this fix...

Cop: Rails/TimeZone | Backend: codex / hard | Model: gpt-5.4 (xhigh) | Mode: fix
Code bugs: 9 | Run: https://github.com/6/nitrocop/actions/runs/23575949147

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.py before committing.

Workflow

  1. Read the Pre-diagnostic Results and Corpus FP/FN Examples sections below first
  2. Verify with RuboCop first (for FP fixes): before writing any code, confirm RuboCop's
    behavior on BOTH the specific FP case AND the general pattern:
    echo '<specific FP case>' > /tmp/test.rb && rubocop --only Rails/TimeZone /tmp/test.rb
    echo '<general pattern>' > /tmp/test.rb && rubocop --only Rails/TimeZone /tmp/test.rb
    If RuboCop flags the general pattern, your fix must be narrow enough to not suppress it.
  3. Add a test case FIRST:
    • FN fix: add the missed pattern to tests/fixtures/cops/rails/time_zone/offense.rb with ^ annotation
    • FP fix: add the false-positive pattern to tests/fixtures/cops/rails/time_zone/no_offense.rb
  4. Verify test fails: cargo test --lib -- cop::rails::time_zone
  5. Fix src/cop/rails/time_zone.rs
  6. Verify test passes: cargo test --lib -- cop::rails::time_zone
  7. Validate against corpus (REQUIRED before committing):
    python3 scripts/check_cop.py Rails/TimeZone --rerun --clone --sample 15
    If this reports FP or FN regression, your fix is too broad — narrow it down.
  8. Add a /// doc comment on the cop struct documenting what you found and fixed
  9. Commit only your cop's files

Fixture Format

Mark offenses with ^ markers on the line AFTER the offending source line.
The ^ characters must align with the offending columns. The message format is Rails/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:

  1. Investigate config resolution (Include/Exclude, cop enablement, disable comments)
  2. The fix is likely in src/config/ or the cop's config handling, not detection logic
  3. If you cannot determine the root cause within 5 minutes, document your findings as
    a /// comment on the cop struct and commit

CRITICAL: 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:

rubocop --only Rails/TimeZone /tmp/test.rb

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 return or continue that skips a whole
node type, operator class, or naming pattern, it's probably too broad. Prefer adding a
condition that matches the SPECIFIC differentiating context.

Rules

  • Only modify src/cop/rails/time_zone.rs and tests/fixtures/cops/rails/time_zone/
  • Run cargo test --lib -- cop::rails::time_zone to verify your fix (do NOT run the full test suite)
  • Run python3 scripts/check_cop.py Rails/TimeZone --rerun --clone --sample 15 before committing to catch regressions
  • Do NOT touch unrelated files
  • Do NOT use git stash

Prism Notes

  • hash splits into HashNode (literal {}) and KeywordHashNode (keyword args foo(a: 1)). If you handle one, check if you need the other.
  • const splits into ConstantReadNode (simple Foo) and ConstantPathNode (qualified Foo::Bar). If you handle one, check if you need the other.

Current Fixture: offense.rb

tests/fixtures/cops/rails/time_zone/offense.rb

# String#to_time without timezone specifier — bad in flexible mode (default)
"2012-03-02 16:05:37".to_time
                      ^^^^^^^ Rails/TimeZone: Do not use `String#to_time` without zone. Use `Time.zone.parse` instead.

"2005-02-27 23:50".to_time
                   ^^^^^^^ Rails/TimeZone: Do not use `String#to_time` without zone. Use `Time.zone.parse` instead.

Time.now
     ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

x = Time.now
         ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

if Time.now > deadline
        ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.
  puts "expired"
end

::Time.now
       ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

Time.now.getutc
     ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

# .localtime without arguments is NOT safe — RuboCop flags MSG_LOCALTIME
Time.at(time).localtime
     ^^ Rails/TimeZone: Use `Time.zone.at` instead of `Time.at`.

Time.at(@time).localtime.to_s
     ^^ Rails/TimeZone: Use `Time.zone.at` instead of `Time.at`.

Time.now.localtime
     ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

# Grouping parentheses — NOT method call parens, should still flag
(Time.now - 1.day).to_i
      ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

(first_seen_at || Time.now).to_i.to_s
                       ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

(Time.now - 7200).to_i
      ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

(Time.now - seconds).to_i
      ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

return (Time.now - 1.day).to_i if expired?
             ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

# utc? is a query method, NOT the same as .utc — should still flag
Time.now.utc?
     ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

Time.at(x).utc?
     ^^ Rails/TimeZone: Use `Time.zone.at` instead of `Time.at`.

Time.now.gmtime.utc?
     ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

# Time.now inside Time.at(..., in:) — the in: makes the OUTER call safe,
# but the inner Time.now still needs timezone awareness
Time.at(Time.now, in: 'UTC')
             ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

Time.at(Time.now, in: 'Z')
             ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

Time.at(Time.now, in: '-00:00')
             ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

# Grouping parens with space between method name and ( — the .to_f is on the
# grouped expression, NOT the enclosing call, so should still flag
schedule (Time.now - 60).to_f, arg2
               ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

expect(val).to eq (Time.now + 7.days).to_i
                        ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

# Grouping paren inside method call: begin node breaks chain in RuboCop AST
# (Time.now - 3600) creates a begin node, stopping the chain walk at .httpdate
Time.httpdate((Time.now - 3600).httpdate)
                    ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

# String interpolation: literal parens in string text are not Ruby method calls
"tolerance zone (#{Time.at(ts)})"
                        ^^ Rails/TimeZone: Use `Time.zone.at` instead of `Time.at`.

# Safe navigation &. breaks chain — RuboCop's send_type? excludes csend
Time.at(val)&.utc
     ^^ Rails/TimeZone: Use `Time.zone.at` instead of `Time.at`.

Time.now&.to_i
     ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

# Non-Time receiver in enclosing call — chain doesn't trace to Time
foo(Time.now).in_time_zone
         ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

bar(Time.local(2023, 1, 1)).to_i
         ^^^^^ Rails/TimeZone: Use `Time.zone.local` instead of `Time.local`.

wrap(Time.now).zone
          ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

ActiveSupport::Duration.build(params.to_time - Time.now).seconds.to_i
                                                    ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

# Non-dangerous Time method inside dangerous enclosing Time call
Time.zone.local(year, month, Time.days_in_month(month))
                                  ^^^^^^^^^^^^^^ Rails/TimeZone: Use `Time.zone.local` instead of `Time.local`.

# Splat argument breaks chain walk — inner Time.now not saved by outer .to_i
Time.new(*Time.now.to_a[0..5].reverse[0..4]).to_i
               ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

# Operator assignment — Time.now is still flagged
Time.now += secs
     ^^^ Rails/TimeZone: Use `Time.zone.now` instead of `Time.now`.

Current Fixture: no_offense.rb

tests/fixtures/cops/rails/time_zone/no_offense.rb

Time.current
Time.zone.now
foo.now
DateTime.current
Process.clock_gettime(Process::CLOCK_MONOTONIC)
# String#to_time with timezone specifier is NOT an offense
"2012-03-02T16:05:37Z".to_time
"2012-03-02T16:05:37+05:00".to_time
# to_time without a receiver (bare method call) is NOT an offense
to_time
# variable.to_time is NOT an offense (receiver is not a string literal)
date_str.to_time
my_var.to_time
Time.now.utc
Time.now.in_time_zone
Time.now.to_i
Time.utc(2000)
Time.gm(2000, 1, 1)
I18n.l(Time.now.utc)
foo(bar: Time.now.in_time_zone)
# String argument with timezone specifier — RuboCop skips these
Time.parse('2023-05-29 00:00:00 UTC')
Time.parse('2015-03-02T19:05:37Z')
Time.parse('2015-03-02T19:05:37+05:00')
Time.parse('2015-03-02T19:05:37-0500')
# Time.at/new/now with `in:` keyword argument — timezone offset provided
Time.at(epoch, in: "UTC")
Time.now(in: "+09:00")
Time.new(2023, 1, 1, in: "UTC")
# Method chains with intermediate calls before timezone-safe method
Time.at(timestamp).to_datetime.in_time_zone
Time.at(payload.updated_at / 1000).to_datetime.in_time_zone("UTC")
Time.now.to_i
Time.parse(str).iso8601
# Qualified constant paths — NOT top-level Time, should not be flagged
Some::Time.now
Module::Time.parse("2023-01-01")
Foo::Bar::Time.at(0)
Some::Time.new(2023, 1, 1)
Some::Time.local(2023, 1, 1)
Some::Time.now(0).strftime('%H:%M')

# Time.parse with interpolated string ending in timezone specifier
Time.parse("#{ts} UTC")
Time.parse("#{string}Z", true)
Time.parse("#{val} +05:00")

# Time.now/local inside arguments of a safe method (RuboCop parent-chain walk)
Time.utc(Time.now.year - 1, 7, 1, 0, 0, 0)
Time.utc(Time.now.year, 1, 1)

# .localtime WITH arguments is safe
Time.now.localtime("+09:00")
Time.at(time).localtime("+05:30")

# Time.now/local nested inside outer Time call with safe chain after closing paren
# Only safe when the enclosing call's receiver traces to Time (method_from_time_class? gate)
Time.to_mongo(Time.local(2009, 8, 15, 0, 0, 0)).zone
Time.parse(date.to_s, Time.now).iso8601
Time.at(Time.now + (60 * 60 * 24 * 7)).utc

# Nested parens: inner Time.now inside outer Time call that has safe chain
Time.parse(helper_method(Time.now)).utc

# Non-dangerous Time.XXX inside dangerous enclosing Time call WITH safe chain
Time.zone.local(year, month, Time.days_in_month(month)).utc

# Time.new with 7 arguments — 7th arg is UTC offset, timezone-aware
Time.new(2005, 10, 30, 0, 0, 0, Time.zone)
Time.new(2019, 1, 1, 0, 0, 0, "+03:00")
Time.new(2010, 1, 1, 0, 0, 0, "+10:00")
Time.new(1988, 3, 15, 3, 0, 0, "-05:00")

# Chain with bracket indexing before safe method — scanner must skip [...]
Time.now.year.to_s[0..1].to_i
Time.now.to_a[0..5].reverse.to_i

# Time.current inside dangerous enclosing Time call — current is a good method in flexible mode
Time.zone.at(event.dig(uri, :ts) || Time.current)

# Time.utc inside dangerous enclosing Time call — utc is an accepted method in flexible mode
Time.zone.parse(Time.utc(date_string).to_s).beginning_of_day

Key Source Files

  • Rust implementation: src/cop/rails/time_zone.rs
  • RuboCop Ruby source (ground truth): vendor/rubocop-rails/lib/rubocop/cop/rails/time_zone.rb
  • RuboCop test excerpts: vendor/rubocop-rails/spec/rubocop/cop/rails/time_zone_spec.rb

Read 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-only
  • python3 scripts/investigate_cop.py Rails/TimeZone --context
  • python3 scripts/verify_cop_locations.py Rails/TimeZone

Top FN repos:

  • cjstewart88__Tubalr__f6956c8 (14 FN) — example heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/generator/darkfish.rb:316
  • liaoziyang__stackneveroverflow__8f4dce2 (14 FN) — example vendor/bundle/ruby/2.3.0/gems/rdoc-4.3.0/lib/rdoc/generator/darkfish.rb:630
  • pitluga__supply_drop__d64c50c (12 FN) — example examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/util/autoload/file_cache.rb:58

Representative FN examples:

  • cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/generator/darkfish.rb:316 — Do not use Time.parse without zone. Use one of Time.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_f instead.
  • cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/generator/darkfish.rb:322 — Do not use Time.now without zone. Use one of Time.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_f instead.
  • cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/rdoc.rb:186 — Do not use Time.parse without zone. Use one of Time.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_f instead.

Pre-diagnostic Results

Diagnosis Summary

Each example was tested by running nitrocop on the extracted source in isolation
with --force-default-config to 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: 15 code bug(s), 0 config/context issue(s)

FN #1: cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/generator/darkfish.rb:316

NOT 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 use Time.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_f instead.

Ready-made test snippet (add to offense.rb, adjust ^ count):

    commitdate = Time.parse "#{date} #{time}"
^ Rails/TimeZone: Do not use `Time.parse` without zone. Use one of `Time.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_f` instead.

Full source context:

  def get_svninfo klass
    constants = klass.constants or return {}

    constants.find { |c| c.value =~ SVNID_PATTERN } or return {}

    filename, rev, date, time, committer = $~.captures
    commitdate = Time.parse "#{date} #{time}"

    return {
      :filename    => filename,
      :rev         => Integer(rev),
      :commitdate  => commitdate,
      :commitdelta => time_delta_string(Time.now - commitdate),
      :committer   => committer,

FN #2: cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/generator/darkfish.rb:322

NOT 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 use Time.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_f instead.

Ready-made test snippet (add to offense.rb, adjust ^ count):

      :commitdelta => time_delta_string(Time.now - commitdate),
^ Rails/TimeZone: Do not use `Time.now` without zone. Use one of `Time.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_f` instead.

Full source context:

    filename, rev, date, time, committer = $~.captures
    commitdate = Time.parse "#{date} #{time}"

    return {
      :filename    => filename,
      :rev         => Integer(rev),
      :commitdate  => commitdate,
      :commitdelta => time_delta_string(Time.now - commitdate),
      :committer   => committer,
    }
  end

  ##
  # Load and render the erb template in the given +template_file+ and write
  # it out to +out_file+.

FN #3: cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/rdoc.rb:186

NOT 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 use Time.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_f instead.

Ready-made test snippet (add to offense.rb, adjust ^ count):

            Time.parse io.gets
^ Rails/TimeZone: Do not use `Time.parse` without zone. Use one of `Time.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_f` instead.

Full source context:

      # do nothing
    elsif File.exist? dir then
      error "#{dir} exists and is not a directory" unless File.directory? dir

      begin
        open flag_file do |io|
          unless force then
            Time.parse io.gets

            io.each do |line|
              file, time = line.split "\t", 2
              time = Time.parse(time) rescue next
              last[file] = time
            end
          end

FN #4: cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/rdoc.rb:190

NOT 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 use Time.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_f instead.

Ready-made test snippet (add to offense.rb, adjust ^ count):

              time = Time.parse(time) rescue next
^ Rails/TimeZone: Do not use `Time.parse` without zone. Use one of `Time.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_f` instead.

Full source context:

      begin
        open flag_file do |io|
          unless force then
            Time.parse io.gets

            io.each do |line|
              file, time = line.split "\t", 2
              time = Time.parse(time) rescue next
              last[file] = time
            end
          end
        end
      rescue SystemCallError, TypeError
        error <<-ERROR

FN #5: cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/rdoc.rb:432

NOT DETECTED — CODE BUG
The cop fails to detect this pattern. Fix the detection logic.

Message: Do not use Time.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_f instead.

Ready-made test snippet (add to offense.rb, adjust ^ count):

    @start_time = Time.now
^ Rails/TimeZone: Do not use `Time.now` without zone. Use one of `Time.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_f` instead.

Full source context:

    @exclude = @options.exclude

    unless @options.coverage_report then
      @last_modified = setup_output_dir @options.op_dir, @options.force_update
    end

    @start_time = Time.now

    file_info = parse_files @options.files

    @options.default_title = "RDoc Documentation"

    RDoc::TopLevel.complete @options.visibility

FN #6: cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/stats.rb:37

NOT DETECTED — CODE BUG
The cop fails to detect this pattern. Fix the detection logic.

Message: Do not use Time.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_f instead.

Ready-made test snippet (add to offense.rb, adjust ^ count):

    @start = Time.now
^ Rails/TimeZone: Do not use `Time.now` without zone. Use one of `Time.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_f` instead.

Full source context:

    @num_files = num_files

    @coverage_level = 0
    @doc_items = nil
    @fully_documented = false
    @num_params = 0
    @percent_doc = nil
    @start = Time.now
    @undoc_params = 0

    @display = case verbosity
               when 0 then Quiet.new   num_files
               when 1 then Normal.new  num_files
               else        Verbose.new num_files
               end

FN #7: cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/stats.rb:408

NOT DETECTED — CODE BUG
The cop fails to detect this pattern. Fix the detection logic.

Message: Do not use Time.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_f instead.

Ready-made test snippet (add to offense.rb, adjust ^ count):

    report << 'Elapsed: %0.1fs' % (Time.now - @start)
^ Rails/TimeZone: Do not use `Time.now` without zone. Use one of `Time.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_f` instead.

Full source context:

    report << nil

    report << 'Total:      %*d (%*d undocumented)' % [
      num_width, @num_items, undoc_width, @undoc_items]

    report << '%6.2f%% documented' % percent_doc
    report << nil
    report << 'Elapsed: %0.1fs' % (Time.now - @start)

    report.join "\n"
  end

  ##
  # Determines which parameters in +method+ were not documented.  Returns a
  # total parameter count and an Array of undocumented methods.

FN #8: cjstewart88__Tubalr__f6956c8: heroku/ruby/1.9.1/gems/rdoc-3.9.4/lib/rdoc/generator/darkfish.rb:316

NOT 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 use Time.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_f instead.

Ready-made test snippet (add to offense.rb, adjust ^ count):

    commitdate = Time.parse "#{date} #{time}"
^ Rails/TimeZone: Do not use `Time.parse` without zone. Use one of `Time.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_f` instead.

Full source context:

  def get_svninfo klass
    constants = klass.constants or return {}

    constants.find { |c| c.value =~ SVNID_PATTERN } or return {}

    filename, rev, date, time, committer = $~.captures
    commitdate = Time.parse "#{date} #{time}"

    return {
      :filename    => filename,
      :rev         => Integer(rev),
      :commitdate  => commitdate,
      :commitdelta => time_delta_string(Time.now - commitdate),
      :committer   => committer,

Omitted 7 additional diagnosed FN example(s) for brevity.

@6 6 bot force-pushed the fix/rails-time_zone-23575949147 branch from a249bde to da179ae Compare March 26, 2026 03:50
@6
Copy link
Copy Markdown
Contributor Author

6 bot commented Mar 26, 2026

Agent produced no changes.

@6 6 bot closed this Mar 26, 2026
@6 6 bot deleted the fix/rails-time_zone-23575949147 branch March 26, 2026 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants