refactoring : mysterious name - change method declaration

This commit is contained in:
haerong22
2022-02-13 19:36:00 +09:00
parent 9535fffa7a
commit 1afb0f51b4
2 changed files with 94 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
package com.example.refactoring._01_mysterious_name._00_before;
import org.kohsuke.github.GHIssue;
import org.kohsuke.github.GHIssueComment;
import org.kohsuke.github.GHRepository;
import org.kohsuke.github.GitHub;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class StudyDashboard {
private Set<String> usernames = new HashSet<>();
private Set<String> reviews = new HashSet<>();
private void studyReviews(GHIssue issue) throws IOException {
List<GHIssueComment> comments = issue.getComments();
for (GHIssueComment comment : comments) {
usernames.add(comment.getUserName());
reviews.add(comment.getBody());
}
}
public Set<String> getUsernames() {
return usernames;
}
public Set<String> getReviews() {
return reviews;
}
public static void main(String[] args) throws IOException {
GitHub gitHub = GitHub.connect();
GHRepository repository = gitHub.getRepository("haerong22/Study");
GHIssue issue = repository.getIssue(1);
StudyDashboard studyDashboard = new StudyDashboard();
studyDashboard.studyReviews(issue);
studyDashboard.getUsernames().forEach(System.out::println);
studyDashboard.getReviews().forEach(System.out::println);
}
}

View File

@@ -0,0 +1,49 @@
package com.example.refactoring._01_mysterious_name._01_change_method_declaration;
import org.kohsuke.github.GHIssue;
import org.kohsuke.github.GHIssueComment;
import org.kohsuke.github.GHRepository;
import org.kohsuke.github.GitHub;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class StudyDashboard {
private Set<String> usernames = new HashSet<>();
private Set<String> reviews = new HashSet<>();
/**
* 이슈에 작성된 리뷰어의 목록과 리뷰를 읽어옵니다.
* @throws IOException
*/
private void loadReviews() throws IOException { // 메소드의 목적에 맞게 메소드명을 변경
GitHub gitHub = GitHub.connect();
GHRepository repository = gitHub.getRepository("haerong22/Study");
GHIssue issue = repository.getIssue(1);
List<GHIssueComment> comments = issue.getComments();
for (GHIssueComment comment : comments) {
usernames.add(comment.getUserName());
reviews.add(comment.getBody());
}
}
public Set<String> getUsernames() {
return usernames;
}
public Set<String> getReviews() {
return reviews;
}
public static void main(String[] args) throws IOException {
StudyDashboard studyDashboard = new StudyDashboard();
studyDashboard.loadReviews();
studyDashboard.getUsernames().forEach(System.out::println);
studyDashboard.getReviews().forEach(System.out::println);
}
}