From ba29fd484cd6800c09bc860c18f2624da95078e7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20Gr=C3=BCtzmacher?=
<44983012+lg2de@users.noreply.github.com>
Date: Sat, 2 Jan 2021 19:21:23 +0100
Subject: [PATCH] Fix migration of user settings (#99)
* Fix migration of settings
* update SQ configuration
* accept S3011 as issue
---
.sonarlint/SimpleAccounting.slconfig | 15 +
.../CSharp/SonarLint.xml | 184 +++++++++
.../lg2de_simpleaccountingcsharp.ruleset | 371 ++++++++++++++++++
SimpleAccounting.ruleset | 132 -------
SimpleAccounting.sln | 5 +-
SonarLint.xml | 49 ---
nuget.config | 2 +-
src/Directory.Build.props | 6 +-
src/SimpleAccounting/App.xaml.cs | 16 +
src/SimpleAccounting/SimpleAccounting.csproj | 2 +-
src/SimpleAccounting/SimpleAccounting.ruleset | 7 -
11 files changed, 592 insertions(+), 197 deletions(-)
create mode 100644 .sonarlint/SimpleAccounting.slconfig
create mode 100644 .sonarlint/lg2de_simpleaccounting/CSharp/SonarLint.xml
create mode 100644 .sonarlint/lg2de_simpleaccountingcsharp.ruleset
delete mode 100644 SimpleAccounting.ruleset
delete mode 100644 SonarLint.xml
delete mode 100644 src/SimpleAccounting/SimpleAccounting.ruleset
diff --git a/.sonarlint/SimpleAccounting.slconfig b/.sonarlint/SimpleAccounting.slconfig
new file mode 100644
index 00000000..2ca00b50
--- /dev/null
+++ b/.sonarlint/SimpleAccounting.slconfig
@@ -0,0 +1,15 @@
+{
+ "ServerUri": "https://sonarcloud.io/",
+ "Organization": {
+ "Key": "lg2de",
+ "Name": "lg2de"
+ },
+ "ProjectKey": "lg2de_SimpleAccounting",
+ "ProjectName": "SimpleAccounting",
+ "Profiles": {
+ "CSharp": {
+ "ProfileKey": "AXBfQepp7SsyObFKJnMR",
+ "ProfileTimestamp": "2020-12-28T10:06:26Z"
+ }
+ }
+}
\ No newline at end of file
diff --git a/.sonarlint/lg2de_simpleaccounting/CSharp/SonarLint.xml b/.sonarlint/lg2de_simpleaccounting/CSharp/SonarLint.xml
new file mode 100644
index 00000000..1fe74877
--- /dev/null
+++ b/.sonarlint/lg2de_simpleaccounting/CSharp/SonarLint.xml
@@ -0,0 +1,184 @@
+
+
+
+
+ sonar.cs.analyzeGeneratedCode
+ false
+
+
+ sonar.cs.file.suffixes
+ .cs
+
+
+ sonar.cs.ignoreHeaderComments
+ true
+
+
+ sonar.cs.roslyn.ignoreIssues
+ false
+
+
+
+
+ S103
+
+
+ maximumLineLength
+ 200
+
+
+
+
+ S104
+
+
+ maximumFileLocThreshold
+ 1000
+
+
+
+
+ S1067
+
+
+ max
+ 3
+
+
+
+
+ S107
+
+
+ max
+ 7
+
+
+
+
+ S110
+
+
+ max
+ 5
+
+
+
+
+ S1151
+
+
+ max
+ 8
+
+
+
+
+ S1192
+
+
+ threshold
+ 3
+
+
+
+
+ S1200
+
+
+ max
+ 30
+
+
+
+
+ S134
+
+
+ max
+ 3
+
+
+
+
+ S138
+
+
+ max
+ 80
+
+
+
+
+ S1451
+
+
+ headerFormat
+ .*Copyright \(c\) Lukas Gr.tzmacher\. All rights reserved\.
+
+
+
+ isRegularExpression
+ true
+
+
+
+
+ S1479
+
+
+ maximum
+ 30
+
+
+
+
+ S1541
+
+
+ maximumFunctionComplexityThreshold
+ 20
+
+
+
+
+ S2342
+
+
+ flagsAttributeFormat
+ ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$
+
+
+ format
+ ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$
+
+
+
+
+ S2436
+
+
+ max
+ 2
+
+
+ maxMethod
+ 3
+
+
+
+
+ S3776
+
+
+ propertyThreshold
+ 3
+
+
+ threshold
+ 20
+
+
+
+
+
\ No newline at end of file
diff --git a/.sonarlint/lg2de_simpleaccountingcsharp.ruleset b/.sonarlint/lg2de_simpleaccountingcsharp.ruleset
new file mode 100644
index 00000000..2ab8bce6
--- /dev/null
+++ b/.sonarlint/lg2de_simpleaccountingcsharp.ruleset
@@ -0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-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/SimpleAccounting.sln b/SimpleAccounting.sln
index 3e33244c..95f3861d 100644
--- a/SimpleAccounting.sln
+++ b/SimpleAccounting.sln
@@ -10,20 +10,19 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
CreateCoverReport.ps1 = CreateCoverReport.ps1
src\Directory.Build.props = src\Directory.Build.props
+ .sonarlint\lg2de_simpleaccountingcsharp.ruleset = .sonarlint\lg2de_simpleaccountingcsharp.ruleset
LICENSE = LICENSE
nuget.config = nuget.config
PatchVersion.ps1 = PatchVersion.ps1
README.md = README.md
- SimpleAccounting.ruleset = SimpleAccounting.ruleset
SimpleAccounting.sln.DotSettings = SimpleAccounting.sln.DotSettings
- SonarLint.xml = SonarLint.xml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleAccounting", "src\SimpleAccounting\SimpleAccounting.csproj", "{976604F7-86B8-407E-A9B2-592E376D7006}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleAccounting.UnitTests", "tests\SimpleAccounting.UnitTests\SimpleAccounting.UnitTests.csproj", "{E77B3647-FBC9-4138-A0D5-C9165EF45417}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleAccounting.IntegrationTests", "tests\SimpleAccounting.IntegrationTests\SimpleAccounting.IntegrationTests.csproj", "{507F5D29-96C7-48C2-966C-58342D08A4A7}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleAccounting.IntegrationTests", "tests\SimpleAccounting.IntegrationTests\SimpleAccounting.IntegrationTests.csproj", "{507F5D29-96C7-48C2-966C-58342D08A4A7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{3F74D64E-D629-4AC0-A60B-29ED0C265896}"
ProjectSection(SolutionItems) = preProject
diff --git a/SonarLint.xml b/SonarLint.xml
deleted file mode 100644
index e2283c65..00000000
--- a/SonarLint.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
-
- sonar.cs.ignoreHeaderComments
- true
-
-
-
-
- S1451
-
-
- headerFormat
- .*Copyright \(c\) Lukas Grützmacher\. All rights reserved\.
-
-
- isRegularExpression
- true
-
-
-
-
- S1541
-
-
- maximumFunctionComplexityThreshold
- 20
-
-
-
-
- S3776
-
-
- threshold
- 20
-
-
- propertyThreshold
- 3
-
-
-
-
-
-
-
diff --git a/nuget.config b/nuget.config
index 6f5b3de5..ccb0b1bd 100644
--- a/nuget.config
+++ b/nuget.config
@@ -6,4 +6,4 @@
-
\ No newline at end of file
+
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 77971fbc..cc807576 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -6,7 +6,7 @@
- $(MSBuildThisFileDirectory)..\SimpleAccounting.ruleset
+ $(MSBuildThisFileDirectory)..\.sonarlint\lg2de_simpleaccountingcsharp.ruleset
@@ -16,9 +16,7 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
-
- Properties\SonarLint.xml
-
+
\ No newline at end of file
diff --git a/src/SimpleAccounting/App.xaml.cs b/src/SimpleAccounting/App.xaml.cs
index 69a62c66..5844a95f 100644
--- a/src/SimpleAccounting/App.xaml.cs
+++ b/src/SimpleAccounting/App.xaml.cs
@@ -4,8 +4,12 @@
namespace lg2de.SimpleAccounting
{
+ using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
+ using System.IO;
+ using System.Linq;
+ using System.Reflection;
using System.Windows;
using System.Windows.Markup;
using lg2de.SimpleAccounting.Properties;
@@ -18,6 +22,18 @@ public App()
// upgrade settings from older versions
var settings = Settings.Default;
settings.Upgrade();
+
+ var provider = Settings.Default.Providers.OfType().FirstOrDefault();
+ var fileName = provider?.GetType().GetField(
+ "_prevLocalConfigFileName",
+ BindingFlags.Instance | BindingFlags.NonPublic)?
+ .GetValue(provider) as string;
+ if (File.Exists(fileName))
+ {
+ // delete configuration of old version
+ // ReSharper disable once AssignNullToNotNullAttribute
+ Directory.Delete(Path.GetDirectoryName(fileName), recursive: true);
+ }
}
[SuppressMessage(
diff --git a/src/SimpleAccounting/SimpleAccounting.csproj b/src/SimpleAccounting/SimpleAccounting.csproj
index 9b438569..39a4d987 100644
--- a/src/SimpleAccounting/SimpleAccounting.csproj
+++ b/src/SimpleAccounting/SimpleAccounting.csproj
@@ -10,7 +10,7 @@
true
true
Lukas Grützmacher
- Copyright © 2007-2020
+ Copyright © 2007-2021
DEVEL
App.ico
diff --git a/src/SimpleAccounting/SimpleAccounting.ruleset b/src/SimpleAccounting/SimpleAccounting.ruleset
deleted file mode 100644
index 1f050388..00000000
--- a/src/SimpleAccounting/SimpleAccounting.ruleset
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file