Skip to content

Commit

Permalink
feat(#1378): remove Home.clean method
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Nov 9, 2022
1 parent 2dd0579 commit 53cfdf0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ final class DepDirs extends ListEnvelope<String> {
*/
private static List<String> list(final Path dir) throws IOException {
final List<String> names = new LinkedList<>();
if (Files.exists(Home.clean(dir))) {
if (Files.exists(dir)) {
final String home = dir.toAbsolutePath().toString();
names.addAll(
Files.find(dir, 4, (t, u) -> true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ final class FileHash {
@Override
public String toString() {
final String hash;
if (Files.exists(Home.clean(this.file))) {
if (Files.exists(this.file)) {
hash = Arrays.toString(
new UncheckedBytes(
new Md5DigestOf(new InputOf(new BytesOf(this.file)))
Expand Down
20 changes: 2 additions & 18 deletions eo-maven-plugin/src/main/java/org/eolang/maven/Home.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.jcabi.log.Logger;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -160,7 +159,7 @@ public void save(final byte[] bytes, final Path path) throws IOException {
* @return True if exists
*/
public boolean exists(final Path path) {
return Files.exists(this.absolute(Home.clean(path)));
return Files.exists(this.absolute(path));
}

/**
Expand All @@ -172,22 +171,7 @@ public boolean exists(final Path path) {
* if some exception happens during reading the file
*/
public Bytes load(final Path path) throws IOException {
return new BytesOf(Files.readAllBytes(this.absolute(Home.clean(path))));
}

/**
* Clean path.
*
* @param path Path
* @return Clean path
* @todo #1352:30min Move utility `clean` method out of `Home` class. Create
* maybe separate class for this. Consider removing this method at all as
* it seems does nothing useful. Update all usages of this method.
*/
@SuppressWarnings("PMD.ProhibitPublicStaticMethods")
public static Path clean(final Path path) {
final byte[] bytes = path.toString().getBytes(StandardCharsets.UTF_8);
return Paths.get(new String(bytes, StandardCharsets.UTF_8));
return new BytesOf(Files.readAllBytes(this.absolute(path)));
}

/**
Expand Down

1 comment on commit 53cfdf0

@0pdd
Copy link

@0pdd 0pdd commented on 53cfdf0 Nov 9, 2022

Choose a reason for hiding this comment

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

Puzzle 1352-5ea27325 disappeared from eo-maven-plugin/src/main/java/org/eolang/maven/Home.java), that's why I closed #1378. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

Please sign in to comment.