Skip to content

Commit 6238c8b

Browse files
Auto-refactor lint cleanup (#633)
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 2c3b00b commit 6238c8b

84 files changed

Lines changed: 305 additions & 620 deletions

File tree

Some content is hidden

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

SkylineToolsStore/src/org/labkey/skylinetoolsstore/SkylineToolsStoreContainerListener.java

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,52 +16,17 @@
1616

1717
package org.labkey.skylinetoolsstore;
1818

19-
import org.jetbrains.annotations.NotNull;
2019
import org.labkey.api.data.Container;
2120
import org.labkey.api.data.ContainerManager.ContainerListener;
22-
import org.labkey.api.data.RuntimeSQLException;
2321
import org.labkey.api.security.User;
2422

25-
import java.sql.SQLException;
26-
27-
import java.beans.PropertyChangeEvent;
28-
import java.util.Collection;
29-
import java.util.Collections;
30-
3123
public class SkylineToolsStoreContainerListener implements ContainerListener
3224
{
33-
@Override
34-
public void containerCreated(Container c, User user)
35-
{
36-
}
3725

3826
@Override
3927
public void containerDeleted(Container c, User user)
4028
{
41-
try
42-
{
43-
SkylineToolsStoreManager.get().deleteAllData(c);
44-
}
45-
catch (SQLException e)
46-
{
47-
throw new RuntimeSQLException(e);
48-
}
49-
}
50-
51-
@Override
52-
public void propertyChange(PropertyChangeEvent evt)
53-
{
54-
}
55-
56-
@Override
57-
public void containerMoved(Container c, Container oldParent, User user)
58-
{
29+
SkylineToolsStoreManager.get().deleteAllData(c);
5930
}
6031

61-
@NotNull
62-
@Override
63-
public Collection<String> canMove(Container c, Container newParent, User user)
64-
{
65-
return Collections.emptyList();
66-
}
6732
}

SkylineToolsStore/src/org/labkey/skylinetoolsstore/SkylineToolsStoreController.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.apache.commons.lang3.math.NumberUtils;
2525
import org.json.JSONArray;
2626
import org.json.JSONObject;
27+
import org.jetbrains.annotations.NotNull;
2728
import org.labkey.api.action.FormHandlerAction;
2829
import org.labkey.api.action.NavTrailAction;
2930
import org.labkey.api.action.PermissionCheckable;
@@ -468,7 +469,7 @@ public InsertAction()
468469
}
469470

470471
@Override
471-
public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception
472+
public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, @NotNull HttpServletResponse httpServletResponse) throws Exception
472473
{
473474
final String sender = httpServletRequest.getParameter("sender");
474475
final String updateTargetString = StringUtils.trimToNull(httpServletRequest.getParameter("updatetarget"));
@@ -703,7 +704,7 @@ public InsertSupplementAction()
703704
}
704705

705706
@Override
706-
public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception
707+
public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, @NotNull HttpServletResponse httpServletResponse) throws Exception
707708
{
708709
final String suppTargetString = httpServletRequest.getParameter("supptarget");
709710
int suppTarget = NumberUtils.toInt(suppTargetString, -1);
@@ -765,7 +766,7 @@ public DeleteSupplementAction()
765766
}
766767

767768
@Override
768-
public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception
769+
public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, @NotNull HttpServletResponse httpServletResponse) throws Exception
769770
{
770771
final int suppTarget = Integer.parseInt(httpServletRequest.getParameter("supptarget"));
771772

@@ -896,7 +897,7 @@ public class DeleteLatestAction extends AbstractController implements Permission
896897
private final Class REQ_PERMS = DeletePermission.class;
897898

898899
@Override
899-
public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception
900+
public ModelAndView handleRequestInternal(@NotNull HttpServletRequest httpServletRequest, @NotNull HttpServletResponse httpServletResponse) throws Exception
900901
{
901902
int id;
902903
try {
@@ -961,7 +962,7 @@ public class DownloadToolAction extends AbstractController implements Permission
961962
public static final String DOWNLOADED_COOKIE_PREFIX = "downloadtool";
962963

963964
@Override
964-
public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception
965+
public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, @NotNull HttpServletResponse httpServletResponse) throws Exception
965966
{
966967
final int id = NumberUtils.toInt(httpServletRequest.getParameter("id"), -1);
967968
final String toolName = httpServletRequest.getParameter("name");
@@ -1239,7 +1240,7 @@ public SetOwnersAction()
12391240
}
12401241

12411242
@Override
1242-
public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception
1243+
public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, @NotNull HttpServletResponse httpServletResponse) throws Exception
12431244
{
12441245
final String sender = httpServletRequest.getParameter("sender");
12451246
final String updateTargetString = httpServletRequest.getParameter("updatetarget");
@@ -1312,7 +1313,7 @@ public class UpdatePropertyAction extends AbstractController implements Permissi
13121313
private final Class REQ_PERMS = InsertPermission.class;
13131314

13141315
@Override
1315-
public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception
1316+
public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, @NotNull HttpServletResponse httpServletResponse) throws Exception
13161317
{
13171318
final int id = Integer.parseInt(httpServletRequest.getParameter("id"));
13181319

@@ -1420,7 +1421,7 @@ public void checkPermissions() throws UnauthorizedException
14201421
public class GetToolsApiAction extends AbstractController implements PermissionCheckable
14211422
{
14221423
@Override
1423-
public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException
1424+
public ModelAndView handleRequestInternal(@NotNull HttpServletRequest httpServletRequest, @NotNull HttpServletResponse httpServletResponse) throws IOException
14241425
{
14251426
StringBuilder sb = new StringBuilder();
14261427

SkylineToolsStore/src/org/labkey/skylinetoolsstore/SkylineToolsStoreManager.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
import org.labkey.api.security.User;
2727
import org.labkey.skylinetoolsstore.model.SkylineTool;
2828

29-
import java.sql.SQLException;
30-
3129
public class SkylineToolsStoreManager
3230
{
3331
private static final SkylineToolsStoreManager _instance = new SkylineToolsStoreManager();
@@ -42,7 +40,7 @@ public static SkylineToolsStoreManager get()
4240
return _instance;
4341
}
4442

45-
public void deleteAllData(Container c) throws SQLException
43+
public void deleteAllData(Container c)
4644
{
4745
// delete all tools when the container is deleted
4846
Filter containerFilter = SimpleFilter.createContainerFilter(c);
@@ -124,18 +122,18 @@ public SkylineTool getToolByNameAndVersion(String name, String version)
124122
return (tools != null && tools.length > 0) ? tools[0] : null;
125123
}
126124

127-
public void deleteTool(int rowId) throws SQLException
125+
public void deleteTool(int rowId)
128126
{
129127
Table.delete(SkylineToolsStoreSchema.getInstance().getTableInfoSkylineTool(), rowId);
130128
}
131129

132-
public SkylineTool insertTool(Container c, User user, SkylineTool tool) throws SQLException
130+
public SkylineTool insertTool(Container c, User user, SkylineTool tool)
133131
{
134132
tool.setContainer(c.getId());
135133
return Table.insert(user, SkylineToolsStoreSchema.getInstance().getTableInfoSkylineTool(), tool);
136134
}
137135

138-
public SkylineTool updateTool(Container c, User user, SkylineTool tool) throws SQLException
136+
public SkylineTool updateTool(Container c, User user, SkylineTool tool)
139137
{
140138
if (tool.getContainerId() == null)
141139
tool.setContainerId(c.getId());
@@ -153,7 +151,7 @@ public SkylineTool updateTool(Container c, User user, SkylineTool tool) throws S
153151
tool, tool.getRowId());
154152
}
155153

156-
public SkylineTool recordToolDownload(SkylineTool tool) throws SQLException
154+
public SkylineTool recordToolDownload(SkylineTool tool)
157155
{
158156
tool.setDownloads(tool.getDownloads() + 1);
159157
return Table.update(null, SkylineToolsStoreSchema.getInstance().getTableInfoSkylineTool(),

SkylineToolsStore/src/org/labkey/skylinetoolsstore/SkylineToolsStoreModule.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.labkey.api.view.BaseWebPartFactory;
2727
import org.labkey.api.view.Portal;
2828
import org.labkey.api.view.ViewContext;
29-
import org.labkey.api.view.WebPartConfigurationException;
3029
import org.labkey.api.view.WebPartFactory;
3130
import org.labkey.api.view.WebPartView;
3231
import org.labkey.skylinetoolsstore.model.SkylineTool;
@@ -74,7 +73,7 @@ protected Collection<WebPartFactory> createWebPartFactories()
7473
}
7574

7675
@Override
77-
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, Portal.@NotNull WebPart webPart) throws WebPartConfigurationException
76+
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, Portal.@NotNull WebPart webPart)
7877
{
7978
return new SkylineToolsStoreWebPart();
8079
}

lincs/src/org/labkey/lincs/CustomGctBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public Gct build(List<Path> files, List<LincsController.SelectedAnnotation> sele
4444

4545
for(Path file: files)
4646
{
47-
_log.info("LINCS custom GCT: reading file: " + file);
47+
_log.info("LINCS custom GCT: reading file: {}", file);
4848
Gct gct;
4949
try
5050
{
@@ -87,10 +87,10 @@ private void updateMultiValueProbeAnnotations(Gct gct, Gct customGct)
8787
{
8888
// All replicates in a single GCT file should have the same value for the "det_plate" replicate annotation.
8989
// TODO: This is not true for GCP plate 16 file.
90-
String detPlateAnnotationVal = gct.getReplicates().get(0).getAnnotationValue(LincsAnnotation.PLATE_ANNOTATION);
90+
String detPlateAnnotationVal = gct.getReplicates().getFirst().getAnnotationValue(LincsAnnotation.PLATE_ANNOTATION);
9191

9292
// All replicates in a single GCT file should have the same value for the "provenance_code" replicate annotation
93-
String expType = gct.getExperimentType(gct.getReplicates().get(0).getAnnotationValue(LincsAnnotation.PROVENANCE_CODE));
93+
String expType = gct.getExperimentType(gct.getReplicates().getFirst().getAnnotationValue(LincsAnnotation.PROVENANCE_CODE));
9494

9595
// Append experiment type to plate annotation since we can have same plate (e.g. plate 18) analyzed by both DIA and PRM.
9696
String expTypeAndPlate = expType + "_" + detPlateAnnotationVal;

lincs/src/org/labkey/lincs/DocImportListener.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void beforeRunDelete(ExpProtocol protocol, ExpRun run, User user)
7070
}
7171
catch (IOException e)
7272
{
73-
_log.warn("LINCS: Error listing files in folder " + FileUtil.getAbsolutePath(gctDir), e);
73+
_log.warn("LINCS: Error listing files in folder {}", FileUtil.getAbsolutePath(gctDir), e);
7474
return;
7575
}
7676

@@ -81,7 +81,7 @@ public void beforeRunDelete(ExpProtocol protocol, ExpRun run, User user)
8181
}
8282
catch (IOException e)
8383
{
84-
_log.warn("LINCS: Error deleting file " + FileUtil.getAbsolutePath(path), e);
84+
_log.warn("LINCS: Error deleting file {}", FileUtil.getAbsolutePath(path), e);
8585
}
8686
});
8787
}
@@ -115,7 +115,7 @@ public void onDocumentImport(Container container, User user, ITargetedMSRun skyl
115115
PipeRoot root = PipelineService.get().findPipelineRoot(container);
116116
if (root == null || !root.isValid())
117117
{
118-
_log.error("LINCS: No valid pipeline root found for " + container.getPath());
118+
_log.error("LINCS: No valid pipeline root found for {}", container.getPath());
119119
return;
120120
}
121121

@@ -129,7 +129,7 @@ public void onDocumentImport(Container container, User user, ITargetedMSRun skyl
129129
}
130130
catch (PipelineValidationException e)
131131
{
132-
_log.error("Error adding LINCS pipeline job to queue. Message: " + e.getMessage(), e);
132+
_log.error("Error adding LINCS pipeline job to queue. Message: {}", e.getMessage(), e);
133133
if(pspJob != null)
134134
{
135135
LincsManager.get().deleteLincsPspJob(pspJob);
@@ -138,7 +138,7 @@ public void onDocumentImport(Container container, User user, ITargetedMSRun skyl
138138
}
139139

140140
long jobId = PipelineService.get().getJobId(user, container, job.getJobGUID());
141-
_log.info("LINCS: Queued job Id " + jobId +" for creating GCT files for " + skylineRun.getFileName() + ". Container: " + container.getPath());
141+
_log.info("LINCS: Queued job Id {} for creating GCT files for {}. Container: {}", jobId, skylineRun.getFileName(), container.getPath());
142142

143143
pspJob.setPipelineJobId(jobId);
144144
LincsManager.get().updatePipelineJobId(pspJob);

lincs/src/org/labkey/lincs/Gct.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,7 @@ public void addMultiValueProbeAnnotation(String annotationName, ProbeExpTypePlat
126126
{
127127
_multiValueProbeAnnotations = new HashMap<>();
128128
}
129-
GctTable<ProbeExpTypePlate> probePlateValues = _multiValueProbeAnnotations.get(annotationName);
130-
if(probePlateValues == null)
131-
{
132-
probePlateValues = new GctTable<>();
133-
_multiValueProbeAnnotations.put(annotationName, probePlateValues);
134-
}
129+
GctTable<ProbeExpTypePlate> probePlateValues = _multiValueProbeAnnotations.computeIfAbsent(annotationName, _ -> new GctTable<>());
135130
probePlateValues.addValue(key, value);
136131
}
137132

lincs/src/org/labkey/lincs/LincsContainerListener.java

Lines changed: 0 additions & 55 deletions
This file was deleted.

lincs/src/org/labkey/lincs/LincsController.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@
9393
import org.springframework.validation.Errors;
9494
import org.springframework.web.servlet.ModelAndView;
9595

96-
import java.io.File;
97-
import java.io.FilenameFilter;
9896
import java.io.IOException;
9997
import java.io.InputStream;
10098
import java.nio.file.Files;

lincs/src/org/labkey/lincs/LincsManager.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public List<LincsAnnotation> getReplicateAnnotations(User user, Container contai
8383
else
8484
{
8585
// Otherwise, read from the lincs_replicate_annotations.txt file in the module's resources directory
86-
_log.info("Could not find table " + listName + " in schema 'lists'. Trying to read from file.");
86+
_log.info("Could not find table {} in schema 'lists'. Trying to read from file.", listName);
8787
return readFromFile("lincs_replicate_annotations.txt");
8888
}
8989
}
@@ -100,7 +100,7 @@ public List<LincsAnnotation> getPeptideAnnotations(User user, Container containe
100100
else
101101
{
102102
// Otherwise, read from the lincs_peptide_annotations.txt file in the module's resources directory
103-
_log.info("Could not find table " + listName + " in schema 'lists'. Trying to read from file.");
103+
_log.info("Could not find table {} in schema 'lists'. Trying to read from file.", listName);
104104
return readFromFile("lincs_peptide_annotations.txt");
105105
}
106106
}
@@ -120,10 +120,10 @@ private List<LincsAnnotation> readFromFile(String filename)
120120
String[] headers = line.split("\\t");
121121
for(int i = 0; i < headers.length; i++)
122122
{
123-
if(headers[i].toLowerCase().equals("name")) {nameCol = i;}
124-
else if(headers[i].toLowerCase().equals("displayname")) {displayNameCol = i;}
125-
else if(headers[i].toLowerCase().equals("advanced")) {advancedCol = i;}
126-
else if(headers[i].toLowerCase().equals("ignored")) {ignoredCol = i;}
123+
if(headers[i].equalsIgnoreCase("name")) {nameCol = i;}
124+
else if(headers[i].equalsIgnoreCase("displayname")) {displayNameCol = i;}
125+
else if(headers[i].equalsIgnoreCase("advanced")) {advancedCol = i;}
126+
else if(headers[i].equalsIgnoreCase("ignored")) {ignoredCol = i;}
127127
}
128128

129129
List<LincsAnnotation> annotations = new ArrayList<>();
@@ -142,7 +142,7 @@ private List<LincsAnnotation> readFromFile(String filename)
142142
}
143143
catch (IOException e)
144144
{
145-
_log.error("Could not read file " + txt.getPath(), e);
145+
_log.error("Could not read file {}", txt.getPath(), e);
146146
return Collections.emptyList();
147147
}
148148
}

0 commit comments

Comments
 (0)