Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
All - Cleanup Style
Browse files Browse the repository at this point in the history
  • Loading branch information
nlogozzo committed Oct 10, 2023
1 parent 7a0ddef commit f1a4a61
Show file tree
Hide file tree
Showing 25 changed files with 102 additions and 107 deletions.
2 changes: 0 additions & 2 deletions Nickvision.Aura.Tests/AuraTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Xunit.Abstractions;

namespace Nickvision.Aura.Tests;

public class AuraTest
Expand Down
2 changes: 1 addition & 1 deletion Nickvision.Aura.Tests/KeyringTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public KeyringTest(ITestOutputHelper output)
{
_output = output;
}

[SkippableFact]
public async Task AccessTest()
{
Expand Down
6 changes: 3 additions & 3 deletions Nickvision.Aura.Tests/SystemDirectoriesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class SystemDirectoriesTest
[Fact]
public void Path()
{
var path = new []{ "test0", "test1" };
var path = new[] { "test0", "test1" };
Environment.SetEnvironmentVariable("PATH", string.Join(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ";" : ":", path));
Assert.True(SystemDirectories.Path.SequenceEqual(path));
}
Expand All @@ -21,7 +21,7 @@ public void Config()
{
Assert.True(SystemDirectories.Config.Length == 0);
}
var config = new []{ "test0", "test1" };
var config = new[] { "test0", "test1" };
Environment.SetEnvironmentVariable("XDG_CONFIG_DIRS", string.Join(":", config));
Assert.True(SystemDirectories.Config.SequenceEqual(config));
}
Expand All @@ -33,7 +33,7 @@ public void Data()
{
Assert.True(SystemDirectories.Data.Length == 0);
}
var data = new []{ "test0", "test1" };
var data = new[] { "test0", "test1" };
Environment.SetEnvironmentVariable("XDG_DATA_DIRS", string.Join(":", data));
Assert.True(SystemDirectories.Data.SequenceEqual(data));
}
Expand Down
13 changes: 6 additions & 7 deletions Nickvision.Aura.Tests/UserDirectoriesTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using Xunit.Abstractions;
Expand All @@ -8,7 +7,7 @@ namespace Nickvision.Aura.Tests;
public class UserDirectoriesTest
{
private readonly ITestOutputHelper _output;

public UserDirectoriesTest(ITestOutputHelper output)
{
_output = output;
Expand Down Expand Up @@ -80,14 +79,14 @@ public void Desktop()
_output.WriteLine($"Desktop: {UserDirectories.Desktop}");
Assert.True(Directory.Exists(UserDirectories.Desktop));
}

[Fact]
public void Documents()
{
_output.WriteLine($"Documents: {UserDirectories.Documents}");
Assert.True(Directory.Exists(UserDirectories.Documents));
}

[Fact]
public void Downloads()
{
Expand All @@ -101,22 +100,22 @@ public void Music()
_output.WriteLine($"Music: {UserDirectories.Music}");
Assert.True(Directory.Exists(UserDirectories.Music));
}

[Fact]
public void Pictures()
{
_output.WriteLine($"Pictures: {UserDirectories.Pictures}");
Assert.True(Directory.Exists(UserDirectories.Pictures));
}

[SkippableFact]
public void PublicShare()
{
Skip.IfNot(RuntimeInformation.IsOSPlatform(OSPlatform.Linux));
_output.WriteLine($"PublicShare: {UserDirectories.PublicShare}");
Assert.True(Directory.Exists(UserDirectories.PublicShare));
}

[Fact]
public void Templates()
{
Expand Down
4 changes: 2 additions & 2 deletions Nickvision.Aura/AppInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ internal AppInfo()
Artists = new Dictionary<string, Uri>();
TranslatorCredits = "";
}

/// <summary>
/// Gets changelog in HTML format
/// </summary>
Expand Down Expand Up @@ -131,7 +131,7 @@ public List<string> TranslatorNames
{
get
{
var result = new List<string> ();
var result = new List<string>();
foreach (var line in TranslatorCredits.Split("\n"))
{
if (line.IndexOf("<") > -1)
Expand Down
8 changes: 4 additions & 4 deletions Nickvision.Aura/Aura.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Nickvision.Aura;
public class Aura
{
private static Aura? _instance;

/// <summary>
/// The AppInfo object
/// </summary>
Expand All @@ -39,7 +39,7 @@ private Aura(string id, string name)
};
ConfigFiles = new Dictionary<string, ConfigurationBase>();
}

/// <summary>
/// Initialize Aura
/// </summary>
Expand All @@ -54,7 +54,7 @@ public static void Init(string id, string name)
}
_instance = new Aura(id, name);
}

/// <summary>
/// Get currently active instance of Aura
/// </summary>
Expand All @@ -70,7 +70,7 @@ public static Aura Active
return _instance;
}
}

/// <summary>
/// Start IPCServer or send command to a running one and quit
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Nickvision.Aura/DependencyLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static DependencyLocator()
/// <returns>The path of the dependency if found, else null</returns>
public static string? Find(string dependency)
{
if(_locations.ContainsKey(dependency) && !string.IsNullOrEmpty(_locations[dependency]))
if (_locations.ContainsKey(dependency) && !string.IsNullOrEmpty(_locations[dependency]))
{
return _locations[dependency];
}
Expand Down
8 changes: 4 additions & 4 deletions Nickvision.Aura/IPCServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public class IPCServer
{
private readonly string _id;
private bool _running;

/// <summary>
/// Occurs when a command is received
/// </summary>
public EventHandler<string[]>? CommandReceived;

/// <summary>
/// Construct IPCServer
/// </summary>
Expand All @@ -27,7 +27,7 @@ public IPCServer()
_id = Aura.Active.AppInfo.ID;
_running = false;
}

/// <summary>
/// Enable IPCServer.
/// First it will be checked if the server is already running
Expand Down Expand Up @@ -58,7 +58,7 @@ public bool Communicate(string[] args)
}
return _running;
}

/// <summary>
/// Triggers the server to start listening for commands
/// </summary>
Expand Down
5 changes: 2 additions & 3 deletions Nickvision.Aura/Keyring/Credential.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Linq;
using System.Text.RegularExpressions;

namespace Nickvision.Aura.Keyring;

Expand Down Expand Up @@ -42,7 +41,7 @@ public class Credential : IComparable<Credential>, IEquatable<Credential>
/// The password of the credential
/// </summary>
public string Password { get; set; }

/// <summary>
/// Constructs a Credential
/// </summary>
Expand All @@ -58,7 +57,7 @@ public Credential(string name, Uri? uri, string username, string password)
Username = username;
Password = password;
}

/// <summary>
/// Constructs a Credential
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions Nickvision.Aura/Keyring/Keyring.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class Keyring : IDisposable
{
private bool _disposed;
private readonly Store _store;

/// <summary>
/// The name of the Keyring
/// </summary>
Expand Down Expand Up @@ -139,7 +139,7 @@ protected virtual void Dispose(bool disposing)
/// <returns>True if successful, else false</returns>
public async Task<bool> DestroyAsync()
{
if(_store.Destroy())
if (_store.Destroy())
{
try
{
Expand Down
25 changes: 12 additions & 13 deletions Nickvision.Aura/Keyring/KeyringDialogController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Nickvision.Aura.Keyring;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
Expand Down Expand Up @@ -46,11 +45,11 @@ public class KeyringDialogController
/// <exception cref="ArgumentException">Thrown if the keyring name is empty or if there is a mismatch between the name and Keyring object</exception>
public KeyringDialogController(string name, Keyring? keyring)
{
if(string.IsNullOrEmpty(name))
if (string.IsNullOrEmpty(name))
{
throw new ArgumentException("Keyring name can not be empty.");
}
if(keyring != null && keyring.Name != name)
if (keyring != null && keyring.Name != name)
{
throw new ArgumentException("Provided Keyring object does not match the provided keyring name.");
}
Expand All @@ -64,7 +63,7 @@ public KeyringDialogController(string name, Keyring? keyring)
/// <returns>True if successful, false is Keyring already enabled or error</returns>
public async Task<bool> EnableKeyringAsync(string? password = null)
{
if(Keyring == null)
if (Keyring == null)
{
Keyring = await Keyring.AccessAsync(_keyringName, password);
return Keyring != null;
Expand All @@ -78,7 +77,7 @@ public async Task<bool> EnableKeyringAsync(string? password = null)
/// <returns>True if successful, false if Keyring already disabled</returns>
public async Task<bool> DisableKeyringAsync()
{
if(Keyring != null)
if (Keyring != null)
{
await Keyring.DestroyAsync();
Keyring = null;
Expand Down Expand Up @@ -112,15 +111,15 @@ public async Task<bool> ResetKeyringAsync()
public CredentialCheckStatus ValidateCredential(string name, string? uri, string username, string password)
{
CredentialCheckStatus result = 0;
if(string.IsNullOrEmpty(name))
if (string.IsNullOrEmpty(name))
{
result |= CredentialCheckStatus.EmptyName;
}
if(string.IsNullOrEmpty(username) && string.IsNullOrEmpty(password))
if (string.IsNullOrEmpty(username) && string.IsNullOrEmpty(password))
{
result |= CredentialCheckStatus.EmptyUsernamePassword;
}
if(!string.IsNullOrEmpty(uri))
if (!string.IsNullOrEmpty(uri))
{
try
{
Expand All @@ -144,7 +143,7 @@ public CredentialCheckStatus ValidateCredential(string name, string? uri, string
/// <returns>The list of Credential objects</returns>
public async Task<List<Credential>> GetAllCredentialsAsync()
{
if(Keyring != null)
if (Keyring != null)
{
return await Keyring.GetAllCredentialsAsync();
}
Expand All @@ -161,7 +160,7 @@ public async Task<List<Credential>> GetAllCredentialsAsync()
/// <returns>True if successful, else false</returns>
public async Task<bool> AddCredentialAsync(string name, string? uri, string username, string password)
{
if(ValidateCredential(name, uri, username, password) == CredentialCheckStatus.Valid && Keyring != null)
if (ValidateCredential(name, uri, username, password) == CredentialCheckStatus.Valid && Keyring != null)
{
return await Keyring.AddCredentialAsync(new Credential(name, string.IsNullOrEmpty(uri) ? null : new Uri(uri), username, password));
}
Expand All @@ -179,10 +178,10 @@ public async Task<bool> AddCredentialAsync(string name, string? uri, string user
/// <returns>True if successful, else false</returns>
public async Task<bool> UpdateCredentialAsync(int id, string name, string? uri, string username, string password)
{
if(ValidateCredential(name, uri, username, password) == CredentialCheckStatus.Valid && Keyring != null)
if (ValidateCredential(name, uri, username, password) == CredentialCheckStatus.Valid && Keyring != null)
{
var credential = await Keyring.LookupCredentialAsync(id);
if(credential != null)
if (credential != null)
{
credential.Name = name;
credential.Uri = string.IsNullOrEmpty(uri) ? null : new Uri(uri);
Expand All @@ -201,7 +200,7 @@ public async Task<bool> UpdateCredentialAsync(int id, string name, string? uri,
/// <returns>True if successful, else false</returns>
public async Task<bool> DeleteCredentialAsync(int id)
{
if(Keyring != null)
if (Keyring != null)
{
return await Keyring.DeleteCredentialAsync(id);
}
Expand Down
16 changes: 8 additions & 8 deletions Nickvision.Aura/Keyring/PasswordGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class PasswordGenerator
{
private readonly List<char> _chars;
private PasswordContent _contentFlags;

/// <summary>
/// Constructs password generator
/// </summary>
Expand All @@ -31,49 +31,49 @@ public PasswordGenerator(PasswordContent contentFlags = PasswordContent.Numeric
_chars = new();
ContentFlags = contentFlags;
}

/// <summary>
/// Possible characters for PasswordGenerator
/// </summary>
public PasswordContent ContentFlags
{
get => _contentFlags;

set
{
_contentFlags = value;
_chars.Clear();
if (_contentFlags.HasFlag(PasswordContent.Numeric))
{
_chars.AddRange(new []{ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' });
_chars.AddRange(new[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' });
}
if (_contentFlags.HasFlag(PasswordContent.Uppercase))
{
_chars.AddRange(new []
_chars.AddRange(new[]
{
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
});
}
if (_contentFlags.HasFlag(PasswordContent.Lowercase))
{
_chars.AddRange(new []
_chars.AddRange(new[]
{
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
});
}
if (_contentFlags.HasFlag(PasswordContent.Special))
{
_chars.AddRange(new []
_chars.AddRange(new[]
{
'!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', ':',
';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`', '{', '|', '}', '~'
});
}
}
}

/// <summary>
/// Generates new password
/// </summary>
Expand Down
Loading

0 comments on commit f1a4a61

Please sign in to comment.