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

DO NOT MERGE: bad code for testing reviewer bots #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tzachz
Copy link
Owner

@tzachz tzachz commented Oct 25, 2021

No description provided.

for (int i = 0; i < arr.length; i++) { // expect error: for loop
System.out.println(arr[i]); // expect error: println
}
if ("1" == "1") { // expect error: use equals
Copy link
Owner Author

Choose a reason for hiding this comment

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

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem: An equality operator (== or !=) is used to compare strings, which matches strings based on address.

Fix: Do content comparison using the equals() method to compare the values of the strings.

@tzachz tzachz closed this Oct 25, 2021
@tzachz tzachz reopened this Oct 25, 2021
@sonarcloud
Copy link

sonarcloud bot commented Oct 25, 2021

SonarCloud Quality Gate failed.    Quality Gate failed

Bug C 3 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell C 8 Code Smells

7.7% 7.7% Coverage
0.0% 0.0% Duplication

for (int i = 0; i < arr.length; i++) { // expect error: for loop
System.out.println(arr[i]); // expect error: println
}
if ("1" == "1") { // expect error: use equals
Copy link

Choose a reason for hiding this comment

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

[PMD Java] Use equals() to compare object references. (view)

Rule Ruleset Priority
CompareObjectsWithEquals Error Prone 3

References:

You can close this issue if no need to fix it. Learn more.

// expect error: unused
private String unused() {
String[] arr = new String[] {"a", "b"};
for (int i = 0; i < arr.length; i++) { // expect error: for loop
Copy link

Choose a reason for hiding this comment

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

[PMD Java] This for loop can be replaced by a foreach loop (view)

Rule Ruleset Priority
ForLoopCanBeForeach Best Practices 3

References:

You can close this issue if no need to fix it. Learn more.

@@ -65,4 +80,11 @@
executorService.scheduleAtFixedRate(new FetcherRunnable(store, fetcher), 0, configuration.getRefreshRateMinutes(), TimeUnit.MINUTES);
}

// expect error: length, number of vars, unused vars, duplication, unused
private void createScheduledFetcher2(LeaderBoardServerConfiguration configuration, Environment environment, GitHubApiFacade apiFacade, LeaderBoardStore store, String aaa, String bbb, String ccc, String ddd) {
Copy link

Choose a reason for hiding this comment

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

[PMD Java] Avoid unused method parameters such as 'aaa'. (view)

Rule Ruleset Priority
UnusedFormalParameter Best Practices 3

References:

You can close this issue if no need to fix it. Learn more.

@@ -65,4 +80,11 @@
executorService.scheduleAtFixedRate(new FetcherRunnable(store, fetcher), 0, configuration.getRefreshRateMinutes(), TimeUnit.MINUTES);
}

// expect error: length, number of vars, unused vars, duplication, unused
private void createScheduledFetcher2(LeaderBoardServerConfiguration configuration, Environment environment, GitHubApiFacade apiFacade, LeaderBoardStore store, String aaa, String bbb, String ccc, String ddd) {
Copy link

Choose a reason for hiding this comment

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

[PMD Java] Avoid unused method parameters such as 'bbb'. (view)

Rule Ruleset Priority
UnusedFormalParameter Best Practices 3

References:

You can close this issue if no need to fix it. Learn more.

@@ -65,4 +80,11 @@
executorService.scheduleAtFixedRate(new FetcherRunnable(store, fetcher), 0, configuration.getRefreshRateMinutes(), TimeUnit.MINUTES);
}

// expect error: length, number of vars, unused vars, duplication, unused
private void createScheduledFetcher2(LeaderBoardServerConfiguration configuration, Environment environment, GitHubApiFacade apiFacade, LeaderBoardStore store, String aaa, String bbb, String ccc, String ddd) {
Copy link

Choose a reason for hiding this comment

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

[PMD Java] Avoid unused method parameters such as 'ccc'. (view)

Rule Ruleset Priority
UnusedFormalParameter Best Practices 3

References:

You can close this issue if no need to fix it. Learn more.

@@ -65,4 +80,11 @@
executorService.scheduleAtFixedRate(new FetcherRunnable(store, fetcher), 0, configuration.getRefreshRateMinutes(), TimeUnit.MINUTES);
}

// expect error: length, number of vars, unused vars, duplication, unused
private void createScheduledFetcher2(LeaderBoardServerConfiguration configuration, Environment environment, GitHubApiFacade apiFacade, LeaderBoardStore store, String aaa, String bbb, String ccc, String ddd) {
Copy link

Choose a reason for hiding this comment

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

[PMD Java] Avoid unused private methods such as 'createScheduledFetcher2(LeaderBoardServerConfiguration,Environment,GitHubApiFacade,LeaderBoardStore,String,String,String,String)'. (view)

Rule Ruleset Priority
UnusedPrivateMethod Best Practices 3

References:

You can close this issue if no need to fix it. Learn more.

for (int i = 0; i < arr.length; i++) { // expect error: for loop
System.out.println(arr[i]); // expect error: println
}
if ("1" == "1") { // expect error: use equals
Copy link

Choose a reason for hiding this comment

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

[PMD Java] Use equals() to compare strings instead of '==' or '!=' (view)

Rule Ruleset Priority
UseEqualsToCompareStrings Error Prone 3

References:

You can close this issue if no need to fix it. Learn more.

@@ -45,7 +45,10 @@
createScheduledFetcher(configuration, environment, apiFacade, store);
}

protected GitHubApiFacade getApiFacade(LeaderBoardServerConfiguration configuration) {
// expect error: bad name
protected GitHubApiFacade GetApiFacade(LeaderBoardServerConfiguration configuration) {
Copy link

Choose a reason for hiding this comment

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

[Checkstyle] Name 'GetApiFacade' must match pattern '^[a-z][a-zA-Z0-9]*$'. (view)

Rule Severity
MethodNameCheck info

References:

You can close this issue if no need to fix it. Learn more.

@@ -65,4 +80,11 @@
executorService.scheduleAtFixedRate(new FetcherRunnable(store, fetcher), 0, configuration.getRefreshRateMinutes(), TimeUnit.MINUTES);
}

// expect error: length, number of vars, unused vars, duplication, unused
private void createScheduledFetcher2(LeaderBoardServerConfiguration configuration, Environment environment, GitHubApiFacade apiFacade, LeaderBoardStore store, String aaa, String bbb, String ccc, String ddd) {
Copy link

Choose a reason for hiding this comment

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

[Checkstyle] More than 7 parameters (found 8). (view)

Rule Severity
ParameterNumberCheck info

References:

You can close this issue if no need to fix it. Learn more.

for (int i = 0; i < arr.length; i++) { // expect error: for loop
System.out.println(arr[i]); // expect error: println
}
if ("1" == "1") { // expect error: use equals
Copy link

Choose a reason for hiding this comment

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

[Checkstyle] Literal Strings should be compared using equals(), not '=='. (view)

Rule Severity
StringLiteralEqualityCheck info

References:

You can close this issue if no need to fix it. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant