Skip to content

Commit

Permalink
Remove Code Smell
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauro Cardillo committed Sep 14, 2023
1 parent d0a3e72 commit 81a5493
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 66 deletions.
11 changes: 9 additions & 2 deletions src/FileSystem/src/Adapters/Adapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Threading.Tasks;
using Maurosoft.FileSystem.Models;
using Serilog;
using Serilog.Core;
using DirectoryNotFoundException = Maurosoft.FileSystem.Exceptions.DirectoryNotFoundException;
using FileNotFoundException = Maurosoft.FileSystem.Exceptions.FileNotFoundException;

Expand Down Expand Up @@ -297,7 +296,15 @@ public void WriteFile(string path, string contents, bool overwrite = false)

protected string[] GetPathParts(string path) => path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

protected string GetLastPathPart(string path) => GetPathParts(path).Length > 0 ? GetPathParts(path).Last() : String.Empty;
protected string GetLastPathPart(string path)
{
var pathParts = GetPathParts(path);

if (pathParts.Length > 0)
return pathParts[pathParts.Length - 1];
else
return String.Empty;
}

protected string GetParentPathPart(string path)
{
Expand Down
4 changes: 1 addition & 3 deletions tests/FileSystem.Tests/FileSystem.Adapters.Ftp/FtpFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ public FtpFixture()
if (Environment.GetEnvironmentVariable("DOCKER_HOST") == null)
Environment.SetEnvironmentVariable("DOCKER_HOST", "unix:///var/run/docker.sock");

userName = faker.Internet.UserName();
userName = faker.Random.String2(10, 15);
password = faker.Internet.Password();

userName = Regex.Replace(userName, @"[^a-zA-Z0-9_]+", "");

var passivePortEnd = PassivePortStart + (MaxUsersCount);

var containerBuilder = new ContainerBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ public SftpFixture()
if (Environment.GetEnvironmentVariable("DOCKER_HOST") == null)
Environment.SetEnvironmentVariable("DOCKER_HOST", "unix:///var/run/docker.sock");

userName = faker.Internet.UserName();
userName = faker.Random.String2(10, 15);
password = faker.Internet.Password();

userName = Regex.Replace(userName, @"[^a-zA-Z0-9_]+", "");

var containerBuilder = new ContainerBuilder()
.WithName(Guid.NewGuid().ToString("D"))
.WithAutoRemove(autoRemove: false)
Expand Down
43 changes: 0 additions & 43 deletions tests/FileSystem.Tests/PriorityOrderer.cs

This file was deleted.

15 changes: 0 additions & 15 deletions tests/FileSystem.Tests/TestPriorityAttribute.cs

This file was deleted.

0 comments on commit 81a5493

Please sign in to comment.