Skip to content

code guru Test 2 Dev->Master #333

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/codeguru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 58 additions & 0 deletions src/main/java/com/shipmentEvents/handlers/test-sample.java
Original file line number Diff line number Diff line change
@@ -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<String> 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<String> 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<String> 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;
}
}
58 changes: 58 additions & 0 deletions src/main/java/com/shipmentEvents/util/test-sample.java
Original file line number Diff line number Diff line change
@@ -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<String> 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<String> 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<String> 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;
}
}