Skip to content
Open
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
Binary file modified .vs/dinfo/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file not shown.
Binary file modified .vs/dinfo/v18/.suo
Binary file not shown.
254 changes: 180 additions & 74 deletions .vs/dinfo/v18/DocumentLayout.backup.json

Large diffs are not rendered by default.

281 changes: 279 additions & 2 deletions .vs/dinfo/v18/DocumentLayout.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/core/Handlers/config-file.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static class ConfigHelper
{
public static void FindConfigFile(string targetDirectory)
{
while (!string.IsNullOrEmpty(targetDirectory))
while (!string.IsNullOrWhiteSpace(targetDirectory))
{
var configPath = Path.Combine(targetDirectory, "dinfo.yaml");

Expand Down Expand Up @@ -63,7 +63,7 @@ public static void FindConfigFile(string targetDirectory)

public static void DeserializeConfigFile(string configFilePath)
{
if (string.IsNullOrEmpty(configFilePath) || !File.Exists(configFilePath))
if (string.IsNullOrWhiteSpace(configFilePath) || !File.Exists(configFilePath))
return;

var deserializer = new DeserializerBuilder()
Expand Down
9 changes: 2 additions & 7 deletions src/core/Helpers/directory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ public async Task ProcessDirectoryAsync(string targetDirectory, CancellationToke
foreach (string fileName in fileEntries)
{
var fileInfo = new FileInfo(fileName);

string relativePath = string.IsNullOrEmpty(GlobalsUtils.TargetDirectory)
? string.Empty
: Path.GetRelativePath(GlobalsUtils.TargetDirectory, fileName);
string relativePath = string.IsNullOrWhiteSpace(GlobalsUtils.TargetDirectory) ? string.Empty : Path.GetRelativePath(GlobalsUtils.TargetDirectory, fileName);

bool isIgnored = GlobalsUtils.IgnoredFiles.Any(pattern =>
{
Expand Down Expand Up @@ -102,9 +99,7 @@ public async Task ProcessDirectoryAsync(string targetDirectory, CancellationToke
continue;
}

string relativePath = string.IsNullOrEmpty(GlobalsUtils.TargetDirectory)
? string.Empty
: Path.GetRelativePath(GlobalsUtils.TargetDirectory, subDirectory);
string relativePath = string.IsNullOrWhiteSpace(GlobalsUtils.TargetDirectory) ? string.Empty : Path.GetRelativePath(GlobalsUtils.TargetDirectory, subDirectory);

bool isIgnoredDir = GlobalsUtils.IgnoredDirectories.Any(pattern =>
{
Expand Down
8 changes: 4 additions & 4 deletions src/core/Helpers/files.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ public void GetFileType(string fileName)
logger.LogDebug("Getting file type for file {fileName}", fileName);
string? name = Path.GetFileName(fileName);

if (name.StartsWith('.'))
if (name?.StartsWith('.') ?? false)
{
return;
}

string? extension = Path.GetExtension(name);
if (!string.IsNullOrEmpty(extension))
if (!string.IsNullOrWhiteSpace(extension))
{
GlobalsUtils.FileTypes.Add(extension);
}
Expand All @@ -97,13 +97,13 @@ public string GetFileTypeSingleFile(string fileName)
logger.LogDebug("Getting file type single file");
string? name = Path.GetFileName(fileName);

if (name.StartsWith('.'))
if (name?.StartsWith('.') ?? false)
{
return "N/A";
}

string? extension = Path.GetExtension(name);
if (!string.IsNullOrEmpty(extension))
if (!string.IsNullOrWhiteSpace(extension))
{
return extension;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/Helpers/git.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void FindGitRoot(string targetDirectory)
{
logger.LogDebug("Finding git root for directory {targetDirectory}", targetDirectory);

while (!string.IsNullOrEmpty(targetDirectory))
while (!string.IsNullOrWhiteSpace(targetDirectory))
{
if (Directory.Exists(Path.Combine(targetDirectory, ".git")))
{
Expand Down
3 changes: 1 addition & 2 deletions src/core/dinfo.core.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishTrimmed>true</PublishTrimmed>
<JsonSerializerIsReflectionEnabledByDefault>true</JsonSerializerIsReflectionEnabledByDefault>
</PropertyGroup>

Expand Down
40 changes: 20 additions & 20 deletions src/tui/Helpers/tui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ public async Task<Panel> BuildGitPanelAsync(string targetDirectory, Cancellation
if (GlobalsUtils.IsRepo)
{
var gitPanel = new Panel(
$"[bold green]Git Branch Name:[/] {GlobalsUtils.GitBranchName}\n"
+ $"[bold green]Git Hash:[/] {GlobalsUtils.GitHash}\n"
+ $"[bold green]Git Author:[/] {GlobalsUtils.GitAuthor}\n"
+ $"[bold green]Git Committer:[/] {GlobalsUtils.GitCommitter}\n"
$"[bold green]Git Branch Name:[/] {GlobalsUtils.GitBranchName}{Environment.NewLine}"
+ $"[bold green]Git Hash:[/] {GlobalsUtils.GitHash}{Environment.NewLine}"
+ $"[bold green]Git Author:[/] {GlobalsUtils.GitAuthor}{Environment.NewLine}"
+ $"[bold green]Git Committer:[/] {GlobalsUtils.GitCommitter}{Environment.NewLine}"
+ $"[bold green]Git Subject:[/] {GlobalsUtils.GitSubject}"
);

Expand Down Expand Up @@ -64,13 +64,13 @@ public async Task PrintDirectoryInfoAsync(string targetDirectory, CancellationTo
int linesOfCode = GlobalsUtils.GetLinesOfCode();

var infoPanel = new Panel(
$"[bold green]Number of files:[/] {GlobalsUtils.TotalFiles}\n"
+ $"[bold green]Number of lines:[/] {GlobalsUtils.TotalLines}\n"
+ $"[bold green]Commentes:[/] {GlobalsUtils.TotalLinesComments}\n"
+ $"[bold green]Blank lines:[/] {GlobalsUtils.TotalBlankLines}\n"
+ $"[bold green]Code:[/] {linesOfCode}\n"
+ $"[bold green]Number of directories:[/] {GlobalsUtils.TotalDirs}\n"
+ $"[bold green]Permissions:[/] {perms}\n"
$"[bold green]Number of files:[/] {GlobalsUtils.TotalFiles}{Environment.NewLine}"
+ $"[bold green]Number of lines:[/] {GlobalsUtils.TotalLines}{Environment.NewLine}"
+ $"[bold green]Commentes:[/] {GlobalsUtils.TotalLinesComments}{Environment.NewLine}"
+ $"[bold green]Blank lines:[/] {GlobalsUtils.TotalBlankLines}{Environment.NewLine}"
+ $"[bold green]Code:[/] {linesOfCode}{Environment.NewLine}"
+ $"[bold green]Number of directories:[/] {GlobalsUtils.TotalDirs}{Environment.NewLine}"
+ $"[bold green]Permissions:[/] {perms}{Environment.NewLine}"
+ $"[bold green]Total size:[/] {DirectoryHelper.SizeToReturn()} {GlobalsUtils.SizeExtension}"
);

Expand All @@ -87,10 +87,10 @@ public async Task PrintDirectoryInfoAsync(string targetDirectory, CancellationTo
var mostUsedExtension = GlobalsUtils.GetMostUsedExtension();

var extensionsPanel = new Panel(
$"[bold green]File extensions:[/] {string.Join(", ", fileTypesNoDupes)}\n"
+ $"[bold green]Most used extension:[/] {mostUsedExtension.TrimStart('.')}\n"
+ $"[bold green]Biggest file:[/] {GlobalsUtils.BiggestFile} ({GlobalsUtils.BiggestFileSize} B)\n"
+ $"[bold green]Last modified file:[/] {GlobalsUtils.LastModifiedFile}\n"
$"[bold green]File extensions:[/] {string.Join(", ", fileTypesNoDupes)}{Environment.NewLine}"
+ $"[bold green]Most used extension:[/] {mostUsedExtension.TrimStart('.')}{Environment.NewLine}"
+ $"[bold green]Biggest file:[/] {GlobalsUtils.BiggestFile} ({GlobalsUtils.BiggestFileSize} B){Environment.NewLine}"
+ $"[bold green]Last modified file:[/] {GlobalsUtils.LastModifiedFile}{Environment.NewLine}"
+ $"[bold green]File encodings:[/] {string.Join(", ", GlobalsUtils.Encodings.Distinct())}"
);

Expand Down Expand Up @@ -177,11 +177,11 @@ public async Task PrintFileInfoAsync(string targetFile, CancellationToken cancel
var code = lines - (comments + blanks);

var infoPanel = new Panel(
$"[bold green]Number of lines:[/] {lines.ToString()}\n"
+ $"[bold green]Commentes:[/] {comments}\n"
+ $"[bold green]Blank lines:[/] {blanks}\n"
+ $"[bold green]Code:[/] {code}\n"
+ $"[bold green]File encoding:[/] {string.Join(", ", GlobalsUtils.Encodings.Distinct())}\n"
$"[bold green]Number of lines:[/] {lines.ToString()}{Environment.NewLine}"
+ $"[bold green]Commentes:[/] {comments}{Environment.NewLine}"
+ $"[bold green]Blank lines:[/] {blanks}{Environment.NewLine}"
+ $"[bold green]Code:[/] {code}{Environment.NewLine}"
+ $"[bold green]File encoding:[/] {string.Join(", ", GlobalsUtils.Encodings.Distinct())}{Environment.NewLine}"
+ $"[bold green]File type:[/] {filesHelper.GetFileTypeSingleFile(targetFile)}"
);

Expand Down
3 changes: 1 addition & 2 deletions src/tui/dinfo.tui.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AssemblyName>dinfo</AssemblyName>
Expand All @@ -7,7 +7,6 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>false</PublishAot>
<PublishTrimmed>false</PublishTrimmed>
<JsonSerializerIsReflectionEnabledByDefault>true</JsonSerializerIsReflectionEnabledByDefault>
<Version>1.2.2</Version>
</PropertyGroup>
Expand Down