Skip to content

Commit 92b85d3

Browse files
authored
Updates from code inspection (#156)
1 parent be19df4 commit 92b85d3

File tree

50 files changed

+153
-177
lines changed

Some content is hidden

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

50 files changed

+153
-177
lines changed

LDK/api-src/org/labkey/api/ldk/notification/NotificationSection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626
public interface NotificationSection
2727
{
28-
public String getMessage(Container c, User u);
28+
String getMessage(Container c, User u);
2929

30-
public boolean isAvailable(Container c, User u);
30+
boolean isAvailable(Container c, User u);
3131
}

LDK/resources/web/LDK/calendar/src/view/AbstractCalendar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ Ext.define('Ext.calendar.view.AbstractCalendar', {
523523
this.doAddFx(this.getEventEls(rec.data[Ext.calendar.data.EventMappings.EventId.name]), {
524524
scope: this
525525
});
526-
};
526+
}
527527
},
528528

529529
doAddFx: function(els, o) {

LDK/resources/web/LDK/panel/TabbedReportPanel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,7 @@ Ext4.define('LDK.panel.TabbedReportPanel', {
14181418
console.log('param is too long for URL: ' + i + '/' + filters[i].length);
14191419
}
14201420
else if (['removable', 'nonRemovable'].indexOf(i) !== -1){
1421-
continue;
1421+
14221422
}
14231423
else {
14241424
token.push(i + ':' + filters[i]);

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
public class LDKController extends SpringActionController
105105
{
106106
private static final DefaultActionResolver _actionResolver = new DefaultActionResolver(LDKController.class);
107-
private static Logger _log = LogManager.getLogger(LDKController.class);
107+
private static final Logger _log = LogManager.getLogger(LDKController.class);
108108

109109
public LDKController()
110110
{
@@ -445,11 +445,10 @@ public ModelAndView getView(Object form, BindException errors) throws Exception
445445
LDKServiceImpl service = (LDKServiceImpl)LDKServiceImpl.get();
446446
List<String> messages = service.validateContainerScopedTables(false);
447447

448-
StringBuilder sb = new StringBuilder();
449-
sb.append("This page is designed to inspect all registered container scoped tables and report any tables with duplicate keys in the same container. This should be enforced by the user schema; however, direct DB inserts will bypass this check.<p>");
450-
sb.append(StringUtils.join(messages, "<br>"));
448+
String sb = "This page is designed to inspect all registered container scoped tables and report any tables with duplicate keys in the same container. This should be enforced by the user schema; however, direct DB inserts will bypass this check.<p>" +
449+
StringUtils.join(messages, "<br>");
451450

452-
return new HtmlView(sb.toString());
451+
return new HtmlView(sb);
453452
}
454453

455454
@Override
@@ -914,11 +913,10 @@ public ModelAndView getConfirmView(MoveWorkbookForm form, BindException errors)
914913
return new SimpleErrorView(errors);
915914
}
916915

917-
StringBuilder sb = new StringBuilder();
918-
sb.append("This will move this workbook to the selected folder, renaming this workbook to match the series in that container. Note: there are many reasons this can be problematic, so please do this with great care<p>");
919-
sb.append("<input name=\"targetContainer\" type=\"text\"></input>");
916+
String sb = "This will move this workbook to the selected folder, renaming this workbook to match the series in that container. Note: there are many reasons this can be problematic, so please do this with great care<p>" +
917+
"<input name=\"targetContainer\" type=\"text\"></input>";
920918

921-
return new HtmlView(sb.toString());
919+
return new HtmlView(sb);
922920
}
923921

924922
@Override

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@
5757
public class LDKServiceImpl extends LDKService
5858
{
5959
private static final Logger _log = LogManager.getLogger(LDKServiceImpl.class);
60-
private Set<NotificationSection> _summaryNotificationSections = new HashSet<>();
61-
private List<List<String>> _containerScopedTables = new ArrayList<>();
60+
private final Set<NotificationSection> _summaryNotificationSections = new HashSet<>();
61+
private final List<List<String>> _containerScopedTables = new ArrayList<>();
6262
private Boolean _isNaturalizeInstalled = null;
63-
private Map<String, Map<String, List<ButtonConfigFactory>>> _queryButtons = new CaseInsensitiveHashMap<Map<String, List<ButtonConfigFactory>>>();
63+
private final Map<String, Map<String, List<ButtonConfigFactory>>> _queryButtons = new CaseInsensitiveHashMap<Map<String, List<ButtonConfigFactory>>>();
6464
private static final String BACKGROUND_USER_PROPNAME = "BackgroundAdminUser";
6565

6666
public LDKServiceImpl()

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ public class NotificationServiceImpl extends NotificationService
8888
private static final String RETURN_EMAIL = "returnEmail";
8989
private static final String USER_PROP = "user";
9090

91-
private List<Notification> _notifications = new ArrayList<>();
92-
private Map<Notification, Trigger> _triggerMap = new HashMap<>();
91+
private final List<Notification> _notifications = new ArrayList<>();
92+
private final Map<Notification, Trigger> _triggerMap = new HashMap<>();
9393

9494
public static NotificationServiceImpl get()
9595
{
@@ -292,9 +292,8 @@ public JSONObject getJson(Notification n, Container c, User u)
292292
List<UserPrincipal> ups = new ArrayList<>();
293293
for (UserPrincipal up : NotificationServiceImpl.get().getRecipients(n, c))
294294
{
295-
if (up instanceof Group)
295+
if (up instanceof Group g)
296296
{
297-
Group g = (Group)up;
298297
Set<UserPrincipal> members = SecurityManager.getAllGroupMembers(g, MemberType.ALL_GROUPS_AND_USERS);
299298
if (members.contains(u))
300299
ups.add(up);
@@ -376,7 +375,7 @@ public List<Address> getEmailsForPrincipal(UserPrincipal user) throws ValidEmail
376375
{
377376
if (user instanceof User)
378377
{
379-
if (!((User) user).isActive())
378+
if (!user.isActive())
380379
{
381380
//_log.error("an inactive user is a notification recipient: " + user.getName());
382381
return Collections.emptyList();
@@ -461,7 +460,7 @@ public User getUser(Notification n, Container c)
461460
public Set<UserPrincipal> getRecipients(Notification n, Container c)
462461
{
463462
final Set<UserPrincipal> recipients = new HashSet<>();
464-
TableInfo t = LDKSchema.getInstance().getTable(LDKSchema.TABLE_NOTIFICATION_RECIPIENTS);
463+
TableInfo t = LDKSchema.getTable(LDKSchema.TABLE_NOTIFICATION_RECIPIENTS);
465464
SimpleFilter filter = new SimpleFilter(FieldKey.fromString("notificationtype"), n.getName(), CompareType.EQUAL);
466465
filter.addCondition(FieldKey.fromString("container"), c.getId(), CompareType.EQUAL);
467466
TableSelector ts = new TableSelector(t, Collections.singleton("recipient"), filter, null);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public void customizeColumn(MutableColumnInfo col)
119119
}
120120
};
121121

122-
private Class dataType;
122+
private final Class dataType;
123123

124124
COL_ENUM(Class dataType){
125125
this.dataType = dataType;

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public static void applyNaturalSort(AbstractTableInfo ti, String colName)
212212
sortCol.setLabel(col.getLabel() + " - Sort Field");
213213
ti.addColumn(sortCol);
214214

215-
col.setSortFieldKeys(Arrays.asList(sortCol.getFieldKey()));
215+
col.setSortFieldKeys(Collections.singletonList(sortCol.getFieldKey()));
216216
}
217217

218218
public static void appendCalculatedDateColumns(AbstractTableInfo ti, @Nullable String dateColName, @Nullable String enddateColName)
@@ -373,9 +373,8 @@ private static boolean configureMoreActionsBtn(TableInfo ti, List<ButtonConfigFa
373373
{
374374
for (ButtonConfig btn : existingBtns)
375375
{
376-
if (btn instanceof UserDefinedButtonConfig)
376+
if (btn instanceof UserDefinedButtonConfig ub)
377377
{
378-
UserDefinedButtonConfig ub = (UserDefinedButtonConfig)btn;
379378
if (MORE_ACTIONS.equals(ub.getText()))
380379
{
381380
moreActionsBtn = ub;
@@ -432,18 +431,18 @@ private static boolean configureMoreActionsBtn(TableInfo ti, List<ButtonConfigFa
432431

433432
public static class Settings
434433
{
435-
private Map<PROPERIES, Object> propertyMap;
434+
private final Map<PROPERIES, Object> propertyMap;
436435

437-
public static enum PROPERIES
436+
public enum PROPERIES
438437
{
439438
disableAllEditUI(Boolean.class, false),
440439
setEditLinkOverrides(Boolean.class, true),
441440
auditMode(String.class, AuditBehaviorType.DETAILED.name()),
442441
disableFacetingForNumericCols(Boolean.class, true),
443442
overrideDetailsUrl(Boolean.class, true);
444443

445-
private Class _clazz;
446-
private Object _defaultVal;
444+
private final Class _clazz;
445+
private final Object _defaultVal;
447446

448447
PROPERIES(Class clazz, Object defaultVal)
449448
{

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ private void insertDataAndValidate(String tableName, UserSchema us, String table
226226
}
227227

228228
//Test duplicate keys, expect failure
229-
ti.getUpdateService().insertRows(getUser(), project, Arrays.asList(row1), errors1, null, null);
229+
ti.getUpdateService().insertRows(getUser(), project, List.of(row1), errors1, null, null);
230230
if (errors1.hasErrors())
231231
{
232232
String msg = errors1.getRowErrors().get(0).getMessage();
@@ -251,7 +251,7 @@ public void insertFailedValidationTest() throws Exception
251251

252252
// Expect failure
253253
BatchValidationException errors1 = new BatchValidationException();
254-
us.getTable(TABLE1).getUpdateService().insertRows(getUser(), project, Arrays.asList(row1), errors1, null, null);
254+
us.getTable(TABLE1).getUpdateService().insertRows(getUser(), project, List.of(row1), errors1, null, null);
255255
if (errors1.hasErrors())
256256
{
257257
String msg = errors1.getRowErrors().get(0).getMessage();
@@ -265,7 +265,7 @@ public void insertFailedValidationTest() throws Exception
265265
//this will pass
266266
row1.put("vaLuE", "CBA");
267267
errors1 = new BatchValidationException();
268-
us.getTable(TABLE1).getUpdateService().insertRows(getUser(), project, Arrays.asList(row1), errors1, null, null);
268+
us.getTable(TABLE1).getUpdateService().insertRows(getUser(), project, List.of(row1), errors1, null, null);
269269
if (errors1.hasErrors())
270270
{
271271
throw errors1;
@@ -281,7 +281,7 @@ public void insertFailedValidationTest() throws Exception
281281

282282
try
283283
{
284-
us.getTable(TABLE1).getUpdateService().updateRows(getUser(), project, Arrays.asList(row1), oldKeys, null, null);
284+
us.getTable(TABLE1).getUpdateService().updateRows(getUser(), project, List.of(row1), oldKeys, null, null);
285285

286286
//Ben's change
287287
throw new ValidationException("Expected update to fail because of row validators");

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@
3838
public class LookupValidationHelper
3939
{
4040
private Container _container;
41-
private User _user;
42-
private TableInfo _table;
41+
private final User _user;
42+
private final TableInfo _table;
4343
private static final Logger _log = LogManager.getLogger(LookupValidationHelper.class);
4444

45-
private Map<String, UserSchema> _userSchemaMap = new HashMap<String, UserSchema>();
46-
private Map<String, Map<String, String>> _allowableValueMap = new HashMap<String, Map<String, String>>();
45+
private final Map<String, UserSchema> _userSchemaMap = new HashMap<String, UserSchema>();
46+
private final Map<String, Map<String, String>> _allowableValueMap = new HashMap<String, Map<String, String>>();
4747

4848
private LookupValidationHelper(String containerId, int userId, String schemaName, String queryName)
4949
{

0 commit comments

Comments
 (0)