From 5335b5c6bd298e3a0d450d938d0f29b9f8824b73 Mon Sep 17 00:00:00 2001 From: danjov Date: Fri, 22 Nov 2024 16:04:01 +0100 Subject: [PATCH] Enable SA1515 / SA1516 and fix violations SA1515: SingleLineCommentMustBePrecededByBlankLine SA1516: ElementsMustBeSeparatedByBlankLine --- .editorconfig | 3 +- src/api/BdmsContext.cs | 34 +++++++++++++++++-- src/api/BoreholeGeometry/AzIncFormat.cs | 7 ++++ src/api/BoreholeGeometry/PitchRollFormat.cs | 6 ++++ src/api/BoreholeGeometry/XYZFormat.cs | 3 ++ src/api/CoordinateService.cs | 1 + src/api/DateOnlyJsonConverter.cs | 1 + src/api/LocationService.cs | 1 + ...30116102740_RemoveCantonsMunicipalities.cs | 1 + src/api/Models/Borehole.cs | 2 ++ src/api/Models/HydrotestCodelist.cs | 2 ++ 11 files changed, 58 insertions(+), 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index a06c1cda4..e7d10c7cd 100644 --- a/.editorconfig +++ b/.editorconfig @@ -248,7 +248,8 @@ dotnet_diagnostic.SA1503.severity = none dotnet_diagnostic.SA1504.severity = none dotnet_diagnostic.SA1512.severity = warning dotnet_diagnostic.SA1513.severity = warning -dotnet_diagnostic.SA1516.severity = none +dotnet_diagnostic.SA1515.severity = warning +dotnet_diagnostic.SA1516.severity = warning dotnet_diagnostic.SA1600.severity = none dotnet_diagnostic.SA1601.severity = none dotnet_diagnostic.SA1602.severity = none diff --git a/src/api/BdmsContext.cs b/src/api/BdmsContext.cs index 33ecb3aea..4faa93f36 100644 --- a/src/api/BdmsContext.cs +++ b/src/api/BdmsContext.cs @@ -12,45 +12,75 @@ namespace BDMS; public class BdmsContext : DbContext { public DbSet Boreholes { get; set; } + public DbSet Codelists { get; set; } + public DbSet Configs { get; set; } + public DbSet Files { get; set; } + public DbSet Layers { get; set; } + public DbSet Stratigraphies { get; set; } + public DbSet Terms { get; set; } + public DbSet Users { get; set; } + public IQueryable UsersWithIncludes => Users .Include(u => u.WorkgroupRoles) .ThenInclude(wr => wr.Workgroup) .Include(u => u.TermsAccepted) .ThenInclude(ta => ta.Term); + public DbSet UserWorkgroupRoles { get; set; } + public DbSet Workflows { get; set; } + public DbSet Workgroups { get; set; } - public IQueryable WorkgroupsWithIncludes => Workgroups - .Include(w => w.Boreholes); + public IQueryable WorkgroupsWithIncludes => Workgroups.Include(w => w.Boreholes); public DbSet BoreholeFiles { get; set; } + public DbSet LithologicalDescriptions { get; set; } + public DbSet FaciesDescriptions { get; set; } + public DbSet ChronostratigraphyLayers { get; set; } + public DbSet LithostratigraphyLayers { get; set; } + public DbSet Observations { get; set; } + public DbSet WaterIngresses { get; set; } + public DbSet Hydrotests { get; set; } + public DbSet HydrotestResults { get; set; } + public DbSet GroundwaterLevelMeasurements { get; set; } + public DbSet FieldMeasurements { get; set; } + public DbSet FieldMeasurementResults { get; set; } + public DbSet Completions { get; set; } + public DbSet Instrumentations { get; set; } + public DbSet Backfills { get; set; } + public DbSet Casings { get; set; } + public DbSet CasingElements { get; set; } + public DbSet
Sections { get; set; } + public DbSet SectionElements { get; set; } + public DbSet BoreholeGeometry { get; set; } + public DbSet BoreholeCodelists { get; set; } public BdmsContext(DbContextOptions options) diff --git a/src/api/BoreholeGeometry/AzIncFormat.cs b/src/api/BoreholeGeometry/AzIncFormat.cs index 5ef6e42c9..4c02ed664 100644 --- a/src/api/BoreholeGeometry/AzIncFormat.cs +++ b/src/api/BoreholeGeometry/AzIncFormat.cs @@ -11,8 +11,11 @@ namespace BDMS.BoreholeGeometry; internal sealed class AzIncFormat : IBoreholeGeometryFormat { public string Key => "AzInc"; + public string Name => "Azimuth Inclination"; + private Lazy expectedCsvHeader = new(Helper.GetCSVHeader); + public string CsvHeader => expectedCsvHeader.Value; public IList ReadCsv(IFormFile file, int boreholeId) @@ -96,12 +99,16 @@ internal sealed class Geometry { [Name("MD_m")] public double MeasuredDepth { get; set; } + [Name("HAZI_deg")] public double Azimuth { get; set; } + [Name("DEVI_deg")] public double Inclination { get; set; } + [Ignore] public double AzimuthRad { get; set; } + [Ignore] public double InclinationRad { get; set; } } diff --git a/src/api/BoreholeGeometry/PitchRollFormat.cs b/src/api/BoreholeGeometry/PitchRollFormat.cs index 8f12eb15d..4e8049741 100644 --- a/src/api/BoreholeGeometry/PitchRollFormat.cs +++ b/src/api/BoreholeGeometry/PitchRollFormat.cs @@ -11,8 +11,11 @@ namespace BDMS.BoreholeGeometry; internal sealed class PitchRollFormat : IBoreholeGeometryFormat { public string Key => "PitchRoll"; + public string Name => "Pitch Roll"; + private Lazy expectedCsvHeader = new(Helper.GetCSVHeader); + public string CsvHeader => expectedCsvHeader.Value; public IList ReadCsv(IFormFile file, int boreholeId) @@ -66,10 +69,13 @@ internal sealed class Geometry { [Name("MD_m")] public double MeasuredDepth { get; set; } + [Name("Roll_deg")] public double RollRad { get; set; } + [Name("Pitch_deg")] public double PitchRad { get; set; } + [Name("Yaw_deg")] public double YawRad { get; set; } } diff --git a/src/api/BoreholeGeometry/XYZFormat.cs b/src/api/BoreholeGeometry/XYZFormat.cs index b99917e2f..a44d26887 100644 --- a/src/api/BoreholeGeometry/XYZFormat.cs +++ b/src/api/BoreholeGeometry/XYZFormat.cs @@ -10,8 +10,11 @@ namespace BDMS.BoreholeGeometry; internal sealed class XYZFormat : IBoreholeGeometryFormat { public string Key => "XYZ"; + public string Name => "X Y Z"; + private Lazy expectedCsvHeader = new(Helper.GetCSVHeader); + public string CsvHeader => expectedCsvHeader.Value; public IList ReadCsv(IFormFile file, int boreholeId) diff --git a/src/api/CoordinateService.cs b/src/api/CoordinateService.cs index c772a188b..c2d5eba64 100644 --- a/src/api/CoordinateService.cs +++ b/src/api/CoordinateService.cs @@ -4,6 +4,7 @@ using System.Text.Json; namespace BDMS; + public class CoordinateService { private const string Lv95ToLv03 = "lv95tolv03"; diff --git a/src/api/DateOnlyJsonConverter.cs b/src/api/DateOnlyJsonConverter.cs index 8a59453a3..39a03763b 100644 --- a/src/api/DateOnlyJsonConverter.cs +++ b/src/api/DateOnlyJsonConverter.cs @@ -3,6 +3,7 @@ using System.Text.Json.Serialization; namespace BDMS; + public class DateOnlyJsonConverter : JsonConverter { private const string Format = "yyyy-MM-dd"; diff --git a/src/api/LocationService.cs b/src/api/LocationService.cs index 2ce1cb791..c5cfec368 100644 --- a/src/api/LocationService.cs +++ b/src/api/LocationService.cs @@ -3,6 +3,7 @@ using System.Text.Json; namespace BDMS; + public class LocationService { private readonly IHttpClientFactory httpClientFactory; diff --git a/src/api/Migrations/20230116102740_RemoveCantonsMunicipalities.cs b/src/api/Migrations/20230116102740_RemoveCantonsMunicipalities.cs index 895580ac2..701b0072d 100644 --- a/src/api/Migrations/20230116102740_RemoveCantonsMunicipalities.cs +++ b/src/api/Migrations/20230116102740_RemoveCantonsMunicipalities.cs @@ -5,6 +5,7 @@ #nullable disable namespace BDMS.Migrations; + public partial class RemoveCantonsMunicipalities : Migration { protected override void Up(MigrationBuilder migrationBuilder) diff --git a/src/api/Models/Borehole.cs b/src/api/Models/Borehole.cs index e58a6779f..6e82d4b38 100644 --- a/src/api/Models/Borehole.cs +++ b/src/api/Models/Borehole.cs @@ -160,6 +160,7 @@ public class Borehole : IChangeTracking, IIdentifyable /// [Column("restriction_id_cli")] public int? RestrictionId { get; set; } + public Codelist? Restriction { get; set; } /// @@ -191,6 +192,7 @@ public class Borehole : IChangeTracking, IIdentifyable /// [Column("qt_location_id_cli")] public int? LocationPrecisionId { get; set; } + public Codelist? LocationPrecision { get; set; } /// diff --git a/src/api/Models/HydrotestCodelist.cs b/src/api/Models/HydrotestCodelist.cs index 95aa2e94c..1f34d6362 100644 --- a/src/api/Models/HydrotestCodelist.cs +++ b/src/api/Models/HydrotestCodelist.cs @@ -10,9 +10,11 @@ public class HydrotestCodelist { [Column("id_ht_fk")] public int HydrotestId { get; set; } + public Hydrotest Hydrotest { get; set; } [Column("id_cli_fk")] public int CodelistId { get; set; } + public Codelist Codelist { get; set; } }