Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit 7a2610c

Browse files
committed
Remove check for empty counts
1 parent 65df934 commit 7a2610c

File tree

3 files changed

+8
-27
lines changed

3 files changed

+8
-27
lines changed

lib/cc/presenters/github_pull_requests_presenter.rb

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@ def initialize(payload, repo_config)
1313
end
1414

1515
def success_message
16-
if issue_counts_in_payload?
17-
if both_issue_counts_zero?
18-
"Code Climate didn't find any new or fixed issues."
19-
else
20-
"Code Climate found #{formatted_issue_counts}."
21-
end
16+
if both_issue_counts_zero?
17+
"Code Climate didn't find any new or fixed issues."
2218
else
23-
"Code Climate has analyzed this pull request."
19+
"Code Climate found #{formatted_issue_counts}."
2420
end
2521
end
2622

@@ -53,10 +49,6 @@ def formatted_issue_counts
5349
def issue_counts
5450
[@new_count, @fixed_count]
5551
end
56-
57-
def issue_counts_in_payload?
58-
issue_counts.all?
59-
end
6052
end
6153
end
6254
end

test/github_pull_requests_test.rb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,15 @@ def test_pull_request_status_pending
1717
def test_pull_request_status_success_detailed
1818
expect_status_update("pbrisbin/foo", "abc123", {
1919
"state" => "success",
20-
"description" => "Code Climate found 1 new issue and 2 fixed issues.",
20+
"description" => "Code Climate found 2 new issues and 1 fixed issue.",
2121
})
2222

2323
receive_pull_request(
2424
{ update_status: true },
2525
{
2626
github_slug: "pbrisbin/foo",
2727
commit_sha: "abc123",
28-
state: "success",
29-
issue_comparison_counts: {
30-
"fixed" => 2,
31-
"new" => 1,
32-
}
28+
state: "success"
3329
},
3430
true
3531
)
@@ -38,7 +34,7 @@ def test_pull_request_status_success_detailed
3834
def test_pull_request_status_success_generic
3935
expect_status_update("pbrisbin/foo", "abc123", {
4036
"state" => "success",
41-
"description" => /has analyzed/,
37+
"description" => /found 2 new issues and 1 fixed issue/,
4238
})
4339

4440
receive_pull_request({ update_status: true }, {
@@ -252,7 +248,7 @@ def receive_pull_request(config, event_data, truthy_repo_config = false)
252248
receive(
253249
CC::Service::GitHubPullRequests,
254250
{ oauth_token: "123" }.merge(config),
255-
{ name: "pull_request" }.merge(event_data),
251+
{ name: "pull_request", issue_comparison_counts: {'fixed' => 1, 'new' => 2} }.merge(event_data),
256252
truthy_repo_config ? TruthyRepoConfig.new : FalsyRepoConfig.new
257253
)
258254
end
@@ -261,7 +257,7 @@ def receive_test(config, event_data = {})
261257
receive(
262258
CC::Service::GitHubPullRequests,
263259
{ oauth_token: "123" }.merge(config),
264-
{ name: "test" }.merge(event_data)
260+
{ name: "test", issue_comparison_counts: {'fixed' => 1, 'new' => 2} }.merge(event_data)
265261
)
266262
end
267263
end

test/presenters/github_pull_requests_presenter_test.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ def test_message_no_new_or_fixed
3737
)
3838
end
3939

40-
def test_message_no_issue_counts
41-
assert_equal(
42-
"Code Climate has analyzed this pull request.",
43-
build_presenter({}).success_message
44-
)
45-
end
46-
4740
private
4841

4942
def build_payload(issue_counts)

0 commit comments

Comments
 (0)