Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number of open issue probe #353

Open
wants to merge 50 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2773dcf
Fetched issue tracker from update center
Jagrutiti Jul 23, 2023
68aa505
Removed issueTracker from models
Jagrutiti Jul 24, 2023
54a82a3
Modified the existing test cases that were affected and updated then …
Jagrutiti Jul 24, 2023
abb1001
Fixing checkstyle issues
Jagrutiti Jul 24, 2023
4d8ae5d
Fixing checkstyle issues
Jagrutiti Jul 24, 2023
c4c1605
Updated probe names and added java docs
Jagrutiti Jul 24, 2023
99d9cf5
Added test and code to count open GitHub issues
Jagrutiti Jul 29, 2023
719c57d
Added test code and completed the test case
Jagrutiti Jul 30, 2023
925afa3
Removed conficting dependencies
Jagrutiti Jul 30, 2023
58b135a
Fixed incorrect artifact name
Jagrutiti Jul 30, 2023
c71a32a
Merge branch 'main' into feature/open-issue-probe
Jagrutiti Jul 30, 2023
5fd8b2d
Fixed JIRA API calling
Jagrutiti Aug 1, 2023
6f9ede3
Merge branch 'main' into feature/open-issue-probe
Jagrutiti Aug 1, 2023
1a54932
Added IssueTrackerDetectionProbe
Jagrutiti Aug 2, 2023
4a144e5
Update IssueTrackerDetectionProbe and added a test for the same
Jagrutiti Aug 5, 2023
d3fd18b
Added abstract probe class and jira and github issues count probe
Jagrutiti Aug 5, 2023
d960448
Fixing checkstyle issues
Jagrutiti Aug 5, 2023
eda1b13
Fixed the test case for open jira issues count
Jagrutiti Aug 6, 2023
97aed28
Removing the issueTracker field from update center
Jagrutiti Aug 6, 2023
528ab43
Added a narrowed depedency in pom file and removed unwanted mock in …
Jagrutiti Aug 6, 2023
5f22f38
Added more test case for IssueTrackerDetectionProbe
Jagrutiti Aug 6, 2023
e13f3a8
Fixed checkstyle issues
Jagrutiti Aug 6, 2023
9bcb49e
Adding more test case for jira open issues
Jagrutiti Aug 6, 2023
4989e81
Apply suggestions from code review
Jagrutiti Aug 8, 2023
7db7e7a
Fixed the abstract class and updated test cases
Jagrutiti Aug 9, 2023
e45ce77
Updated the test cases
Jagrutiti Aug 9, 2023
510d340
Modifying the abstract class to make it better
Jagrutiti Aug 9, 2023
3cf7406
Refactored code in GitHub open issues probe
Jagrutiti Aug 12, 2023
b9cda9c
Restructured IssueTrackerDetectionProbe and improved its readability
Jagrutiti Aug 13, 2023
37884d5
Added a new test case for IssueTrackerDertectionProbe
Jagrutiti Aug 13, 2023
898c86c
Refactored code, test cases, fixed border cases
Jagrutiti Aug 13, 2023
fdd1a4e
Updating IssueTrackerDetectionProbe ORDER
Jagrutiti Aug 13, 2023
1940e67
Fixed method names
Jagrutiti Aug 14, 2023
151df0d
Merge branch 'main' into feature/open-issue-probe
Jagrutiti Aug 14, 2023
12ef4aa
Removed unused imports
Jagrutiti Aug 14, 2023
7f6cb04
Merge branch 'feature/open-issue-probe' of https://github.com/Jagruti…
Jagrutiti Aug 14, 2023
6a7214a
Fixed JavaDocs
Jagrutiti Aug 15, 2023
8e0f12a
Update core/src/main/java/io/jenkins/pluginhealth/scoring/probes/GitH…
Jagrutiti Aug 19, 2023
12db24b
Removed unwanted dependencies and fixed log statements
Jagrutiti Aug 19, 2023
793114b
Adding a comment
Jagrutiti Aug 22, 2023
e13b17e
Update core/src/test/java/io/jenkins/pluginhealth/scoring/probes/GitH…
Jagrutiti Aug 23, 2023
f4ef76e
Made minor changes based on code review
Jagrutiti Aug 23, 2023
1e194e9
Merge branch 'feature/open-issue-probe' of https://github.com/Jagruti…
Jagrutiti Aug 23, 2023
d9fad0c
Adding null checks
Jagrutiti Aug 24, 2023
663282c
Apply suggestions from code review
Jagrutiti Sep 6, 2023
c099e40
Fixed foramatting, updated library uses based on code review
Jagrutiti Sep 6, 2023
ec28408
Updated syntax for null check
Jagrutiti Sep 6, 2023
6a740d2
Merge branch 'main' into feature/open-issue-probe
Jagrutiti Sep 7, 2023
9244d60
Fixing merge issues
Jagrutiti Sep 7, 2023
b722a87
Fixing checkstyle issues
Jagrutiti Sep 7, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ public record Plugin(String name, VersionNumber version, String scm,
ZonedDateTime releaseTimestamp, List<String> labels,
int popularity, String requiredCore, String defaultBranch, List<IssueTrackers> issueTrackers) {

/* This constructor is used in test cases
when List<IssueTrackers> is not required as a parameter.
*/
/* This builder function is used in test cases when List<IssueTrackers> is not required as a mandatory parameter. */
public static Plugin of(String name, VersionNumber version, String scm,
ZonedDateTime releaseTimestamp, List<String> labels,
int popularity, String requiredCore, String defaultBranch) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class GitHubOpenIssuesProbe extends AbstractOpenIssuesProbe {
*/
@Override
Optional<Integer> getCountOfOpenIssues(ProbeContext context) {
if (context.getIssueTrackerUrlsByNames().get("github") == null) {
Jagrutiti marked this conversation as resolved.
Show resolved Hide resolved
LOGGER.info("IssueTracker has no GitHub open issues for the plugin.");
return Optional.empty();
}
/* Stores the GitHub URL to view all existing issues in the plugin. Ex: https://github.com/jenkinsci/cloudevents-plugin/issues */
String issueTrackerViewUrl = context.getIssueTrackerUrlsByNames().get("github");
Copy link
Collaborator

Choose a reason for hiding this comment

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

context.getIssueTrackerUrlsByNames() cannot be null right?

If you are not sure, you can add a first check to validate that the plugin has an issue tracker configured? (a simple if before trying to .get("github");)

Copy link
Member Author

Choose a reason for hiding this comment

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

IssueTrackerDetectionProbe is the requirement for GitHubOpenIssuesProbe and UpdateCenterPluginPublicationProbe is the requirement for IssueTrackerDetectionProbe that is why a part of my believes that this issue might not occur.

It is better to be safe than sorry.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like the "better safe than sorry" principal. 👍


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected ProbeResult doApply(Plugin plugin, ProbeContext context) {
return ProbeResult.failure(key(), String.format("No issue tracker data available for %s plugin in Update Center.", plugin.getName()));
}
context.setIssueTrackerNameAndUrl(issueTrackerDetails);
return ProbeResult.success(key(), "Issue tracker detected and returned successfully.");
return ProbeResult.success(key(), String.format("Found %d issue trackers configured for the %s plugin.", issueTrackerDetails.size(), plugin.getName()));
}

@Override
Expand All @@ -76,7 +76,7 @@ public String getDescription() {
* @return A Map of filtered data from issue trackers.
*/
private Map<String, String> getIssueTrackersForAPlugin(String pluginName, UpdateCenter updateCenter) {
return updateCenter.plugins().get(pluginName) != null
return (updateCenter.plugins().get(pluginName) != null) && (updateCenter.plugins().get(pluginName).getIssueTrackers() != null)
? filterIssueTrackersForTypeAndViewUrl(updateCenter.plugins().get(pluginName).getIssueTrackers())
Jagrutiti marked this conversation as resolved.
Show resolved Hide resolved
Jagrutiti marked this conversation as resolved.
Show resolved Hide resolved
: Map.of();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ class JiraOpenIssuesProbe extends AbstractOpenIssuesProbe {
*/
@Override
Optional<Integer> getCountOfOpenIssues(ProbeContext context) {
if (context.getIssueTrackerUrlsByNames().get("jira") == null) {
Jagrutiti marked this conversation as resolved.
Show resolved Hide resolved
LOGGER.info("IssueTracker has no JIRA open issues for the plugin.");
return Optional.empty();
}

/* Stores the JIRA URL to view all existing issues in the plugin. Ex: https://github.com/jenkinsci/cloudevents-plugin/issues */
String viewJiraIssuesUrl = context.getIssueTrackerUrlsByNames().get("jira");
Copy link
Collaborator

Choose a reason for hiding this comment

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

context.getIssueTrackerUrlsByNames() cannot be null right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as before, "better safe than sorry".

Copy link
Member Author

Choose a reason for hiding this comment

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

The if condition checks whether the null values below this line.


if (viewJiraIssuesUrl == null || viewJiraIssuesUrl.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void shouldDetectIssueTrackersInPlugin() throws IOException {
assertThat(probe.apply(plugin, ctx))
.usingRecursiveComparison()
.comparingOnlyFields("id", "status", "message")
.isEqualTo(ProbeResult.success(IssueTrackerDetectionProbe.KEY, "Issue tracker detected and returned successfully."));
.isEqualTo(ProbeResult.success(IssueTrackerDetectionProbe.KEY, "Found 2 issue trackers configured for the foo plugin."));

assertThat(ctx.getIssueTrackerUrlsByNames()).contains(entry("github", "https://github.com/foo-plugin/issues"), entry("jira", "https://issues.jenkins.io/issues/?jql=component=18331"));
verify(probe).doApply(plugin, ctx);
Expand Down Expand Up @@ -143,7 +143,7 @@ void shouldAlwaysFilterDataForTheCorrectPluginFromIssueTrackers() throws IOExcep
assertThat(probe.apply(plugin, ctx))
.usingRecursiveComparison()
.comparingOnlyFields("id", "status", "message")
.isEqualTo(ProbeResult.success(IssueTrackerDetectionProbe.KEY, "Issue tracker detected and returned successfully."));
.isEqualTo(ProbeResult.success(IssueTrackerDetectionProbe.KEY, "Found 1 issue trackers configured for the foo plugin."));

assertThat(plugin.getName()).isEqualTo(correctPluginToFilterFor);
assertThat(ctx.getIssueTrackerUrlsByNames()).containsExactlyEntriesOf(correctIssueSetToMatch);
Expand Down Expand Up @@ -178,7 +178,7 @@ void shouldDetectForOnlyGHInIssueTrackers() throws IOException {
assertThat(probe.apply(plugin, ctx))
.usingRecursiveComparison()
.comparingOnlyFields("id", "status", "message")
.isEqualTo(ProbeResult.success(IssueTrackerDetectionProbe.KEY, "Issue tracker detected and returned successfully."));
.isEqualTo(ProbeResult.success(IssueTrackerDetectionProbe.KEY, "Found 1 issue trackers configured for the foo plugin."));

assertThat(ctx.getIssueTrackerUrlsByNames()).contains(entry("github", "https://github.com/foo-plugin/issues"));
verify(probe).doApply(plugin, ctx);
Expand Down Expand Up @@ -213,7 +213,7 @@ void shouldDetectForOnlyJIRAInIssueTrackers() throws IOException {
assertThat(probe.apply(plugin, ctx))
.usingRecursiveComparison()
.comparingOnlyFields("id", "status", "message")
.isEqualTo(ProbeResult.success(IssueTrackerDetectionProbe.KEY, "Issue tracker detected and returned successfully."));
.isEqualTo(ProbeResult.success(IssueTrackerDetectionProbe.KEY, "Found 1 issue trackers configured for the foo plugin."));

assertThat(ctx.getIssueTrackerUrlsByNames()).contains(entry("jira", "https://issues.jenkins.io/issues/?jql=component=18331"));
verify(probe).doApply(plugin, ctx);
Expand Down