Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 35 additions & 5 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,54 @@ jobs:
with:
dotnet-version: '8.0.x'

- name: Install SonarScanner
run: dotnet tool install --global dotnet-sonarscanner
- name: Install global tools (SonarScanner + ReportGenerator)
run: |
dotnet tool install --global dotnet-sonarscanner
dotnet tool install --global dotnet-reportgenerator-globaltool

- name: Add tool path to environment
run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH

- name: Restore dependencies
run: dotnet restore src/Faura.sln

- name: Begin SonarCloud Analysis
- name: Begin SonarCloud analysis
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
dotnet sonarscanner begin \
/k:"JosepFe_faura" \
/o:"josepfe" \
/d:sonar.login="${SONAR_TOKEN}" \
/d:sonar.host.url="https://sonarcloud.io"
/d:sonar.host.url="https://sonarcloud.io" \
/d:sonar.cs.opencover.reportsPaths="coverage/combined/coverage.opencover.xml"

- name: Build solution
run: dotnet build src/Faura.sln --no-restore --no-incremental
run: dotnet build src/Faura.sln --no-restore --configuration Release

- name: Run Unit Tests with Coverage (WebAPI)
run: |
mkdir -p coverage/unit
dotnet test src/Templates/Faura.WebAPI.UnitTests/Faura.WebAPI.UnitTests.csproj \
--configuration Release \
/p:CollectCoverage=true \
/p:CoverletOutputFormat=opencover \
/p:CoverletOutput=coverage/unit/ \
--no-build

- name: Merge coverage reports
run: |
mkdir -p coverage/combined
reportgenerator \
-reports:"coverage/unit/coverage.opencover.xml" \
-targetdir:"coverage/combined" \
-reporttypes:Html

- name: Upload Coverage Report Artifact
uses: actions/upload-artifact@v4
with:
name: CoverageReport
path: coverage/combined

- name: End SonarCloud Analysis
env:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ AppPackages/
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
Expand Down
157 changes: 157 additions & 0 deletions src/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
root = true

[*]
charset = utf-8
indent_size = 4
indent_style = space
insert_final_newline = true
time_trailing_whitespace = true
end_of_line = lf

[*.cs]
csharp_using_directive_placement = inside_namespace:warning
dotnet_sort_system_directives_first = true
csharp_style_expression_bodied_methods = true:warning
csharp_style_expression_bodied_constructors = true:warning
csharp_style_expression_bodied_properties = true:warning
csharp_style_expression_bodied_indexers = true:warning
csharp_style_expression_bodied_accessors = true:warning


### IDE specific rules

# IDE0090: Use 'new(...)'
csharp_style_implicit_object_creation_when_type_is_apparent = true

# IDE0017: Simplify object initialization
dotnet_style_object_initializer = true

### StyleCop.Analyzers custom configuration

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

# Methods should only be documented if shipped as a public API, the best documentation is the code implementation
dotnet_diagnostic.SA1516.severity = none
dotnet_diagnostic.SA1600.severity = none
dotnet_diagnostic.SA1601.severity = none
dotnet_diagnostic.SA1602.severity = none
dotnet_diagnostic.SA1611.severity = none
dotnet_diagnostic.SA1615.severity = none
dotnet_diagnostic.SA1618.severity = none
dotnet_diagnostic.SA1619.severity = none

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

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

# SX1101: Do not prefix local calls with 'this.'
dotnet_diagnostic.SX1101.severity = warning

# SA1309: Field names should not begin with underscore
dotnet_diagnostic.SA1309.severity = none

# SX1309: Field names should begin with underscore
dotnet_diagnostic.SX1309.severity = warning

# SA1130: Classes should not be empty
dotnet_diagnostic.SA1130.severity = none

# SA1400: Access modifier must be declared
dotnet_diagnostic.SA1400.severity = warning

# SA1413: Use trailing commas in multi-line initializers
dotnet_diagnostic.SA1413.severity = warning

# SA1503: Braces should not be omitted
dotnet_diagnostic.SA1503.severity = none

### SonarAnalyzer.CSharp custom configuration

# S1128: Unused "using" should be removed
dotnet_diagnostic.S1128.severity = warning

# S2094: Classes should not be empty
dotnet_diagnostic.S2094.severity = none

# S4487: Unread "private" fields should be removed
dotnet_diagnostic.S4487.severity = warning

# S1172: Unused method parameters should be removed
dotnet_diagnostic.S1172.severity = warning

#Disable S1133 for obsolete
dotnet_diagnostic.S1133.severity = suggestion

#Disable CS0618 for obsolete
dotnet_diagnostic.CS0618.severity = suggestion
csharp_indent_labels = one_less_than_current
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = file_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_prefer_system_threading_lock = true:suggestion
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_space_around_binary_operators = before_and_after
dotnet_diagnostic.SA1010.severity = none
dotnet_diagnostic.SA1000.severity = none

[*.{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
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
43 changes: 43 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<Project>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
<RunCodeAnalysis>false</RunCodeAnalysis>
<NeutralLanguage>en</NeutralLanguage>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Authors>Faura</Authors>
<Product>Faura</Product>
<RepositoryType>git</RepositoryType>
<Version>1.0.0</Version>
</PropertyGroup>

<ItemGroup Condition=" '$(MSBuildProjectExtension)' != '.dcproj'">
<AdditionalFiles Include="..\..\stylecop.json" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.11.0.117924">
<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 Condition="'$(IsTestProject)' == true">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
40 changes: 31 additions & 9 deletions src/Faura.sln
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,22 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Faura.Infrastructure.ApiBoo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Faura.Infrastructure.IntegrationTesting", "Modules\Faura.Infrastructure.IntegrationTesting\Faura.Infrastructure.IntegrationTesting.csproj", "{09790598-6AD0-D698-A32D-D9A056BAF8D0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Faura.IntegrationTest", "Templates\Faura.IntegrationTest\Faura.IntegrationTest.csproj", "{89320569-AAF8-4290-B912-699F792319F5}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
..\.gitignore = ..\.gitignore
Directory.Build.props = Directory.Build.props
global.json = global.json
stylecop.json = stylecop.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebAPI", "WebAPI", "{F1517752-590B-4773-A4D6-9E670C639523}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebAPIGrpc", "WebAPIGrpc", "{F3ABDB5B-F5E0-43DE-898B-4170F6852893}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Faura.WebAPI.UnitTests", "Templates\Faura.WebAPI.UnitTests\Faura.WebAPI.UnitTests.csproj", "{38B3C54C-1AED-42E7-A510-0734DF5A7B8F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Faura.WebAPI.IntegrationTests", "Templates\Faura.WebAPI.IntegrationTests\Faura.WebAPI.IntegrationTests.csproj", "{71A15B05-FF1A-8D1F-0833-4F72927CEC48}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -75,10 +90,14 @@ Global
{09790598-6AD0-D698-A32D-D9A056BAF8D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{09790598-6AD0-D698-A32D-D9A056BAF8D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{09790598-6AD0-D698-A32D-D9A056BAF8D0}.Release|Any CPU.Build.0 = Release|Any CPU
{89320569-AAF8-4290-B912-699F792319F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{89320569-AAF8-4290-B912-699F792319F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{89320569-AAF8-4290-B912-699F792319F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{89320569-AAF8-4290-B912-699F792319F5}.Release|Any CPU.Build.0 = Release|Any CPU
{38B3C54C-1AED-42E7-A510-0734DF5A7B8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{38B3C54C-1AED-42E7-A510-0734DF5A7B8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{38B3C54C-1AED-42E7-A510-0734DF5A7B8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{38B3C54C-1AED-42E7-A510-0734DF5A7B8F}.Release|Any CPU.Build.0 = Release|Any CPU
{71A15B05-FF1A-8D1F-0833-4F72927CEC48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{71A15B05-FF1A-8D1F-0833-4F72927CEC48}.Debug|Any CPU.Build.0 = Debug|Any CPU
{71A15B05-FF1A-8D1F-0833-4F72927CEC48}.Release|Any CPU.ActiveCfg = Release|Any CPU
{71A15B05-FF1A-8D1F-0833-4F72927CEC48}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -87,14 +106,17 @@ Global
{F0757E5C-ACCD-44DD-B755-64CAFE654A7A} = {420A3EFF-9247-407D-B58F-EC8144EB14F4}
{8146A031-8E30-4F0F-940E-F77795C208F8} = {420A3EFF-9247-407D-B58F-EC8144EB14F4}
{1F34C695-2396-428D-87EF-7D3FDD9BD8C2} = {420A3EFF-9247-407D-B58F-EC8144EB14F4}
{2B690895-0614-4013-85D8-7FC47B956C26} = {0C2B5D2F-B5EE-48E0-ACEE-A064E0232A26}
{2B690895-0614-4013-85D8-7FC47B956C26} = {F1517752-590B-4773-A4D6-9E670C639523}
{F749C616-5B16-4A0B-9F88-D08BEAA5F27B} = {420A3EFF-9247-407D-B58F-EC8144EB14F4}
{CE7C267E-97CF-4C7F-A5D0-B8AFC30C6130} = {420A3EFF-9247-407D-B58F-EC8144EB14F4}
{09790598-6AD0-D698-A32D-D9A056BAF8D0} = {420A3EFF-9247-407D-B58F-EC8144EB14F4}
{89320569-AAF8-4290-B912-699F792319F5} = {0C2B5D2F-B5EE-48E0-ACEE-A064E0232A26}
{AFC92389-71C2-BB14-10A4-CA1B415F02E9} = {420A3EFF-9247-407D-B58F-EC8144EB14F4}
{31D599B8-9C10-410E-9ACD-0F2201C2BD4E} = {0C2B5D2F-B5EE-48E0-ACEE-A064E0232A26}
{31D599B8-9C10-410E-9ACD-0F2201C2BD4E} = {F3ABDB5B-F5E0-43DE-898B-4170F6852893}
{93D57E51-3F79-19CF-B65F-08600B130F57} = {420A3EFF-9247-407D-B58F-EC8144EB14F4}
{09790598-6AD0-D698-A32D-D9A056BAF8D0} = {420A3EFF-9247-407D-B58F-EC8144EB14F4}
{F1517752-590B-4773-A4D6-9E670C639523} = {0C2B5D2F-B5EE-48E0-ACEE-A064E0232A26}
{F3ABDB5B-F5E0-43DE-898B-4170F6852893} = {0C2B5D2F-B5EE-48E0-ACEE-A064E0232A26}
{38B3C54C-1AED-42E7-A510-0734DF5A7B8F} = {F1517752-590B-4773-A4D6-9E670C639523}
{71A15B05-FF1A-8D1F-0833-4F72927CEC48} = {F1517752-590B-4773-A4D6-9E670C639523}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7B487365-BA97-49F1-93FD-C12DB361C20B}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
using Microsoft.Extensions.DependencyInjection;

namespace Faura.Infrastructure.ApiBootstrapper.Extensions;

using Microsoft.Extensions.DependencyInjection;

public static class ApiExtensions
{
/// <summary>
/// Configures controllers.
/// </summary>
/// <param name="services"><see cref="IServiceCollection"/> services.</param>
/// <returns><see cref="IMvcBuilder"/></returns>
public static IMvcBuilder ConfigureControllers(this IServiceCollection services) =>
services.AddControllers();
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Faura.Configurations;
using Microsoft.Extensions.Configuration;

namespace Faura.Infrastructure.ApiBootstrapper.Extensions;

using Faura.Infrastructure.Common.Models;
using Microsoft.Extensions.Configuration;

public static class ConfigurationExtensions
{
public static void ConfigureUserSecrets<T>(this IConfigurationBuilder configBuilder)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
using Microsoft.AspNetCore.Builder;
namespace Faura.Infrastructure.ApiBootstrapper.Extensions;

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace Faura.Infrastructure.ApiBootstrapper.Extensions;

public static class HeadersPropagationExtensions
{
public const string CorrelationIdHeaderKey = "x-correlation-id";

public static void AddHeadersPropagation(
this WebApplicationBuilder builder,
IConfiguration config
) => builder.Services.AddHeadersPropagation(config);
IConfiguration config)
=> builder.Services.AddHeadersPropagation(config);

public static IServiceCollection AddHeadersPropagation(
this IServiceCollection services,
IConfiguration config
)
IConfiguration config)
{
services.AddHeaderPropagation(options =>
{
Expand Down
Loading
Loading