Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A better handling of old workspaces (fixes #224) #310

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions gama.ui.application/src/gama/ui/application/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,9 @@ public static Object checkWorkspace() throws IOException {
// this stage
if (ret != null) {
remember = "models".equals(ret) && WorkspacePreferences.askBeforeUsingOutdatedWorkspace()
&& !openQuestion(null, "Different version of the models library",
"The workspace contains a different version of the models library. Do you want to use another workspace ?");
&& openQuestion(null, "Different version of the models library",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ Getting worse: Overall Code Complexity
The mean cyclomatic complexity increases from 4.20 to 4.30, threshold = 4

"The workspace contains a different version of the models library. Do you want GAMA to proceed and update it ?");
if (remember) { clearWorkspace(true); }
Comment on lines +244 to +246

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Getting worse: Complex Method
checkWorkspace increases in cyclomatic complexity from 16 to 17, threshold = 9

Suppress

Comment on lines +244 to +246

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ New issue: Deep, Nested Complexity
checkWorkspace has a nested complexity depth of 4, threshold = 4

Suppress

}
}
}
Expand All @@ -255,7 +256,7 @@ public static Object checkWorkspace() throws IOException {
if (pick == 1 /* Window.CANCEL */ || wr == null) {
openError(null, IKeyword.ERROR, "GAMA can not start without a workspace and will now exit.");
// System.exit(0);
return IApplication.EXIT_OK;
return EXIT_OK;
}
/* Tell Eclipse what the selected location was and continue */
instanceLoc.set(new URL("file", null, wr), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,12 @@
if (askBeforeUsingOutdatedWorkspace()) {
create = MessageDialog.openQuestion(Display.getDefault().getActiveShell(),
"Different version of the models library",
"The workspace contains a different version of the models library. Do you want to proceed anyway ?");
"The workspace contains a different version of the models library. Do you want GAMA to proceed and update it ?");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ Getting worse: Complex Method
checkWorkspaceDirectory already has high cyclomatic complexity, and now it increases in Lines of Code from 71 to 72

}
if (create) {
try {
dotFile.createNewFile();

Check warning on line 253 in gama.ui.application/src/gama/ui/application/workspace/WorkspacePreferences.java

View workflow job for this annotation

GitHub Actions / SpotBugs

RV_RETURN_VALUE_IGNORED_BAD_PRACTICE

Exceptional return value of java.io.File.createNewFile() ignored in gama.ui.application.workspace.WorkspacePreferences.checkWorkspaceDirectory(String, boolean, boolean, boolean)
Raw output
This method returns a value that is not checked. The return value should be checked since it can indicate an unusual or unexpected function execution. For example, the File.delete() method returns false if the file could not be successfully deleted (rather than throwing an Exception). If you don't check the result, you won't notice if the method invocation signals unexpected behavior by returning an atypical return value.
Application.clearWorkspace(true);
} catch (final IOException e) {
return "Error updating the models library";
}
Expand All @@ -262,7 +263,7 @@
}
if (cloning) {
final boolean b = MessageDialog.openQuestion(Display.getDefault().getActiveShell(), "Existing workspace",
"The path entered is a path to an existing workspace. All its contents will be erased and replaced by the current workspace contents. Proceed anyway ?");
"The path entered is a path to an existing workspace. Its contents will be erased and replaced by the current workspace contents. Proceed anyway ?");
if (!b) return "";
}
return null;
Expand Down