Skip to content
This repository was archived by the owner on Aug 9, 2025. It is now read-only.

Commit e8a30dc

Browse files
committed
Resolve #98, get rid of repetitive string constant
1 parent 1891fa2 commit e8a30dc

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

CPPCheckPlugin/CPPCheckPluginPackage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ private void documentSaved(Document document)
210210
if (document == null || document.Language != "C/C++")
211211
return;
212212

213-
if (Properties.Settings.Default["CheckSavedFiles"] != null && Properties.Settings.Default.CheckSavedFiles == false)
213+
if (Properties.Settings.Default[Properties.Settings.CheckSavedFilesOptionKeyName] != null && Properties.Settings.Default.CheckSavedFiles == false)
214214
return;
215215

216216
if (document.ActiveWindow == null)
@@ -240,7 +240,7 @@ private void documentSaved(Document document)
240240
if (sourceForAnalysis == null)
241241
return;
242242

243-
if (Properties.Settings.Default["CheckSavedFiles"] == null)
243+
if (Properties.Settings.Default[Properties.Settings.CheckSavedFilesOptionKeyName] == null)
244244
{
245245
askCheckSavedFiles();
246246

CPPCheckPlugin/CppcheckSettings.xaml.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,25 @@ public CppcheckSettings()
3434

3535
Properties.Settings.Default.Save();
3636

37-
if (Properties.Settings.Default["CheckSavedFiles"] == null)
37+
if (Properties.Settings.Default[Properties.Settings.CheckSavedFilesOptionKeyName] == null)
3838
{
3939
CPPCheckPluginPackage.askCheckSavedFiles();
4040
}
4141
}
4242

4343
private void onActivated(object o, EventArgs e)
4444
{
45-
InconclusiveChecks.IsChecked = Properties.Settings.Default.InconclusiveChecksEnabled;
45+
var settings = Properties.Settings.Default;
4646

47-
CheckSavedFiles.IsChecked = Properties.Settings.Default.CheckSavedFiles;
48-
Project_OnlyCheckCurrentConfig.IsChecked = Properties.Settings.Default.ProjectOnlyCheckCurrentConfig;
49-
File_OnlyCheckCurrentConfig.IsChecked = Properties.Settings.Default.FileOnlyCheckCurrentConfig;
50-
ArgumentsEditor.Text = Properties.Settings.Default.DefaultArguments;
47+
InconclusiveChecks.IsChecked = settings.InconclusiveChecksEnabled;
48+
49+
if (settings[Properties.Settings.CheckSavedFilesOptionKeyName] == null)
50+
CheckSavedFiles.IsChecked = false;
51+
else
52+
CheckSavedFiles.IsChecked = settings.CheckSavedFiles;
53+
Project_OnlyCheckCurrentConfig.IsChecked = settings.ProjectOnlyCheckCurrentConfig;
54+
File_OnlyCheckCurrentConfig.IsChecked = settings.FileOnlyCheckCurrentConfig;
55+
ArgumentsEditor.Text = settings.DefaultArguments;
5156
}
5257

5358
private void OnClosed(object o, EventArgs e)
@@ -70,13 +75,13 @@ private void inconclusive_Checked(object sender, RoutedEventArgs e)
7075

7176
private void checkSavedFiles_Unchecked(object sender, RoutedEventArgs e)
7277
{
73-
Properties.Settings.Default["CheckSavedFiles"] = false;
78+
Properties.Settings.Default[Properties.Settings.CheckSavedFilesOptionKeyName] = false;
7479
Properties.Settings.Default.Save();
7580
}
7681

7782
private void checkSavedFiles_Checked(object sender, RoutedEventArgs e)
7883
{
79-
Properties.Settings.Default["CheckSavedFiles"] = true;
84+
Properties.Settings.Default[Properties.Settings.CheckSavedFilesOptionKeyName] = true;
8085
Properties.Settings.Default.Save();
8186
}
8287

CPPCheckPlugin/Settings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ private void SettingChangingEventHandler(object sender, System.Configuration.Set
2424
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
2525
// Add code to handle the SettingsSaving event here.
2626
}
27+
28+
public const string CheckSavedFilesOptionKeyName = "CheckSavedFiles";
2729
}
2830
}

0 commit comments

Comments
 (0)