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

Update FileUtils.java #364

Merged
merged 1 commit into from
Oct 28, 2024
Merged
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
32 changes: 11 additions & 21 deletions gama.core/src/gama/core/common/util/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
********************************************************************************************************/
package gama.core.common.util;

import static java.util.stream.Collectors.toList;

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.93 to 4.96, threshold = 4


import java.io.File;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -19,7 +17,6 @@
import java.net.URLDecoder;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;

import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo;
Expand Down Expand Up @@ -160,13 +157,14 @@ static public String constructAbsoluteFilePath(final IScope scope, final String
if (a == null) return fp;
if (!a.isHeadless()) {
// Necessary to ask the workspace for the containers as projects might be linked
final List<IContainer> paths = a.getWorkingPaths().stream()
.map(s -> ROOT.findContainersForLocation(new Path(s))[0]).collect(toList());
for (final IContainer folder : paths) {
final String file = findInWorkspace(fp, folder, mustExist);
if (file != null) {
DEBUG.OUT("Hit with workspace-based search: " + file);
return file;
for (final String folder : a.getWorkingPaths()) {
IContainer[] containers = ROOT.findContainersForLocation(new Path(folder));
for (IContainer container : containers) {
final String file = findInWorkspace(fp, container, mustExist);
if (file != null) {
DEBUG.OUT("Hit with workspace-based search: " + file);
return file;
}
Comment on lines +160 to +167

Choose a reason for hiding this comment

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

❌ Getting worse: Complex Method
constructAbsoluteFilePath increases in cyclomatic complexity from 11 to 12, threshold = 9

Suppress

Comment on lines +160 to +167

Choose a reason for hiding this comment

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

ℹ Getting worse: Deep, Nested Complexity
constructAbsoluteFilePath increases in nested complexity depth from 4 to 5, threshold = 4

}
}
}
Expand Down Expand Up @@ -419,10 +417,9 @@ public static URI getURI(final String target, final URI existingResource) {
return null;
}
}

public static String escapeFilePath(String path) {
return path .replace("\\", "\\\\")
.replace("\"", "\\\"");

public static String escapeFilePath(final String path) {
return path.replace("\\", "\\\\").replace("\"", "\\\"");
}

/**
Expand Down Expand Up @@ -479,13 +476,6 @@ public static IContainer getFolder(final String path, final URI root, final bool
return null;
}

// public static IFile linkAndGetExternalFile(final URI uri, final URI
// workspaceResource) {
// final String path = URI.decode(uri.isFile() ? uri.toFileString() :
// uri.toString());
// return linkAndGetExternalFile(URI.decode(path), workspaceResource);
// }

/**
* Creates the linked file.
*
Expand Down