Skip to content

Commit

Permalink
Fixed code analysis issues
Browse files Browse the repository at this point in the history
  • Loading branch information
credfeto committed Apr 19, 2024
1 parent aa674fb commit 4835666
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
3 changes: 3 additions & 0 deletions src/ChangeLog.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@
<s:Boolean x:Key="/Default/CodeStyle/Naming/CSharpNaming/ApplyAutoDetectedRules/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=EnumMember/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=236f7aa5_002D7b06_002D43ca_002Dbf2a_002D9b31bfcff09a/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Any" AccessRightKinds="Private" Description="Constant fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="CONSTANT_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=8b8504e3_002Df0be_002D4c14_002D9103_002Dc732f2bddc15/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Any" AccessRightKinds="Any" Description="Enum members"&gt;&lt;ElementKinds&gt;&lt;Kind Name="ENUM_MEMBER" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FBLOCK_005FSCOPE_005FCONSTANT/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FBLOCK_005FSCOPE_005FFUNCTION/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FBLOCK_005FSCOPE_005FVARIABLE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
Expand Down Expand Up @@ -424,6 +426,7 @@
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EPredefinedNamingRulesToUserRulesUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=weth/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=uniswap/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ecdsa/@EntryIndexedValue">True</s:Boolean>
Expand Down
2 changes: 2 additions & 0 deletions src/Credfeto.ChangeLog.Cmd/Credfeto.ChangeLog.Cmd.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
<EnableMicrosoftExtensionsConfigurationBinderSourceGenerator>true</EnableMicrosoftExtensionsConfigurationBinderSourceGenerator>
<EnablePackageValidation>true</EnablePackageValidation>
<EnableRequestDelegateGenerator>true</EnableRequestDelegateGenerator>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<Features>strict;flow-analysis</Features>
<GenerateNeutralResourcesLanguageAttribute>true</GenerateNeutralResourcesLanguageAttribute>
<IlcGenerateStackTraceData>false</IlcGenerateStackTraceData>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<UseSystemResourceKeys>true</UseSystemResourceKeys>
<WarningsAsErrors />
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
</PropertyGroup>
<PropertyGroup>
<AnalysisLevel>latest</AnalysisLevel>
Expand Down
8 changes: 5 additions & 3 deletions src/Credfeto.ChangeLog/ChangeLogChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,14 @@ private static bool CheckForChangesAfterFirstRelease(PatchEntryChanges change, i
private static string ExtractPatchDetails(string patch)
{
Console.WriteLine(patch);
List<string> lines = patch.Split('\n')
.ToList();
List<string> lines =
[
..patch.Split('\n')
];

RemoveLastLineIfBlank(lines);

int lastHunk = lines.FindLastIndex(x => CommonRegex.GitHunkPosition.IsMatch(x));
int lastHunk = lines.FindLastIndex(CommonRegex.GitHunkPosition.IsMatch);

if (lastHunk != -1)
{
Expand Down
18 changes: 10 additions & 8 deletions src/Credfeto.ChangeLog/ChangeLogUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ public static async Task RemoveEntryAsync(string changeLogFileName, string type,

private static async Task<string> ReadChangeLogAsync(string changeLogFileName, CancellationToken cancellationToken)
{
if (!File.Exists(changeLogFileName))
if (File.Exists(changeLogFileName))
{
await CreateEmptyAsync(changeLogFileName: changeLogFileName, cancellationToken: cancellationToken);

return TemplateFile.Initial;
return await File.ReadAllTextAsync(path: changeLogFileName, encoding: Encoding.UTF8, cancellationToken: cancellationToken);
}

return await File.ReadAllTextAsync(path: changeLogFileName, encoding: Encoding.UTF8, cancellationToken: cancellationToken);
await CreateEmptyAsync(changeLogFileName: changeLogFileName, cancellationToken: cancellationToken);

return TemplateFile.Initial;
}

public static string AddEntry(string changeLog, string type, string message)
Expand All @@ -68,9 +68,11 @@ private static string AddEntryCommon(string changeLog, string type, string messa

private static List<string> ChangeLogAsLines(string changeLog)
{
return EnsureChangelog(changeLog)
.SplitToLines()
.ToList();
return
[
.. EnsureChangelog(changeLog)
.SplitToLines()
];
}

public static string RemoveEntry(string changeLog, string type, string message)
Expand Down
1 change: 1 addition & 0 deletions src/Credfeto.ChangeLog/Credfeto.ChangeLog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<UseSystemResourceKeys>true</UseSystemResourceKeys>
<WarningsAsErrors />
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
</PropertyGroup>
<PropertyGroup>
<AnalysisLevel>latest</AnalysisLevel>
Expand Down

0 comments on commit 4835666

Please sign in to comment.