Skip to content

Commit

Permalink
Merge pull request #127 from XanatosX/feature/fix-codacy-errors
Browse files Browse the repository at this point in the history
Feature/fix codacy errors
  • Loading branch information
XanatosX authored Jan 2, 2024
2 parents 40fa3ca + 491daa3 commit 2c60eb9
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 25 deletions.
5 changes: 2 additions & 3 deletions src/DefaultPlugins/ScriptExecutionPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using DefaultPlugins.Information;
using DefaultPlugins.ProcessStartStrategies;
using ModularToolManagerPlugin.Attributes;
using ModularToolManagerPlugin.Enums;
using ModularToolManagerPlugin.Models;
using ModularToolManagerPlugin.Plugin;
using ModularToolManagerPlugin.Services;
Expand All @@ -10,7 +9,7 @@
namespace DefaultPlugins;

/// <summary>
/// Plugin to run scripts on windows maschines
/// Plugin to run scripts on windows machines
/// </summary>
public sealed class ScriptExecutionPlugin : AbstractFunctionPlugin
{
Expand All @@ -22,7 +21,7 @@ public sealed class ScriptExecutionPlugin : AbstractFunctionPlugin
/// <summary>
/// The factory to use for creating starter objects
/// </summary>
private DefaultScriptStarterFactory starterFactory;
private readonly DefaultScriptStarterFactory starterFactory;

/// <summary>
/// Fallback text if a translation is missing
Expand Down
2 changes: 1 addition & 1 deletion src/ModularToolManager/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private Serilog.ILogger CreateLoggerConfig(IServiceCollection collection)
public override void OnFrameworkInitializationCompleted()
{
var provider = BuildServiceCollection().BuildServiceProvider();
WeakReferenceMessenger.Default.Register<RefreshMainWindow>(this, (_, e) =>
WeakReferenceMessenger.Default.Register<RefreshMainWindow>(this, (_, _) =>
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public override Color Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSe
case CurrentColorMode.Blue:
blue = number;
break;
default: break;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ internal class CultureInfoJsonConverter : JsonConverter<CultureInfo>
CultureInfo? culture = null;
try
{
culture = CultureInfo.GetCultureInfo(isoThreeCode ?? String.Empty);
culture = CultureInfo.GetCultureInfo(isoThreeCode ?? string.Empty);
}
catch (Exception)
{
// Culture not detected, returning null!
}
return culture;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ public List<CultureInfo> GetAvailableCultures()
{
returnCulture = CultureInfo.GetCultureInfo(Properties.Properties.FallbackLanguage);
}
catch (System.Exception)
catch (System.Exception e)
{
logger.LogWarning($"Could not get culture fallback with error {e.Message}");
}
return returnCulture;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ModularToolManager/Services/Settings/ISettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public interface ISettingsService
/// <summary>
/// Change the application settings
/// </summary>
/// <param name="changeSettings">The current settings to change</param>
/// <param name="changeSettingsAction">The current settings to change</param>
/// <returns>True if changing was successful</returns>
bool ChangeSettings(Action<ApplicationSettings> changeSettings);
bool ChangeSettings(Action<ApplicationSettings> changeSettingsAction);

/// <summary>
/// Save the application settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ public SerializedSettingsService(ISerializeService serializer,
}

/// <inheritdoc/>
public bool ChangeSettings(Action<ApplicationSettings> changeSettings)
public bool ChangeSettings(Action<ApplicationSettings> changeSettingsAction)
{
if (changeSettings is null)
if (changeSettingsAction is null)
{
return false;
}
ApplicationSettings settings = GetApplicationSettings();
changeSettings(settings);
changeSettingsAction(settings);
return settings is not null ? SaveApplicationSettings(settings) : false;
}

Expand All @@ -66,7 +66,7 @@ public ApplicationSettings GetApplicationSettings()
{
return cachedApplicationSettings;
}
ApplicationSettings returnData = new ApplicationSettings()
ApplicationSettings returnData = new ApplicationSettings
{
ShowInTaskbar = true,
EnableAutocompleteForFunctionSearch = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public IEnumerable<IStyle> GetCurrentAppIncludeStyles()
{
return Enumerable.Empty<IStyle>();
}
var styles = App.Current.Styles.Where(style => style.GetType() == typeof(Styles)).ToList(); ;
var types = styles.Select(style => style.GetType());
return App.Current?.Styles.Where(style => style.GetType() == typeof(Styles)) ?? Enumerable.Empty<IStyle>();
}

Expand All @@ -54,7 +52,6 @@ public IEnumerable<IStyle> GetCurrentAppIncludeStyles()
/// <inheritdoc/>
public T? GetStyleByName<T>(IStyle? style, string name) where T : AvaloniaObject
{
var test = GetCurrentAppIncludeStyles();
return GetAllStylesWithinResource(style)
.Where(style => style.Resources.Count > 0)
.Where(style => style.Resources.ContainsKey(name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public async Task ShowModalWindowAsync(ShowWindowModel modalData, Window? parent
public async Task<string[]> ShowOpenFileDialogAsync(ShowOpenFileDialogModel fileDialogModel, Window parent)
{
IStorageFolder? initialDirectory = await parent.StorageProvider.TryGetFolderFromPathAsync(fileDialogModel.InitialDirectory ?? string.Empty);
var files = await parent.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions() {
var files = await parent.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions {
AllowMultiple = fileDialogModel.AllowMultipleSelection,
FileTypeFilter = fileDialogModel.FileDialogFilters.ToList(),
SuggestedStartLocation = initialDirectory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private void SaveFunctionsOrder(SaveFunctionsOrderMessage saveFunctionMessage)
/// <inheritdoc/>
protected override void OnPropertyChanged(PropertyChangedEventArgs e)
{
Action action = e.PropertyName == nameof(SearchText) ? () => FilterFunctionList() : () => { return; };
Action action = e.PropertyName == nameof(SearchText) ? () => FilterFunctionList() : () => { };
action();
base.OnPropertyChanged(e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ModularToolManager/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public MainWindowViewModel(
SelectLanguageCommand = new AsyncRelayCommand(async () => await OpenModalWindow(Properties.Resources.SubMenu_Language, Properties.Properties.Icon_language, nameof(ChangeLanguageViewModel)));
HideApplicationCommand = new RelayCommand(() => WeakReferenceMessenger.Default.Send(new ToggleApplicationVisibilityMessage(true)));

WeakReferenceMessenger.Default.Register<ValueChangedMessage<ApplicationSettings>>(this, (_, e) =>
WeakReferenceMessenger.Default.Register<ValueChangedMessage<ApplicationSettings>>(this, (_, _) =>
{
UpdateShowInTaskbar();
});
Expand Down
4 changes: 2 additions & 2 deletions src/ModularToolManager/ViewModels/ModalWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public partial class ModalWindowViewModel : ObservableObject
/// Can the modal be resized
/// </summary>
[ObservableProperty]
public bool canResize;
private bool canResize;

/// <summary>
/// The service used to switch the application theme
Expand Down Expand Up @@ -95,7 +95,7 @@ public ModalWindowViewModel(
private void SwitchTheme(int themeId)
{
var theme = themeService.GetStyleById(themeId);
theme ??= theme ??= themeService.GetAllStyles().FirstOrDefault() ?? new ApplicationStyle { MaterialOpacity = 1, TintOpacity = 0.65f, TintColor = Colors.Pink };
theme ??= themeService.GetAllStyles().FirstOrDefault() ?? new ApplicationStyle { MaterialOpacity = 1, TintOpacity = 0.65f, TintColor = Colors.Pink };
if (theme is null)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal abstract partial class PluginSettingBaseViewModel : ObservableValidator
/// Create a new instance of this class
/// </summary>
/// <param name="settingModel">The setting model to create the data set from</param>
public PluginSettingBaseViewModel(SettingModel settingModel)
protected PluginSettingBaseViewModel(SettingModel settingModel)
{
storedModel = settingModel;
TranslationKey = settingModel.DisplayName ?? string.Empty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public override SettingModel GetSettingsModel()
/// <inheritdoc/>
public override void UpdateValue(object? newData)
{
if (newData is string)
if (newData is string stringData)
{
SettingText = (string)newData;
SettingText = stringData;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public bool OpenUrl(Uri url)
{
try
{
ProcessStartInfo processStartInfo = new ProcessStartInfo()
ProcessStartInfo processStartInfo = new ProcessStartInfo
{
UseShellExecute = true,
FileName = url.OriginalString
Expand Down

0 comments on commit 2c60eb9

Please sign in to comment.