Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Update C# application code
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed May 8, 2024
1 parent 4cfff95 commit 02e18d6
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 40 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
48 changes: 8 additions & 40 deletions src/test/java/org/openrewrite/csharp/FindClassTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;
import org.openrewrite.test.SourceSpec;
import org.openrewrite.test.TypeValidation;

import static org.openrewrite.java.Assertions.java;

Expand Down Expand Up @@ -75,54 +74,23 @@ class T2 {
}

@Test
void foreachLoop() {
void whileLoop() {
rewriteRun(
spec -> spec.typeValidationOptions(TypeValidation.none()),
java(
"""
package io.moderne.github;
import org.kohsuke.github.*;
import java.io.FileWriter;
import java.io.IOException;
import java.time.LocalDate;
import java.time.ZoneId;
public class Main {
public static void main(String[] args) throws IOException {
String ghOrigin = args.length == 0 ? "github.com" : args[0];
String ghEndpoint = args.length < 2 ? "https://api.github.com" : args[1];
GitHub github = GitHubBuilder.fromPropertyFile()
.withEndpoint(ghEndpoint)
.build();
try (FileWriter writer = new FileWriter("repos.csv")) {
PagedIterator<GHOrganization> orgs = github.listOrganizations()._iterator(10);
while (orgs.hasNext()) {
GHOrganization org = orgs.next();
try {
for (GHRepository repo : org.getRepositories().values()) {
if (!repo.isArchived() && LocalDate.now().minusYears(2).isBefore(repo.getPushedAt()
.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate())) {
writer.write(org.getLogin() + "/" + repo.getName() + "," + repo.getDefaultBranch() + ",,,,,\\n");
}
}
} catch (Throwable ignored) {
// continue to the next org
}
}
class T {
public static void main(String[] args) {
while (true) {
System.out.println("OK");
}
}
}
""",
"""
/*~~>*/class T {
void foo() {
for (int i : new int[] {1, 2, 3}) {
System.out.println(i);
public static void main(String[] args) {
while (true) {
System.out.println("OK");
}
}
}
Expand Down

0 comments on commit 02e18d6

Please sign in to comment.