Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void initialize(Bootstrap<LeaderBoardServerConfiguration> bootstrap) {

@Override
public void run(LeaderBoardServerConfiguration configuration, Environment environment) {
GitHubApiFacade apiFacade = getApiFacade(configuration);
GitHubApiFacade apiFacade = GetApiFacade(configuration);
LeaderBoardStore store = getStore(apiFacade);

environment.addHealthCheck(new GitHubCredentialsHealthCheck(apiFacade, configuration.getOrganization()));
Expand All @@ -45,7 +45,10 @@ public void run(LeaderBoardServerConfiguration configuration, Environment enviro
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)

Details
Rule Severity
MethodNameCheck info

References:

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

String a = null;
int i = a.length(); // expect error: null
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 local variables such as 'i'. (view)

Details
Rule Ruleset Priority
UnusedLocalVariable Best Practices 3

References:

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

GitHubCredentials credsConfig = configuration.getGitHubCredentials();
final Credentials credentials = new CredentialsFactory().build(
credsConfig.getUsername(),
Expand All @@ -54,6 +57,18 @@ protected GitHubApiFacade getApiFacade(LeaderBoardServerConfiguration configurat
return new GitHubApiFacadeImpl(credentials, configuration.getGitHubApiUrl());
}

// expect error: unused
private String unused() {
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 'unused()'. (view)

Details
Rule Ruleset Priority
UnusedPrivateMethod Best Practices 3

References:

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

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)

Details
Rule Ruleset Priority
ForLoopCanBeForeach Best Practices 3

References:

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

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.

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)

Details
Rule Ruleset Priority
CompareObjectsWithEquals Error Prone 3

References:

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

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)

Details
Rule Ruleset Priority
UseEqualsToCompareStrings Error Prone 3

References:

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

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)

Details
Rule Severity
StringLiteralEqualityCheck info

References:

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

return "a";
}
return null;
}

private LeaderBoardStore getStore(GitHubApiFacade apiFacade) {
EmojiStore emojiStore = new EmojiStore(apiFacade);
return new LeaderBoardStore(new Clock(), emojiStore);
Expand All @@ -65,4 +80,11 @@ private void createScheduledFetcher(LeaderBoardServerConfiguration configuration
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)

Details
Rule Ruleset Priority
UnusedFormalParameter Best Practices 3

References:

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

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)

Details
Rule Ruleset Priority
UnusedFormalParameter Best Practices 3

References:

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

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)

Details
Rule Ruleset Priority
UnusedFormalParameter Best Practices 3

References:

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

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 'ddd'. (view)

Details
Rule Ruleset Priority
UnusedFormalParameter Best Practices 3

References:

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

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)

Details
Rule Ruleset Priority
UnusedPrivateMethod Best Practices 3

References:

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

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)

Details
Rule Severity
ParameterNumberCheck info

References:

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

ScheduledExecutorService executorService = environment.managedScheduledExecutorService("comment-fetcher", 1);
final CommentFetcher fetcher = new CommentFetcher(apiFacade, configuration.getOrganization(), configuration.getRepositories(), Period.getLongest().getDaysBack());
executorService.scheduleAtFixedRate(new FetcherRunnable(store, fetcher), 0, configuration.getRefreshRateMinutes(), TimeUnit.MINUTES);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void setUp() throws Exception {
when(environment.managedScheduledExecutorService(anyString(), anyInt())).thenReturn(executorService);
this.service = new LeaderBoardService() {
@Override
protected GitHubApiFacade getApiFacade(LeaderBoardServerConfiguration configuration) {
protected GitHubApiFacade GetApiFacade(LeaderBoardServerConfiguration configuration) {
return apiFacade;
}
};
Expand Down