Skip to content

Commit 57a1708

Browse files
Auto-refactor lint cleanup
SequencedCollections: get(0) -> getFirst(), etc Add missing @NotNull/@nullable Simplify test assertions Map operation simplification Remove redundant throws clause Switch to parameterized log message C-style array -> Java-style array declaration Delete overridden methods identical to parent Switch statement -> enhanced switch statement Remove redundant imports
1 parent 0af6963 commit 57a1708

29 files changed

Lines changed: 102 additions & 368 deletions

LDK/api-src/org/labkey/api/ldk/ExtendedSimpleModule.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@
1717

1818
import jakarta.servlet.http.HttpServletRequest;
1919
import org.jetbrains.annotations.Nullable;
20-
import org.labkey.api.data.Container;
2120
import org.labkey.api.module.ModuleContext;
2221
import org.labkey.api.module.SimpleController;
2322
import org.labkey.api.module.SimpleModule;
24-
import org.labkey.api.security.User;
25-
import org.labkey.api.view.ActionURL;
2623
import org.springframework.context.ApplicationContextAware;
2724
import org.springframework.web.servlet.mvc.Controller;
2825

@@ -64,12 +61,6 @@ public String getResourcePath()
6461
return "/" + getClass().getPackage().getName().replaceAll("\\.", "/");
6562
}
6663

67-
@Override
68-
public ActionURL getTabURL(Container c, User user)
69-
{
70-
return SimpleController.getBeginViewUrl(this, c);
71-
}
72-
7364
@Override
7465
public boolean hasScripts()
7566
{

LDK/api-src/org/labkey/api/ldk/table/AbstractDataDefinedTable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public CustomPermissionsTable<SchemaType> init()
8686

8787
List<String> pks = getRealTable().getPkColumnNames();
8888
assert !pks.isEmpty();
89-
_pk = pks.get(0);
89+
_pk = pks.getFirst();
9090

9191
var valueCol = getMutableColumn(_valueColumn);
9292
assert valueCol != null;

LDK/api-src/org/labkey/api/ldk/table/ContainerScopedTable.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.labkey.api.data.ContainerFilter;
2929
import org.labkey.api.data.ContainerManager;
3030
import org.labkey.api.data.ContainerType;
31-
import org.labkey.api.data.ConvertHelper;
3231
import org.labkey.api.data.SimpleFilter;
3332
import org.labkey.api.data.TableInfo;
3433
import org.labkey.api.data.TableSelector;
@@ -138,7 +137,7 @@ private ColumnInfo getPkCol()
138137
{
139138
assert _rootTable.getPkColumnNames().size() == 1;
140139

141-
return _rootTable.getPkColumns().get(0);
140+
return _rootTable.getPkColumns().getFirst();
142141
}
143142

144143
@Override
@@ -324,7 +323,7 @@ public boolean rowExists(Container c, Object key)
324323
}
325324
catch (ConversionException e)
326325
{
327-
_log.error("Unable to convert value for column: " + _pseudoPk + " to class: " + pkCol.getJavaClass() + " for table: " + getPublicSchemaName() + "." + getName(), e);
326+
_log.error("Unable to convert value for column: {} to class: {} for table: {}.{}", _pseudoPk, pkCol.getJavaClass(), getPublicSchemaName(), getName(), e);
328327
return false;
329328
}
330329

LDK/api-src/org/labkey/api/ldk/table/QueryCache.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public TableInfo getTableInfo(Container targetContainer, User u, String schemaPa
106106
TableInfo ti = qd.getTable(errors, true);
107107
if (!errors.isEmpty())
108108
{
109-
_log.error("Unable to create tabbed report item for query: " + schemaPath + "." + queryName + " in " + targetContainer.getPath());
109+
_log.error("Unable to create tabbed report item for query: {}.{} in {}", schemaPath, queryName, targetContainer.getPath());
110110
for (QueryException e : errors)
111111
{
112112
_log.error(e.getMessage(), e);
@@ -116,7 +116,7 @@ public TableInfo getTableInfo(Container targetContainer, User u, String schemaPa
116116

117117
if (ti == null)
118118
{
119-
_log.info("TableInfo was null: " + schemaPath + "/" + queryName + " in container: " + targetContainer.getPath(), new Exception());
119+
_log.info("TableInfo was null: {}/{} in container: {}", schemaPath, queryName, targetContainer.getPath(), new Exception());
120120
return null;
121121
}
122122

@@ -140,7 +140,7 @@ public void cache(TableInfo ti)
140140

141141
if (ti.getUserSchema() == null)
142142
{
143-
_log.warn("TableInfo lacks a user schema: " + ti.getPublicSchemaName() + "." + ti.getName(), new Exception());
143+
_log.warn("TableInfo lacks a user schema: {}.{}", ti.getPublicSchemaName(), ti.getName(), new Exception());
144144
return;
145145
}
146146

LDK/src/org/labkey/ldk/LDKController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ public ModelAndView getView(QueryForm form, BindException errors) throws Excepti
834834
List<String> pks = ti.getPkColumnNames();
835835
String keyField = null;
836836
if (pks.size() == 1)
837-
keyField = pks.get(0);
837+
keyField = pks.getFirst();
838838

839839
ActionURL url = getViewContext().getActionURL().clone();
840840

LDK/src/org/labkey/ldk/LDKServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public List<String> validateContainerScopedTables(boolean onlyReportErrors)
240240
DbSchema schema = DbSchema.get(values.get(0));
241241
if (schema == null)
242242
{
243-
messages.add("Unknown schema: " + values.get(0));
243+
messages.add("Unknown schema: " + values.getFirst());
244244
continue;
245245
}
246246

LDK/src/org/labkey/ldk/notification/NotificationJob.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void execute(JobExecutionContext context) throws JobExecutionException
3939
return;
4040
}
4141

42-
_log.info("Trying to run notification: " + _notification.getName());
42+
_log.info("Trying to run notification: {}", _notification.getName());
4343

4444
Set<Container> activeContainers = NotificationServiceImpl.get().getActiveContainers(_notification);
4545
if (activeContainers.isEmpty())

LDK/src/org/labkey/ldk/notification/NotificationServiceImpl.java

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@
6262
import org.quartz.impl.StdSchedulerFactory;
6363

6464
import java.io.IOException;
65-
import java.sql.ResultSet;
66-
import java.sql.SQLException;
6765
import java.util.ArrayList;
6866
import java.util.Collections;
6967
import java.util.Date;
@@ -122,7 +120,7 @@ private Set<Container> getEnabledContainers()
122120
@Override
123121
public void registerNotification(Notification notification)
124122
{
125-
_log.info("Registering notification: " + notification.getName());
123+
_log.info("Registering notification: {}", notification.getName());
126124
_notifications.add(notification);
127125

128126
try
@@ -508,18 +506,13 @@ public Set<UserPrincipal> getRecipients(Notification n, Container c)
508506
TableSelector ts = new TableSelector(t, Collections.singleton("recipient"), filter, null);
509507
if (ts.getRowCount() > 0)
510508
{
511-
ts.forEach(new TableSelector.ForEachBlock<>()
512-
{
513-
@Override
514-
public void exec(ResultSet rs) throws SQLException
515-
{
516-
int userId = rs.getInt("recipient");
517-
UserPrincipal u = SecurityManager.getPrincipal(userId);
518-
if (u != null)
519-
recipients.add(u);
520-
else
521-
_log.error("unknown user registered with " + n.getName() + "notification: " + userId);
522-
}
509+
ts.forEach(rs -> {
510+
int userId = rs.getInt("recipient");
511+
UserPrincipal u = SecurityManager.getPrincipal(userId);
512+
if (u != null)
513+
recipients.add(u);
514+
else
515+
_log.error("unknown user registered with {}notification: {}", n.getName(), userId);
523516
});
524517
}
525518

@@ -644,26 +637,26 @@ public void runForContainer(Notification notification, Container c)
644637
User u = NotificationService.get().getUser(notification, c);
645638
if (u == null)
646639
{
647-
_log.error("Invalid user when trying to run notification " + notification.getName() + " for container: " + c.getPath());
640+
_log.error("Invalid user when trying to run notification {} for container: {}", notification.getName(), c.getPath());
648641
return;
649642
}
650643

651644
if (!c.hasPermission(u, AdminPermission.class))
652645
{
653-
_log.error("Error running " + notification.getName() + ". User " + u.getEmail() + " does not have admin permissions on container: " + c.getPath());
646+
_log.error("Error running {}. User {} does not have admin permissions on container: {}", notification.getName(), u.getEmail(), c.getPath());
654647
return;
655648
}
656649

657650
if (!NotificationServiceImpl.get().isActive(notification, c))
658651
{
659-
_log.error("Error running " + notification.getName() + " in container : " + c.getPath() + ". Notification is inactive, but a task was still scheduled");
652+
_log.error("Error running {} in container : {}. Notification is inactive, but a task was still scheduled", notification.getName(), c.getPath());
660653
return;
661654
}
662655

663656
List<Address> recipients = NotificationServiceImpl.get().getEmails(notification, c);
664657
if (recipients.isEmpty())
665658
{
666-
_log.info("Notification: " + notification.getName() + " has no recipients, skipping");
659+
_log.info("Notification: {} has no recipients, skipping", notification.getName());
667660
return;
668661
}
669662

@@ -672,11 +665,11 @@ public void runForContainer(Notification notification, Container c)
672665
MimeMessage mail = notification.createMessage(c, u);
673666
if (mail == null)
674667
{
675-
_log.info("Notification " + notification.getName() + " did not produce a message, will not send email");
668+
_log.info("Notification {} did not produce a message, will not send email", notification.getName());
676669
return;
677670
}
678671

679-
_log.info("Sending message for notification: " + notification.getName() + " to " + recipients.size() + " recipients");
672+
_log.info("Sending message for notification: {} to {} recipients", notification.getName(), recipients.size());
680673

681674
mail.setFrom(NotificationServiceImpl.get().getReturnEmail(c));
682675
mail.setSubject(notification.getEmailSubject(c));

LDK/src/org/labkey/ldk/query/BuiltInColumnsCustomizer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void customize(TableInfo table)
4141

4242
if (table.isLocked())
4343
{
44-
_log.debug("BuildInColumnsCustomizer called on a locked table: " + table.getPublicSchemaName() + " / " + table.getName(), new Exception());
44+
_log.debug("BuildInColumnsCustomizer called on a locked table: {} / {}", table.getPublicSchemaName(), table.getName(), new Exception());
4545
return;
4646
}
4747

@@ -144,7 +144,7 @@ public static void processColumn(MutableColumnInfo col)
144144
{
145145
if (col.isLocked())
146146
{
147-
_log.debug("BuiltInColumnsCustomizer was called on a locked column: " + col.getName(), new Exception());
147+
_log.debug("BuiltInColumnsCustomizer was called on a locked column: {}", col.getName(), new Exception());
148148
return;
149149
}
150150

LDK/src/org/labkey/ldk/query/DefaultTableCustomizer.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ public void customize(TableInfo table)
8484
{
8585
if (table.isLocked())
8686
{
87-
_log.debug("DefaultTableCustomizer called on a locked table: " + table.getPublicSchemaName() + " / " + table.getName(), new Exception());
87+
_log.debug("DefaultTableCustomizer called on a locked table: {} / {}", table.getPublicSchemaName(), table.getName(), new Exception());
8888
return;
8989
}
9090

9191
if (table instanceof SchemaTableInfo)
92-
_log.error("Table customizer is being passed a SchemaTableInfo for: " + table.getPublicSchemaName() + "." + table.getPublicName());
92+
_log.error("Table customizer is being passed a SchemaTableInfo for: {}.{}", table.getPublicSchemaName(), table.getPublicName());
9393
else if (table instanceof AbstractTableInfo)
9494
customizeAbstractTableInfo((AbstractTableInfo)table);
9595
}
@@ -128,7 +128,7 @@ private void setDetailsUrl(AbstractTableInfo ti)
128128
List<String> keyFields = ti.getPkColumnNames();
129129
if (keyFields.isEmpty())
130130
{
131-
_log.debug("No key fields found for the table, cannot set details URL: " + ti.getPublicSchemaName() + "." + ti.getPublicName());
131+
_log.debug("No key fields found for the table, cannot set details URL: {}.{}", ti.getPublicSchemaName(), ti.getPublicName());
132132
return;
133133
}
134134

@@ -137,7 +137,7 @@ private void setDetailsUrl(AbstractTableInfo ti)
137137
String alternatePK = _settings.getPrimaryKeyField();
138138
if (!keyFields.contains(alternatePK))
139139
{
140-
_log.error("Table: " + ti.getUserSchema().getSchemaName() + "." + ti.getPublicName() + " supplied an alternate primaryKeyField that doesnt match actual PKs: " + alternatePK);
140+
_log.error("Table: {}.{} supplied an alternate primaryKeyField that doesnt match actual PKs: {}", ti.getUserSchema().getSchemaName(), ti.getPublicName(), alternatePK);
141141
return;
142142
}
143143

@@ -150,11 +150,11 @@ private void setDetailsUrl(AbstractTableInfo ti)
150150
}
151151
else if (keyFields.size() > 1)
152152
{
153-
_log.error("Table: " + ti.getUserSchema().getSchemaName() + "." + ti.getPublicName() + " has more than 1 PK: " + StringUtils.join(keyFields, ";") + ", cannot apply custom links - please update the TableCustomizer properties");
153+
_log.error("Table: {}.{} has more than 1 PK: {}, cannot apply custom links - please update the TableCustomizer properties", ti.getUserSchema().getSchemaName(), ti.getPublicName(), StringUtils.join(keyFields, ";"));
154154
return;
155155
}
156156

157-
String keyField = keyFields.get(0);
157+
String keyField = keyFields.getFirst();
158158
StringExpression se = ti.getDetailsURL(null, ti.getUserSchema().getContainer());
159159
// Handle a null source string, which you get when the URL is a AbstractTableInfo.LINK_DISABLER. See issue 39403
160160
if (se == null || se.toString() == null || se.toString().contains("detailsQueryRow"))
@@ -191,7 +191,7 @@ else if (_settings.isSetEditLinkOverrides())
191191
return;
192192
}
193193

194-
_log.debug("No key fields found for the table, cannot customize edit UI: " + ti.getPublicSchemaName() + "." + ti.getPublicName());
194+
_log.debug("No key fields found for the table, cannot customize edit UI: {}.{}", ti.getPublicSchemaName(), ti.getPublicName());
195195
return;
196196
}
197197

@@ -200,7 +200,7 @@ else if (_settings.isSetEditLinkOverrides())
200200
String alternatePK = _settings.getPrimaryKeyField();
201201
if (!keyFields.contains(alternatePK))
202202
{
203-
_log.error("Table: " + ti.getUserSchema().getSchemaName() + "." + ti.getPublicName() + " supplied an alternate primaryKeyField that doesnt match actual PKs: " + alternatePK);
203+
_log.error("Table: {}.{} supplied an alternate primaryKeyField that doesnt match actual PKs: {}", ti.getUserSchema().getSchemaName(), ti.getPublicName(), alternatePK);
204204
return;
205205
}
206206

@@ -213,13 +213,13 @@ else if (_settings.isSetEditLinkOverrides())
213213
}
214214
else if (keyFields.size() != 1)
215215
{
216-
_log.error("Table: " + schemaName + "." + queryName + " has more than 1 PK: " + StringUtils.join(keyFields, ";") + ", cannot apply custom links - please update the TableCustomizer properties");
216+
_log.error("Table: {}.{} has more than 1 PK: {}, cannot apply custom links - please update the TableCustomizer properties", schemaName, queryName, StringUtils.join(keyFields, ";"));
217217
return;
218218
}
219219

220220
if (schemaName != null && queryName != null)
221221
{
222-
String keyField = keyFields.get(0);
222+
String keyField = keyFields.getFirst();
223223
if (!AbstractTableInfo.LINK_DISABLER_ACTION_URL.equals(ti.getImportDataURL(ti.getUserSchema().getContainer())))
224224
ti.setImportURL(DetailsURL.fromString("/query/importData.view?schemaName=" + schemaName + "&query.queryName=" + queryName + "&keyField=" + keyField + "&bulkImport=true"));
225225

@@ -290,7 +290,7 @@ private static void appendEnddate(AbstractTableInfo ti, String sourceColName)
290290
ColumnInfo sourceCol = ti.getColumn(sourceColName);
291291
if (sourceCol == null)
292292
{
293-
_log.error("Unable to find column: " + sourceColName + " on table " + ti.getSelectName());
293+
_log.error("Unable to find column: {} on table {}", sourceColName, ti.getSelectName());
294294
return;
295295
}
296296

@@ -329,7 +329,7 @@ private static void appendDateOnly(AbstractTableInfo ti, String sourceColName)
329329
ColumnInfo sourceCol = ti.getColumn(sourceColName);
330330
if (sourceCol == null)
331331
{
332-
_log.error("Unable to find column: " + sourceColName + " on table " + ti.getName());
332+
_log.error("Unable to find column: {} on table {}", sourceColName, ti.getName());
333333
return;
334334
}
335335

@@ -533,15 +533,15 @@ public Settings(MultiValuedMap<String, String> props)
533533
{
534534
if (props.get(p.name()).size() > 1)
535535
{
536-
_log.error("Multiple values provided for property: " + p.name() + ", values: " + StringUtils.join(props.get(p.name()), ";"));
536+
_log.error("Multiple values provided for property: {}, values: {}", p.name(), StringUtils.join(props.get(p.name()), ";"));
537537
}
538538

539539
try
540540
{
541541
Collection<String> c = props.get(p.name());
542542
if (c.size() > 1)
543543
{
544-
_log.error("More than one value supplied for property: " + p.name() + " in table XML, values: " + StringUtils.join(c, ";"));
544+
_log.error("More than one value supplied for property: {} in table XML, values: {}", p.name(), StringUtils.join(c, ";"));
545545
}
546546

547547
if (!c.isEmpty())
@@ -551,7 +551,7 @@ public Settings(MultiValuedMap<String, String> props)
551551
}
552552
catch (ConversionException e)
553553
{
554-
_log.error("Unable to type convert property " + p.name() + ", value: " + props.get(p.name()).iterator().next());
554+
_log.error("Unable to type convert property {}, value: {}", p.name(), props.get(p.name()).iterator().next());
555555
}
556556
}
557557
}
@@ -582,7 +582,7 @@ public AuditBehaviorType getAuditMode()
582582
}
583583
catch (IllegalArgumentException e)
584584
{
585-
_log.error("Unable to parse auditMode in TableCustomizer: " + getProperty(PROPERIES.auditMode));
585+
_log.error("Unable to parse auditMode in TableCustomizer: {}", getProperty(PROPERIES.auditMode));
586586
}
587587

588588
return AuditBehaviorType.DETAILED;

0 commit comments

Comments
 (0)