-
Notifications
You must be signed in to change notification settings - Fork 25
DO NOT MERGE: bad code for testing reviewer bots #40
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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())); | ||||||||||||||||||||||||||||||||||||
|
|
@@ -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) { | ||||||||||||||||||||||||||||||||||||
| String a = null; | ||||||||||||||||||||||||||||||||||||
| int i = a.length(); // expect error: null | ||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [PMD Java] Avoid unused local variables such as 'i'. (view) Details
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(), | ||||||||||||||||||||||||||||||||||||
|
|
@@ -54,6 +57,18 @@ protected GitHubApiFacade getApiFacade(LeaderBoardServerConfiguration configurat | |||||||||||||||||||||||||||||||||||
| return new GitHubApiFacadeImpl(credentials, configuration.getGitHubApiUrl()); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // expect error: unused | ||||||||||||||||||||||||||||||||||||
| private String unused() { | ||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [PMD Java] Avoid unused private methods such as 'unused()'. (view) Details
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 | ||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
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 | ||||||||||||||||||||||||||||||||||||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [PMD Java] Use equals() to compare object references. (view) Details
References: You can close this issue if no need to fix it. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [PMD Java] Use equals() to compare strings instead of '==' or '!=' (view) Details
References: You can close this issue if no need to fix it. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Checkstyle] Literal Strings should be compared using equals(), not '=='. (view) Details
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); | ||||||||||||||||||||||||||||||||||||
|
|
@@ -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) { | ||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [PMD Java] Avoid unused method parameters such as 'aaa'. (view) Details
References: You can close this issue if no need to fix it. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [PMD Java] Avoid unused method parameters such as 'bbb'. (view) Details
References: You can close this issue if no need to fix it. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [PMD Java] Avoid unused method parameters such as 'ccc'. (view) Details
References: You can close this issue if no need to fix it. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [PMD Java] Avoid unused method parameters such as 'ddd'. (view) Details
References: You can close this issue if no need to fix it. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
References: You can close this issue if no need to fix it. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Checkstyle] More than 7 parameters (found 8). (view) Details
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); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
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
MethodNameCheckinfoReferences:
You can close this issue if no need to fix it. Learn more.