Skip to content

Commit

Permalink
Enable dotnet built-in code analysis (#7)
Browse files Browse the repository at this point in the history
* Test dotnet official analyzer

* Try main instead?

* 2 dotnet versions

* Fun

* Trigger

* Disable built-in in inspect

* Explicit AnalysisMode

* Revert cs change
  • Loading branch information
Pythonic-Rainbow authored Jan 16, 2024
1 parent d773196 commit a318fde
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ jobs:
workingDirectory: './Bot'
solutionPath: './Bot.sln'
noBuild: true
minimumSeverity: 'warning'
minimumSeverity: 'warning'
70 changes: 70 additions & 0 deletions Bot/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

[*.{cs,vb}]
#### Naming styles ####

# Naming rules

dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i

dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

# Symbol specifications

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
indent_size = 4
end_of_line = crlf
dotnet_style_namespace_match_folder = true:suggestion

[*.cs]
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = file_scoped:suggestion
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_indent_labels = one_less_than_current
csharp_style_expression_bodied_lambdas = true:silent
12 changes: 11 additions & 1 deletion Bot/Bot.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>Hyperstellar</RootNamespace>

<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/overview?tabs=net-8 -->
<!-- https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#analysismode -->
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<AnalysisMode>Recommended</AnalysisMode>
<AnalysisModeStyle>All</AnalysisModeStyle>
<AnalysisModeNaming>All</AnalysisModeNaming>
<AnalysisModePerformance>All</AnalysisModePerformance>
<AnalysisModeGlobalization>None</AnalysisModeGlobalization>
<AnalysisModeSecurity>All</AnalysisModeSecurity>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Bot/Sql/Db.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ namespace Hyperstellar.Sql;

internal class Db
{
private static readonly SQLiteConnection _db = new("Hyperstellar.db");
private static readonly SQLiteConnection s_db = new("Hyperstellar.db");

Check warning on line 7 in Bot/Sql/Db.cs

View workflow job for this annotation

GitHub Actions / build

Unused field 's_db' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1823)

Check warning on line 7 in Bot/Sql/Db.cs

View workflow job for this annotation

GitHub Actions / build

Private member 'Db.s_db' can be removed as the value assigned to it is never read (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0052)
}

0 comments on commit a318fde

Please sign in to comment.