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 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 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