Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit c3baa91

Browse files
authored
Merge pull request #445 from hansenmc/cleanupLinting
Apply various code quality fixes, remove unused imports, use diamond operator, try-with-resources, etc
2 parents 67b3092 + ae90312 commit c3baa91

File tree

51 files changed

+94
-153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+94
-153
lines changed

src/main/java/com/marklogic/appdeployer/DefaultAppConfigFactory.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,7 @@ public void initialize() {
457457
logger.info("Databases that will have their forest(s) created on a single host: " + prop);
458458
String[] names = prop.split(",");
459459
Set<String> set = new HashSet<>();
460-
for (String name : names) {
461-
set.add(name);
462-
}
460+
set.addAll(Arrays.asList(names));
463461
config.setDatabasesWithForestsOnOneHost(set);
464462
});
465463

@@ -904,9 +902,7 @@ protected Map<String, List<String>> buildMapOfListsFromDelimitedString(String st
904902
String dbName = tokens[i];
905903
String[] hostNames = tokens[i + 1].split("\\|");
906904
List<String> names = new ArrayList<>();
907-
for (String name : hostNames) {
908-
names.add(name);
909-
}
905+
names.addAll(Arrays.asList(hostNames));
910906
map.put(dbName, names);
911907
}
912908
return map;

src/main/java/com/marklogic/appdeployer/cli/Main.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,8 @@ private static PropertySource buildPropertySource(Options options) throws IOExce
102102
if (logger.isInfoEnabled()) {
103103
logger.info("Reading properties from file path: " + propertiesFilePath);
104104
}
105-
FileInputStream fis = new FileInputStream(propertiesFilePath);
106-
try {
105+
try (FileInputStream fis = new FileInputStream(propertiesFilePath)) {
107106
props.load(fis);
108-
} finally {
109-
fis.close();
110107
}
111108

112109
// Dynamic params override what's in the properties file

src/main/java/com/marklogic/appdeployer/command/AbstractCommand.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ public void setFilenamesToIgnore(String... filenames) {
7575
} else {
7676
set = new HashSet<>();
7777
}
78-
for (String f : filenames) {
79-
set.add(f);
80-
}
78+
set.addAll(Arrays.asList(filenames));
8179
rff.setFilenamesToIgnore(set);
8280
} else {
8381
logger.warn("resourceFilenameFilter is not an instanceof ResourceFilenameFilter, so unable to set resource filenames to ignore");

src/main/java/com/marklogic/appdeployer/command/CommandMapBuilder.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,35 +92,35 @@ public List<Command> getCommandsForReplicaCluster() {
9292
}
9393

9494
private void addCommandsThatDoNotWriteToDatabases(Map<String, List<Command>> map) {
95-
List<Command> clusterCommands = new ArrayList<Command>();
95+
List<Command> clusterCommands = new ArrayList<>();
9696
clusterCommands.add(new ModifyLocalClusterCommand());
9797
map.put("mlClusterCommands", clusterCommands);
9898

9999
List<Command> configurationCommands = new ArrayList<>();
100100
configurationCommands.add(new DeployConfigurationsCommand());
101101
map.put("mlConfigurationCommands", configurationCommands);
102102

103-
List<Command> dbCommands = new ArrayList<Command>();
103+
List<Command> dbCommands = new ArrayList<>();
104104
dbCommands.add(new DeployOtherDatabasesCommand());
105105
map.put("mlDatabaseCommands", dbCommands);
106106

107-
List<Command> forestCommands = new ArrayList<Command>();
107+
List<Command> forestCommands = new ArrayList<>();
108108
forestCommands.add(new DeployCustomForestsCommand());
109109
map.put("mlForestCommands", forestCommands);
110110

111-
List<Command> replicaCommands = new ArrayList<Command>();
111+
List<Command> replicaCommands = new ArrayList<>();
112112
replicaCommands.add(new ConfigureForestReplicasCommand());
113113
map.put("mlForestReplicaCommands", replicaCommands);
114114

115-
List<Command> groupCommands = new ArrayList<Command>();
115+
List<Command> groupCommands = new ArrayList<>();
116116
groupCommands.add(new DeployGroupsCommand());
117117
map.put("mlGroupCommands", groupCommands);
118118

119-
List<Command> hostCommands = new ArrayList<Command>();
119+
List<Command> hostCommands = new ArrayList<>();
120120
hostCommands.add(new AssignHostsToGroupsCommand());
121121
map.put("mlHostCommands", hostCommands);
122122

123-
List<Command> mimetypeCommands = new ArrayList<Command>();
123+
List<Command> mimetypeCommands = new ArrayList<>();
124124
mimetypeCommands.add(new DeployMimetypesCommand());
125125
map.put("mlMimetypeCommands", mimetypeCommands);
126126

@@ -137,7 +137,7 @@ private void addCommandsThatDoNotWriteToDatabases(Map<String, List<Command>> map
137137
restApiCommands.add(new DeployRestApiServersCommand());
138138
map.put("mlRestApiCommands", restApiCommands);
139139

140-
List<Command> securityCommands = new ArrayList<Command>();
140+
List<Command> securityCommands = new ArrayList<>();
141141
securityCommands.add(new DeployRolesCommand());
142142
securityCommands.add(new DeployUsersCommand());
143143
securityCommands.add(new DeployAmpsCommand());
@@ -157,20 +157,20 @@ private void addCommandsThatDoNotWriteToDatabases(Map<String, List<Command>> map
157157
serverCommands.add(new UpdateRestApiServersCommand());
158158
map.put("mlServerCommands", serverCommands);
159159

160-
List<Command> taskCommands = new ArrayList<Command>();
160+
List<Command> taskCommands = new ArrayList<>();
161161
taskCommands.add(new DeployScheduledTasksCommand());
162162
taskCommands.add(new UpdateTaskServerCommand());
163163
map.put("mlTaskCommands", taskCommands);
164164
}
165165

166166
private void addCommandsThatWriteToDatabases(Map<String, List<Command>> map) {
167-
List<Command> alertCommands = new ArrayList<Command>();
167+
List<Command> alertCommands = new ArrayList<>();
168168
alertCommands.add(new DeployAlertConfigsCommand());
169169
alertCommands.add(new DeployAlertActionsCommand());
170170
alertCommands.add(new DeployAlertRulesCommand());
171171
map.put("mlAlertCommands", alertCommands);
172172

173-
List<Command> cpfCommands = new ArrayList<Command>();
173+
List<Command> cpfCommands = new ArrayList<>();
174174
cpfCommands.add(new DeployCpfConfigsCommand());
175175
cpfCommands.add(new DeployDomainsCommand());
176176
cpfCommands.add(new DeployPipelinesCommand());
@@ -180,7 +180,7 @@ private void addCommandsThatWriteToDatabases(Map<String, List<Command>> map) {
180180
dataCommands.add(new LoadDataCommand());
181181
map.put("mlDataCommands", dataCommands);
182182

183-
List<Command> flexrepCommands = new ArrayList<Command>();
183+
List<Command> flexrepCommands = new ArrayList<>();
184184
flexrepCommands.add(new DeployConfigsCommand());
185185
flexrepCommands.add(new DeployTargetsCommand());
186186
flexrepCommands.add(new DeployFlexrepCommand());
@@ -201,11 +201,11 @@ private void addCommandsThatWriteToDatabases(Map<String, List<Command>> map) {
201201
temporalCommands.add(new DeployTemporalCollectionsLSQTCommand());
202202
map.put("mlTemporalCommands", temporalCommands);
203203

204-
List<Command> triggerCommands = new ArrayList<Command>();
204+
List<Command> triggerCommands = new ArrayList<>();
205205
triggerCommands.add(new DeployTriggersCommand());
206206
map.put("mlTriggerCommands", triggerCommands);
207207

208-
List<Command> viewCommands = new ArrayList<Command>();
208+
List<Command> viewCommands = new ArrayList<>();
209209
viewCommands.add(new DeployViewSchemasCommand());
210210
map.put("mlViewCommands", viewCommands);
211211
}

src/main/java/com/marklogic/appdeployer/command/ResourceFilenameFilter.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.marklogic.client.ext.helper.LoggingObject;
44

55
import java.io.File;
6+
import java.util.Arrays;
67
import java.util.HashSet;
78
import java.util.Set;
89
import java.util.regex.Pattern;
@@ -38,9 +39,7 @@ public ResourceFilenameFilter(ResourceFileManager resourceFileManager) {
3839
public ResourceFilenameFilter(String... filenamesToIgnore) {
3940
this();
4041
this.filenamesToIgnore = new HashSet<>();
41-
for (String f : filenamesToIgnore) {
42-
this.filenamesToIgnore.add(f);
43-
}
42+
this.filenamesToIgnore.addAll(Arrays.asList(filenamesToIgnore));
4443
}
4544

4645
public ResourceFilenameFilter(Set<String> filenamesToIgnore) {

src/main/java/com/marklogic/appdeployer/command/alert/DeployAlertRulesCommand.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.marklogic.appdeployer.command.alert;
22

3-
import java.io.File;
4-
53
import com.marklogic.appdeployer.AppConfig;
64
import com.marklogic.appdeployer.ConfigDir;
75
import com.marklogic.appdeployer.command.AbstractCommand;

src/main/java/com/marklogic/appdeployer/command/databases/DeployDatabaseCommand.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import com.marklogic.appdeployer.command.UndoableCommand;
99
import com.marklogic.appdeployer.command.forests.DeployForestsCommand;
1010
import com.marklogic.mgmt.PayloadParser;
11-
import com.marklogic.mgmt.SaveReceipt;
1211
import com.marklogic.mgmt.api.database.Database;
1312
import com.marklogic.mgmt.resource.databases.DatabaseManager;
1413

src/main/java/com/marklogic/appdeployer/command/databases/DeployOtherDatabasesCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ protected List<DatabasePlan> mergeDatabasePlanFiles(CommandContext context, Data
249249
ObjectReader objectReader = ObjectMapperFactory.getObjectMapper().readerFor(Database.class);
250250

251251
List<DatabasePlan> databasePlanList = new ArrayList<>();
252-
databasePlans.getDatabasePlanMap().values().forEach(ref -> databasePlanList.add(ref));
252+
databasePlanList.addAll(databasePlans.getDatabasePlanMap().values());
253253

254254
DatabasePlan testDatabasePlan = null;
255255

src/main/java/com/marklogic/appdeployer/command/databases/DeploySubDatabasesCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void execute(CommandContext context) {
3737
}
3838

3939
if (subdbDir.exists()) {
40-
List<String> subDbNames = new ArrayList<String>();
40+
List<String> subDbNames = new ArrayList<>();
4141
for (File subDatabaseFile : listFilesInDirectory(subdbDir)) {
4242
logger.info(format("Processing sub-database for %s found in file: %s", superDatabaseName, subDatabaseFile.getAbsolutePath()));
4343

src/main/java/com/marklogic/appdeployer/command/flexrep/DeployTargetsCommand.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
package com.marklogic.appdeployer.command.flexrep;
22

3-
import java.io.File;
4-
53
import com.marklogic.appdeployer.AppConfig;
64
import com.marklogic.appdeployer.ConfigDir;
75
import com.marklogic.appdeployer.command.AbstractCommand;
86
import com.marklogic.appdeployer.command.CommandContext;
97
import com.marklogic.appdeployer.command.SortOrderConstants;
10-
import com.marklogic.mgmt.ManageClient;
118
import com.marklogic.mgmt.SaveReceipt;
129
import com.marklogic.mgmt.resource.flexrep.TargetManager;
1310

1411
import java.io.File;
15-
import java.net.URI;
1612

1713
/**
1814
* The directory structure for this is a bit different from most command. Since targets belong to a certain flexrep

0 commit comments

Comments
 (0)