From 4c66dd1f100c3501cc11817d6d7727a27cb7ae9f Mon Sep 17 00:00:00 2001 From: riyapuri21 <169127253+riyapuri21@users.noreply.github.com> Date: Wed, 8 May 2024 11:07:27 +0530 Subject: [PATCH 1/3] Update codeguru.yml added IAM role details --- .github/workflows/codeguru.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeguru.yml b/.github/workflows/codeguru.yml index 0c781a9e..4acac974 100644 --- a/.github/workflows/codeguru.yml +++ b/.github/workflows/codeguru.yml @@ -19,7 +19,7 @@ jobs: continue-on-error: true uses: aws-actions/configure-aws-credentials@v1 with: - role-to-assume: arn:aws:iam::048169001733:role/GuruGitHubCICDRole + role-to-assume: arn:aws:iam::648977173330:role/GitHubCICDRole aws-region: us-west-2 - uses: actions/checkout@v2 From 401b29c9c5e89f4bd479108678d95b5ba90769ed Mon Sep 17 00:00:00 2001 From: riyapuri21 Date: Wed, 8 May 2024 11:24:21 +0530 Subject: [PATCH 2/3] added demo file --- .../com/shipmentEvents/util/test-sample.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/main/java/com/shipmentEvents/util/test-sample.java diff --git a/src/main/java/com/shipmentEvents/util/test-sample.java b/src/main/java/com/shipmentEvents/util/test-sample.java new file mode 100644 index 00000000..51a45369 --- /dev/null +++ b/src/main/java/com/shipmentEvents/util/test-sample.java @@ -0,0 +1,58 @@ +import java.util.ArrayList; +import java.util.List; + +public class ComplexCode { + + public static void main(String[] args) { + ComplexCode complexCode = new ComplexCode(); + List names = new ArrayList<>(); + names.add("Alice"); + names.add("Bob"); + names.add("Charlie"); + + // Call a method with a potential bug + complexCode.printNames(names); + + // Call a method with a potential bug + complexCode.processNames(names); + } + + // Method to print names from a list + public void printNames(List names) { + for (int i = 0; i <= names.size(); i++) { // Bug: Index out of bounds + System.out.println(names.get(i)); + } + } + + // Method to process names and add suffix + public void processNames(List names) { + for (String name : names) { + if (name.equals("Alice")) { + name += " Doe"; + } else if (name.equals("Bob")) { + name += " Smith"; + } else { + name += " Unknown"; // Bug: Incorrect logic + } + System.out.println(name); + } + } + + // Method to calculate factorial (intentionally complex) + public int calculateFactorial(int n) { + if (n == 0) { + return 1; + } else { + return n * calculateFactorial(n - 1); + } + } + + // Method to perform a complex calculation (intentionally complex) + public double complexCalculation(double a, double b, int n) { + double result = 0.0; + for (int i = 0; i < n; i++) { + result += Math.pow(a, i) * Math.pow(b, n - i) / calculateFactorial(i); // Bug: Potential arithmetic error + } + return result; + } +} \ No newline at end of file From fd67e552c5dc37ec4581f2b92102c54a53d2f2fd Mon Sep 17 00:00:00 2001 From: riyapuri21 Date: Wed, 8 May 2024 11:46:14 +0530 Subject: [PATCH 3/3] code guru test 2 --- .../shipmentEvents/handlers/test-sample.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/main/java/com/shipmentEvents/handlers/test-sample.java diff --git a/src/main/java/com/shipmentEvents/handlers/test-sample.java b/src/main/java/com/shipmentEvents/handlers/test-sample.java new file mode 100644 index 00000000..51a45369 --- /dev/null +++ b/src/main/java/com/shipmentEvents/handlers/test-sample.java @@ -0,0 +1,58 @@ +import java.util.ArrayList; +import java.util.List; + +public class ComplexCode { + + public static void main(String[] args) { + ComplexCode complexCode = new ComplexCode(); + List names = new ArrayList<>(); + names.add("Alice"); + names.add("Bob"); + names.add("Charlie"); + + // Call a method with a potential bug + complexCode.printNames(names); + + // Call a method with a potential bug + complexCode.processNames(names); + } + + // Method to print names from a list + public void printNames(List names) { + for (int i = 0; i <= names.size(); i++) { // Bug: Index out of bounds + System.out.println(names.get(i)); + } + } + + // Method to process names and add suffix + public void processNames(List names) { + for (String name : names) { + if (name.equals("Alice")) { + name += " Doe"; + } else if (name.equals("Bob")) { + name += " Smith"; + } else { + name += " Unknown"; // Bug: Incorrect logic + } + System.out.println(name); + } + } + + // Method to calculate factorial (intentionally complex) + public int calculateFactorial(int n) { + if (n == 0) { + return 1; + } else { + return n * calculateFactorial(n - 1); + } + } + + // Method to perform a complex calculation (intentionally complex) + public double complexCalculation(double a, double b, int n) { + double result = 0.0; + for (int i = 0; i < n; i++) { + result += Math.pow(a, i) * Math.pow(b, n - i) / calculateFactorial(i); // Bug: Potential arithmetic error + } + return result; + } +} \ No newline at end of file