Fix some issues caught by IntelliJ static code analysis

The most common issues were:
* Arrays.asList() shouldn't be called with a single parameter.
* Broken Javadoc @links.
* Unnecessary casts and type declarations.
* Unnecessary unused variable initializations.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=230994311
This commit is contained in:
mcilwain 2019-01-25 16:53:20 -08:00 committed by Ben McIlwain
parent 3cf26ff9b6
commit c6e58d3bff
39 changed files with 132 additions and 165 deletions

View file

@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package google.registry.tools;
/**
* Marker interface for commands that use the remote api.
*
* <p>Just implementing this is sufficient to use the remote api; {@link RegistryTool} will
* install it as needed.
* <p>Just implementing this is sufficient to use the remote api; {@link RegistryTool} will install
* it as needed.
*/
package google.registry.tools;
interface CommandWithRemoteApi extends Command {}

View file

@ -43,10 +43,12 @@ final class GetResourceByKeyCommand implements CommandWithRemoteApi {
public void run() {
for (String keyString : mainParameters) {
System.out.println("\n");
Key<EppResource> resourceKey = checkNotNull(
Key.<EppResource>create(keyString), "Could not parse key string: " + keyString);
EppResource resource = checkNotNull(
ofy().load().key(resourceKey).now(), "Could not load resource for key: " + resourceKey);
Key<EppResource> resourceKey =
checkNotNull(Key.create(keyString), "Could not parse key string: " + keyString);
EppResource resource =
checkNotNull(
ofy().load().key(resourceKey).now(),
"Could not load resource for key: " + resourceKey);
System.out.println(expand ? resource.toHydratedString() : resource.toString());
}
}

View file

@ -131,7 +131,7 @@ final class ValidateEscrowDepositCommand implements Command {
}
}
System.out.println();
System.out.printf("Contents:\n");
System.out.println("Contents:");
for (Map.Entry<String, Long> count : counts.entrySet()) {
System.out.printf(" - %s: %,d %s\n",
count.getKey(),
@ -158,9 +158,9 @@ final class ValidateEscrowDepositCommand implements Command {
good = false;
}
if (good) {
System.out.printf("RDE deposit is XML schema valid\n");
System.out.println("RDE deposit is XML schema valid");
} else {
System.out.printf("RDE deposit is XML schema valid but has bad references\n");
System.out.println("RDE deposit is XML schema valid but has bad references");
}
}

View file

@ -83,13 +83,13 @@ public class CreateGroupsAction implements Runnable {
// that type.
groupsConnection.createGroup(groupKey);
groupsConnection.addMemberToGroup(parentGroup, groupKey, Role.MEMBER);
return Optional.<Exception>empty();
return Optional.empty();
} catch (Exception e) {
return Optional.of(e);
}
});
// Return the correct server response based on the results of the group creations.
if (results.stream().filter(Optional::isPresent).count() > 0) {
if (results.stream().anyMatch(Optional::isPresent)) {
StringWriter responseString = new StringWriter();
PrintWriter responseWriter = new PrintWriter(responseString);
for (int i = 0; i < results.size(); i++) {