#1160: fix undefined method 'zero?' in dimensions-of-terrain judge#1162
#1160: fix undefined method 'zero?' in dimensions-of-terrain judge#1162Yegorov wants to merge 1 commit into
dimensions-of-terrain judge#1162Conversation
WalkthroughThe PR adds nil-aware checks for repository size values in dimension-of-terrain judges to prevent NoMethodError when calling Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
judges/dimensions-of-terrain/total_files.rb (1)
11-11: Update comment to reflect nil-size handling.The comment mentions "ignores empty repositories" but now the code also skips repositories with nil size. Consider updating the comment for accuracy.
Apply this diff to update the comment:
-# items (files, not directories), and ignores empty repositories. +# items (files, not directories), and ignores empty and nil-size repositories.judges/dimensions-of-terrain/total_contributors.rb (1)
12-12: Update comment to reflect nil-size handling.The comment states "Empty repositories (size zero) are skipped" but now the code also skips repositories with nil size. Update the comment for accuracy.
Apply this diff:
-# each contributor is counted only once even if they contribute to multiple repositories. -# Empty repositories (size zero) are skipped. +# each contributor is counted only once even if they contribute to multiple repositories. +# Empty and nil-size repositories are skipped.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
judges/dimensions-of-terrain/total_commits.rb(1 hunks)judges/dimensions-of-terrain/total_contributors.rb(1 hunks)judges/dimensions-of-terrain/total_files.rb(1 hunks)test/judges/test-dimensions-of-terrain.rb(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
test/judges/test-dimensions-of-terrain.rb (1)
test/test__helper.rb (1)
load_it(46-56)
judges/dimensions-of-terrain/total_commits.rb (2)
judges/quantity-of-deliverables/total_commits_pushed.rb (1)
total_commits_pushed(15-29)test/judges/test-quantity-of-deliverables.rb (1)
test_counts_commits(20-88)
🪛 GitHub Actions: rake
test/judges/test-dimensions-of-terrain.rb
[error] 288-288: TestDimensionsOfTerrain#test_total_commits failed. Expected: 1484, Actual: 2968.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: make
🔇 Additional comments (3)
judges/dimensions-of-terrain/total_files.rb (1)
23-23: LGTM - nil check prevents NoMethodError.The addition of the nil check correctly prevents the
NoMethodErrorthat occurs when calling.zero?on a nil value, which was the root cause of issue #1160.judges/dimensions-of-terrain/total_contributors.rb (1)
23-24: LGTM - nil check prevents NoMethodError.The nil-aware guard correctly prevents calling
.zero?on nil values. The refactoring to fetch repository info first is reasonable, though it differs slightly from the pattern intotal_files.rb(which uses inline access). Both approaches work correctly.judges/dimensions-of-terrain/total_commits.rb (1)
20-21: LGTM - nil check prevents NoMethodError.The nil-aware guard correctly addresses the bug reported in issue #1160 by preventing
.zero?from being called on nil values.
kreinba
left a comment
There was a problem hiding this comment.
The nil guard is added in three judges but the test suite only exercises the new branch in one of them, and the make and rake checks on the head commit are red. Two inline comments below.
| fb, | ||
| Judges::Options.new( | ||
| { | ||
| 'repositories' => 'foo/foo,yegor256/empty-repo,yegor256/nil-size-repo', |
There was a problem hiding this comment.
The repositories list now includes yegor256/nil-size-repo for test_total_commits, but test_total_contributors (line 500) and test_total_files (line 417) still pass only foo/foo,yegor256/empty-repo, so the new nil? branch added to total_contributors.rb and total_files.rb is never executed by the suite. Add the same nil-size repository to those two tests so every changed file has a regression test.
| Fbe.unmask_repos do |repo| | ||
| next if Fbe.octo.repository(repo)[:size].zero? | ||
| json = Fbe.octo.repository(repo) | ||
| next if json[:size].nil? || json[:size].zero? |
There was a problem hiding this comment.
The single Fbe.octo.repository(repo) call was split into a local variable to read :size twice — fine — but the new branch is not covered by a test. Without a stub returning size: nil for a repo passed to test_total_contributors, this guard is dead code from the suite's point of view, and the rake check on the current head is failing.
|
This pull request has merge conflicts. Please rebase it on the default branch to resolve them so it can be merged. |
Test fail, because this zerocracy/fbe#341 PR need merge before
Closes #1160
Summary by CodeRabbit