Skip to content

Commit

Permalink
chore: Code cleanup (#1143)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveSkender authored Jan 3, 2024
1 parent 0d3e8b4 commit 4407e16
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 195 deletions.
222 changes: 60 additions & 162 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,156 +1,38 @@
# top-most EditorConfig file
root = true

# global baselines
[*]
charset = utf-8
end_of_line = lf

indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
max_line_length = 150
tab_width = 2

[*.{cs,csx,vb,vbx}]
indent_size = 4
line_length = 150
max_line_length = 150
trim_trailing_whitespace = true
insert_final_newline = true

[*.cs]
csharp_indent_block_contents = true

# IDE0161 Convert to file-scoped namespace
csharp_style_namespace_declarations = file_scoped:suggestion
csharp_using_directive_placement = outside_namespace:warning
dotnet_style_namespace_match_folder = false:none

# CA1051: Do not declare visible instance fields
dotnet_diagnostic.CA1051.severity = silent

# CA1303: Do not pass literals as localized parameters
dotnet_diagnostic.CA1303.severity = none

# CA1720: Identifier contains type name
dotnet_diagnostic.CA1720.severity = silent
dotnet_diagnostic.IDE0090.severity = suggestion
dotnet_diagnostic.SA1413.severity = silent
dotnet_diagnostic.SA1200.severity = silent

# CS1591 Missing XML comment for publicly visible type
dotnet_diagnostic.CS1591.severity = none

# SA0001: XML comment analysis disabled
dotnet_diagnostic.SA0001.severity = none

# SA1000: Keywords should be spaced correctly
dotnet_diagnostic.SA1000.severity = silent

# SA1101: Prefix local calls with this
dotnet_diagnostic.SA1101.severity = none

# SA1108: Block statements should not contain embedded comments
dotnet_diagnostic.SA1108.severity = silent

# SA1117: Parameters should be on same line or separate lines
dotnet_diagnostic.SA1117.severity = none

# SA1118: Parameter should not span multiple lines
dotnet_diagnostic.SA1118.severity = silent

# SA1202: Elements should be ordered by access
dotnet_diagnostic.SA1202.severity = silent

# SA1208: Using directive sorting
dotnet_sort_system_directives_first = true

# SA1512: Single-line comments should not be followed by blank line
dotnet_diagnostic.SA1512.severity = silent

# SA1514: Element documentation header should be preceded by blank line
dotnet_diagnostic.SA1514.severity = silent

# SA1516: Elements should be separated by blank line
dotnet_diagnostic.SA1516.severity = silent

# SA1600: Elements should be documented
dotnet_diagnostic.SA1600.severity = none

# SA1601: Partial elements should be documented
dotnet_diagnostic.SA1601.severity = silent

# SA1602: Enumeration items should be documented
dotnet_diagnostic.SA1602.severity = silent

# SA1633: File should have header
dotnet_diagnostic.SA1633.severity = none

# Misc IDE
dotnet_diagnostic.IDE0055.severity = suggestion
dotnet_diagnostic.IDE0059.severity = suggestion
dotnet_diagnostic.IDE0060.severity = suggestion
dotnet_diagnostic.IDE0062.severity = suggestion
dotnet_diagnostic.IDE0063.severity = suggestion
dotnet_diagnostic.IDE0065.severity = suggestion
dotnet_diagnostic.IDE0066.severity = suggestion
dotnet_diagnostic.IDE0071.severity = suggestion
dotnet_diagnostic.IDE0047.severity = suggestion
csharp_indent_labels = no_change
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:suggestion
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_expression_bodied_methods = true:suggestion
csharp_style_expression_bodied_constructors = false:suggestion
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_style_expression_bodied_lambdas = true:warning
csharp_style_expression_bodied_local_functions = true:silent
csharp_style_throw_expression = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
dotnet_diagnostic.IDE0161.severity = suggestion
csharp_space_around_binary_operators = before_and_after
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
csharp_style_unused_value_expression_statement_preference = discard_variable:none
csharp_prefer_static_local_function = true:suggestion
csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false:silent
csharp_style_conditional_delegate_call = true:suggestion
csharp_style_prefer_parameter_null_checking = true:suggestion
csharp_style_prefer_switch_expression = true:suggestion
csharp_style_prefer_pattern_matching = true:silent
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_prefer_not_pattern = true:suggestion
csharp_style_prefer_extended_property_pattern = true:suggestion
csharp_style_var_for_built_in_types = false:warning
csharp_style_var_when_type_is_apparent = false:warning
csharp_style_var_elsewhere = false:suggestion
csharp_indent_case_contents = true
csharp_style_prefer_top_level_statements = false:silent
csharp_style_prefer_utf8_string_literals = true:suggestion
csharp_preserve_single_line_statements = false
csharp_style_prefer_primary_constructors = true:suggestion
[*.{csproj,props,targets}]
indent_style = space
indent_size = 2

# IDE0058: Expression value is never used
dotnet_diagnostic.IDE0058.severity = none
dotnet_diagnostic.IDE0077.severity = warning
dotnet_diagnostic.IDE0100.severity = suggestion
[*.yml]
indent_style = space
indent_size = 2

[*.{cs,vb}]
tab_width = 4
end_of_line = crlf
indent_size = 4
end_of_line = lf

#### Naming styles ####

# Naming rules

dotnet_naming_rule.interface_should_be_begins_with_i.severity = warning
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

Expand Down Expand Up @@ -192,33 +74,49 @@ 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_code_quality_unused_parameters = all:suggestion

dotnet_sort_system_directives_first = true

dotnet_style_operator_placement_when_wrapping = beginning_of_line
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
dotnet_style_namespace_match_folder = false:none
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_readonly_field = true:suggestion
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
dotnet_style_predefined_type_for_member_access = true:silent
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
dotnet_code_quality_unused_parameters = all:suggestion
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
dotnet_style_qualification_for_field = false:silent
dotnet_style_qualification_for_property = false:silent
dotnet_style_qualification_for_method = false:silent
dotnet_style_qualification_for_event = false:silent
dotnet_style_allow_multiple_blank_lines_experimental = false:suggestion
dotnet_style_allow_statement_immediately_after_block_experimental = false:suggestion
dotnet_style_prefer_collection_expression = true:suggestion

[*.cs]
csharp_indent_labels = one_less_than_current
csharp_using_directive_placement = outside_namespace:warning
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_static_local_function = true:suggestion
csharp_prefer_braces = true:suggestion
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 = true: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_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_unused_value_assignment_preference = unused_local_variable:suggestion
csharp_style_prefer_switch_expression = true:suggestion
csharp_style_prefer_pattern_matching = true:silent
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_prefer_not_pattern = true:suggestion
csharp_style_prefer_extended_property_pattern = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion

dotnet_diagnostic.CA1303.severity = none
dotnet_diagnostic.CS1591.severity = silent
dotnet_diagnostic.IDE0058.severity = none
1 change: 0 additions & 1 deletion .github/workflows/build-indicators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ jobs:
results-path: ./test-indicators/**/*.trx
coverage-path: ./test-indicators/**/coverage.cobertura.xml
coverage-type: cobertura
coverage-threshold: 95

- name: Post coverage to Codacy
uses: codacy/codacy-coverage-reporter-action@v1
Expand Down
7 changes: 0 additions & 7 deletions Stock.Indicators.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests.Other", "tests\other\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests.Performance", "tests\performance\Tests.Performance.csproj", "{3BD4837B-D197-41FD-A286-A3256D0770E1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{3A4158F9-4165-4823-9526-0CFAACCF1ACC}"
ProjectSection(SolutionItems) = preProject
.github\build.main.yml = .github\build.main.yml
.github\workflows\build.yml = .github\workflows\build.yml
.github\dependabot.yml = .github\dependabot.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
7 changes: 7 additions & 0 deletions src/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
Scope = "member",
Target = "~P:Skender.Stock.Indicators.IBasicData.Date")]

[assembly: SuppressMessage("Naming",
"CA1720:Identifier contains type name"
, Justification = "Not really an issue.",
Scope = "type",
Target = "~T:Skender.Stock.Indicators.ChandelierType")]

[assembly: SuppressMessage(
"Naming",
"CA1720:Identifier contains type name",
Expand All @@ -44,3 +50,4 @@
"StyleCop.CSharp.SpacingRules",
"SA1010:Opening square brackets should be spaced correctly",
Justification = "Invalid for new C# 12 [ collection ] syntax.")]

4 changes: 0 additions & 4 deletions src/Indicators.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
</ItemGroup>

Expand Down
4 changes: 0 additions & 4 deletions tests/indicators/Tests.Indicators.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 0 additions & 6 deletions tests/other/CustomIndicator.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ public class CustomIndicatorTests
{
private static readonly CultureInfo EnglishCulture = new("en-US", false);

#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter
#pragma warning disable SA1304 // Non-private readonly fields should begin with upper-case letter
#pragma warning disable SA1311 // Static readonly fields should begin with upper-case letter
internal static readonly IEnumerable<Quote> quotes = TestData.GetDefault();
internal static readonly IEnumerable<Quote> otherQuotes = TestData.GetCompare();
internal static readonly IEnumerable<Quote> badQuotes = TestData.GetBad();
Expand All @@ -100,9 +97,6 @@ public class CustomIndicatorTests
internal static readonly IEnumerable<Quote> randomQuotes = TestData.GetRandom(1000);
internal static readonly IEnumerable<Quote> zeroesQuotes = TestData.GetZeros();
internal static readonly IEnumerable<(DateTime, double)> tupleNanny = TestData.GetTupleNaN();
#pragma warning restore SA1307 // Accessible fields should begin with upper-case letter
#pragma warning restore SA1304 // Non-private readonly fields should begin with upper-case letter
#pragma warning restore SA1311 // Static readonly fields should begin with upper-case letter

[TestMethod]
public void Standard()
Expand Down
4 changes: 0 additions & 4 deletions tests/other/Tests.Other.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions tests/performance/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@
Justification = "Required for BenchmarkDotNet",
Scope = "member",
Target = "~F:Tests.Performance.InternalsPerformance.Periods")]

[assembly: SuppressMessage("Design",
"CA1051:Do not declare visible instance fields",
Justification = "Required for BenchmarkDotNet",
Scope = "member",
Target = "~F:Tests.Performance.InternalsPerformance.Periods")]
10 changes: 3 additions & 7 deletions tests/performance/Tests.Performance.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.11"/>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="BenchmarkDotNet" Version="0.13.11" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Indicators.csproj"/>
<ProjectReference Include="..\indicators\Tests.Indicators.csproj"/>
<ProjectReference Include="..\..\src\Indicators.csproj" />
<ProjectReference Include="..\indicators\Tests.Indicators.csproj" />
</ItemGroup>

</Project>

0 comments on commit 4407e16

Please sign in to comment.