Skip to content

Commit 857f351

Browse files
Yassin Lokhatcursoragent
andcommitted
chore: enable latest-all analyzers and tune severities via .editorconfig
All three projects opt in to <AnalysisLevel>latest-all</AnalysisLevel>. A new root .editorconfig pragmatically maps the analyser rules that would require sweeping rewrites (culture-sensitive string APIs, visible-field design, multidimensional array layout, exception base class choice, etc.) to 'suggestion' so they remain visible in the IDE while TreatWarningsAsErrors continues to enforce correctness rules. CA5350/CA5351/CA5394/CA5401 are explicitly noted as follow-ups because changing the algorithms would invalidate every existing on-disk database. One genuine correctness issue surfaced by the new analysers is fixed: HotKeyHelper now compares the wParam IntPtr against the cached IntPtr representation of the hotkey id instead of an int cast that could silently overflow on .NET 7+ (CA2020). Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 77c2ce9 commit 857f351

5 files changed

Lines changed: 105 additions & 1 deletion

File tree

.editorconfig

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
root = true
2+
3+
[*.cs]
4+
indent_style = space
5+
indent_size = 3
6+
end_of_line = crlf
7+
insert_final_newline = true
8+
charset = utf-8-bom
9+
trim_trailing_whitespace = true
10+
11+
# Security/correctness rules are kept as errors.
12+
# The rules below are downgraded because they would require sweeping
13+
# rewrites unrelated to the current focus (architecture, security and
14+
# performance). They can be tightened back to errors progressively.
15+
16+
# Style/design suggestions: keep visible (suggestion) but not breaking.
17+
dotnet_diagnostic.CA1003.severity = suggestion # EventHandler<T> with EventArgs
18+
dotnet_diagnostic.CA1008.severity = suggestion # Enums should have zero value
19+
dotnet_diagnostic.CA1024.severity = suggestion # Use properties where appropriate
20+
dotnet_diagnostic.CA1032.severity = suggestion # Implement standard exception ctors
21+
dotnet_diagnostic.CA1056.severity = suggestion # Uri properties should not be strings
22+
dotnet_diagnostic.CA1030.severity = suggestion # Make method an event
23+
dotnet_diagnostic.CA1031.severity = suggestion # Do not catch general Exception
24+
dotnet_diagnostic.CA1034.severity = suggestion # Nested types should not be visible
25+
dotnet_diagnostic.CA1051.severity = suggestion # Do not declare visible instance fields
26+
dotnet_diagnostic.CA1062.severity = suggestion # Validate arguments of public methods
27+
dotnet_diagnostic.CA1303.severity = none # Localised string literal
28+
dotnet_diagnostic.CA1304.severity = suggestion # ToLower without culture
29+
dotnet_diagnostic.CA1305.severity = suggestion # IFormatProvider missing
30+
dotnet_diagnostic.CA1307.severity = suggestion # StringComparison missing
31+
dotnet_diagnostic.CA1308.severity = suggestion # ToLowerInvariant vs ToUpperInvariant
32+
dotnet_diagnostic.CA1310.severity = suggestion # StartsWith without StringComparison
33+
dotnet_diagnostic.CA1311.severity = suggestion # Specify culture for ToLower/ToUpper
34+
dotnet_diagnostic.CA1707.severity = suggestion # Underscore in identifiers
35+
dotnet_diagnostic.CA1716.severity = suggestion # Reserved language identifier
36+
dotnet_diagnostic.CA1805.severity = suggestion # Default value initialization
37+
dotnet_diagnostic.CA1810.severity = suggestion # Init static fields inline
38+
dotnet_diagnostic.CA1812.severity = suggestion # Avoid uninstantiated internal class
39+
dotnet_diagnostic.CA1815.severity = suggestion # Override Equals on value types
40+
dotnet_diagnostic.CA1819.severity = suggestion # Properties should not return arrays
41+
dotnet_diagnostic.CA1822.severity = suggestion # Mark members static
42+
dotnet_diagnostic.CA1859.severity = suggestion # Use concrete types for performance
43+
dotnet_diagnostic.CA1862.severity = suggestion # StringComparison for Contains
44+
dotnet_diagnostic.CA2227.severity = suggestion # Collection properties should be read-only
45+
46+
# In an executable, internal types are encouraged but the existing
47+
# code base exposes most types publicly. Lower CA1515 to suggestion
48+
# to surface it without breaking the build.
49+
dotnet_diagnostic.CA1515.severity = suggestion
50+
51+
# CA1815 / CA1851 noisy across the codebase; keep as suggestion.
52+
dotnet_diagnostic.CA1851.severity = suggestion
53+
54+
# Security: keep dispose ownership warning visible without breaking.
55+
# Database lifecycle is managed by ISessionService.
56+
dotnet_diagnostic.CA2000.severity = suggestion
57+
58+
# CA5392 (DefaultDllImportSearchPaths): keep as suggestion; the
59+
# P/Invokes target well-known system DLLs (user32, dwmapi).
60+
dotnet_diagnostic.CA5392.severity = suggestion
61+
62+
# The Core/QrCode logic uses multidimensional arrays for matrix algebra.
63+
# Rewriting to jagged arrays would degrade readability without any gain.
64+
dotnet_diagnostic.CA1814.severity = suggestion
65+
66+
# CA1852 (seal internal types): worthwhile but currently noisy in Core.
67+
dotnet_diagnostic.CA1852.severity = suggestion
68+
69+
# CA2201 (reserved exception types): the codebase intentionally throws
70+
# NullReferenceException in some places; flag as suggestion until those
71+
# sites can be reviewed individually.
72+
dotnet_diagnostic.CA2201.severity = suggestion
73+
74+
# CA1001 (type owns disposable field but is not IDisposable): User holds
75+
# a DispatcherTimer; the existing lifetime is tied to Database.Dispose.
76+
# Surfaced as suggestion for a follow-up.
77+
dotnet_diagnostic.CA1001.severity = suggestion
78+
79+
# Cryptography rules: the existing on-disk format relies on MD5/SHA1/
80+
# legacy IV derivation. Changing the algorithms would silently break
81+
# every existing user database, so they are kept as suggestion and the
82+
# follow-up will introduce versioned migrations.
83+
dotnet_diagnostic.CA5350.severity = suggestion
84+
dotnet_diagnostic.CA5351.severity = suggestion
85+
dotnet_diagnostic.CA5394.severity = suggestion
86+
dotnet_diagnostic.CA5401.severity = suggestion
87+
88+
# Visual Studio Editor-only style rules; keep silent when not relevant.
89+
dotnet_diagnostic.IDE0001.severity = suggestion
90+
dotnet_diagnostic.IDE0008.severity = suggestion
91+
dotnet_diagnostic.IDE0028.severity = suggestion
92+
dotnet_diagnostic.IDE0046.severity = suggestion
93+
dotnet_diagnostic.IDE0047.severity = suggestion
94+
dotnet_diagnostic.IDE0048.severity = suggestion
95+
dotnet_diagnostic.IDE0058.severity = suggestion
96+
dotnet_diagnostic.IDE0072.severity = suggestion
97+
dotnet_diagnostic.IDE0290.severity = suggestion

Core/Upsilon.Apps.Passkey.Core.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
<Description>A local stored Password Manager Core.</Description>
1010
<AssemblyVersion>1.0.1</AssemblyVersion>
1111
<FileVersion>1.0.1</FileVersion>
12+
<EnableNETAnalyzers>true</EnableNETAnalyzers>
13+
<AnalysisLevel>latest-all</AnalysisLevel>
1214
</PropertyGroup>
1315

1416
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

GUI/WPF/Helper/HotKeyHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ public static int Register(Window window, ModifierKeys modifiers, Key key)
3737
return -1;
3838
}
3939

40+
IntPtr expected = (IntPtr)hotkeyId;
4041
HwndSourceHook hook = (IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) =>
4142
{
42-
if (msg == WM_HOTKEY && (int)wParam == hotkeyId)
43+
if (msg == WM_HOTKEY && wParam == expected)
4344
{
4445
HotkeyPressed?.Invoke(window, new HotkeyEventArgs(lParam));
4546
handled = true;

GUI/WPF/Upsilon.Apps.Passkey.GUI.WPF.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
<AssemblyVersion>1.0.2</AssemblyVersion>
1414
<FileVersion>1.0.2</FileVersion>
1515
<ApplicationIcon>icon.ico</ApplicationIcon>
16+
<EnableNETAnalyzers>true</EnableNETAnalyzers>
17+
<AnalysisLevel>latest-all</AnalysisLevel>
1618
</PropertyGroup>
1719

1820
<ItemGroup>

Interfaces/Upsilon.Apps.Passkey.Interfaces.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
<Title>$(AssemblyName)</Title>
88
<Authors>Yassin Lokhat</Authors>
99
<Description>A local stored Password Manager Interfaces.</Description>
10+
<EnableNETAnalyzers>true</EnableNETAnalyzers>
11+
<AnalysisLevel>latest-all</AnalysisLevel>
1012
</PropertyGroup>
1113

1214
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

0 commit comments

Comments
 (0)