Skip to content

Commit 9b38099

Browse files
committed
fix codacy issues
1 parent 67617ea commit 9b38099

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvStorageHelper.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ public static String getRelativeFilePath(Project project, VirtualFile virtualFil
1818
if (project == null || virtualFile == null) {
1919
return null;
2020
}
21-
if (virtualFile instanceof VirtualFileWindow) {
22-
virtualFile = ((VirtualFileWindow) virtualFile).getDelegate();
23-
}
24-
String filePath = virtualFile.getUserData(RELATIVE_FILE_URL);
21+
VirtualFile targetFile = virtualFile instanceof VirtualFileWindow ?
22+
((VirtualFileWindow) virtualFile).getDelegate() :
23+
virtualFile;
24+
String filePath = targetFile.getUserData(RELATIVE_FILE_URL);
2525
if (filePath == null && project.getBasePath() != null) {
26-
String localFilePath = PathUtil.getLocalPath(virtualFile);
26+
String localFilePath = PathUtil.getLocalPath(targetFile);
2727
if (localFilePath == null) {
2828
return null;
2929
}
3030
String projectDir = PathUtil.getLocalPath(project.getBasePath());
3131
filePath = localFilePath.replaceFirst("^" + Pattern.quote(projectDir), "");
32-
virtualFile.putUserData(RELATIVE_FILE_URL, filePath);
32+
targetFile.putUserData(RELATIVE_FILE_URL, filePath);
3333
}
3434
return filePath;
3535
}

src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/TableRowUtilities.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.awt.event.ComponentAdapter;
4040
import java.awt.event.ComponentEvent;
4141
import java.util.ArrayList;
42+
import java.util.Objects;
4243

4344

4445
/**
@@ -154,7 +155,7 @@ public static JTable addNumberColumn(final JTable userTable, int startingNumber)
154155
// Make certain we are the viewPort's view and not, for example, the rowHeaderView of the scrollPane - an implementor of fixed columns might do this.
155156
JViewport viewport = scrollPane.getViewport();
156157

157-
if (viewport == null || viewport.getView() != userTable) {
158+
if (viewport == null || !Objects.equals(viewport.getView(), userTable)) {
158159
return null;
159160
}
160161

@@ -318,7 +319,7 @@ private TableSynchronizer(JTable rowHeadersTableArg, JTable userTableArg) {
318319
}
319320

320321
public void valueChanged(ListSelectionEvent e) {
321-
if (e.getSource() == userTable.getSelectionModel()) {
322+
if (Objects.equals(e.getSource(), userTable.getSelectionModel())) {
322323
rowHeadersTable.getSelectionModel().removeListSelectionListener(this);
323324
rowHeadersTable.getSelectionModel().clearSelection();
324325

@@ -330,7 +331,7 @@ public void valueChanged(ListSelectionEvent e) {
330331
}
331332

332333
rowHeadersTable.getSelectionModel().addListSelectionListener(this);
333-
} else if (e.getSource() == rowHeadersTable.getSelectionModel()) {
334+
} else if (Objects.equals(e.getSource(), rowHeadersTable.getSelectionModel())) {
334335
boolean isColumnSelectionAllowed = userTable.getColumnSelectionAllowed();
335336
boolean isRowSelectionAllowed = userTable.getRowSelectionAllowed();
336337
boolean isCellSelectionAllowed = userTable.getCellSelectionEnabled();

0 commit comments

Comments
 (0)