Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion judges/dimensions-of-terrain/total_commits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def total_commits(_fact)
repos = []
Fbe.unmask_repos do |repo|
json = Fbe.octo.repository(repo)
next if json[:size].zero?
next if json[:size].nil? || json[:size].zero?
repos << [*repo.split('/'), json[:default_branch]]
end
commits = Fbe.github_graph.total_commits(repos:).sum { _1['total_commits'] } unless repos.empty?
Expand Down
3 changes: 2 additions & 1 deletion judges/dimensions-of-terrain/total_contributors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
def total_contributors(_fact)
contributors = Set.new
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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fbe.octo.contributors(repo).each do |contributor|
contributors << contributor[:id]
end
Expand Down
2 changes: 1 addition & 1 deletion judges/dimensions-of-terrain/total_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def total_files(_fact)
files = 0
Fbe.unmask_repos do |repo|
repo_info = Fbe.octo.repository(repo)
next if repo_info[:size].zero?
next if repo_info[:size].nil? || repo_info[:size].zero?
Fbe.octo.tree(repo, repo_info[:default_branch], recursive: true).then do |json|
files += json[:tree].count { |item| item[:type] == 'blob' }
end
Expand Down
12 changes: 10 additions & 2 deletions test/judges/test-dimensions-of-terrain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,16 @@ def test_total_issues_and_pull_requests
def test_total_commits
WebMock.disable_net_connect!
fb = Factbase.new
load_it('dimensions-of-terrain', fb,
Judges::Options.new({ 'repositories' => 'foo/foo,yegor256/empty-repo', 'testing' => true }))
load_it(
'dimensions-of-terrain',
fb,
Judges::Options.new(
{
'repositories' => 'foo/foo,yegor256/empty-repo,yegor256/nil-size-repo',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

'testing' => true
}
)
)
f = fb.query("(eq what 'dimensions-of-terrain')").each.first
assert_equal(1484, f.total_commits)
end
Comment thread
Yegorov marked this conversation as resolved.
Expand Down
Loading