Skip to content

Commit

Permalink
more linting
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed Feb 8, 2023
1 parent 63d7de8 commit 6b6d074
Show file tree
Hide file tree
Showing 19 changed files with 125 additions and 59 deletions.
3 changes: 3 additions & 0 deletions src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ dotnet_diagnostic.IDE0073.severity = warning # Enforce file header
file_header_template = Copyright (c) by Terradue Srl. All Rights Reserved.\nLicense under the AGPL, Version 3.0.\nFile Name: {fileName}

# Microsoft.CodeAnalysis.CSharp.CodeStyle
dotnet_diagnostic.SA1005.severity = warning # Single line comments should begin with single space
dotnet_diagnostic.SA1028.severity = warning # Code should not contain trailing whitespace
dotnet_diagnostic.SA1101.severity = warning # Prefix local calls with this
dotnet_diagnostic.SA1107.severity = warning # Code should not contain multiple statements on one line
Expand All @@ -412,6 +413,7 @@ dotnet_diagnostic.SA1119.severity = warning # Statement must not use unnece
dotnet_diagnostic.SA1124.severity = warning # Do not use regions
dotnet_diagnostic.SA1127.severity = warning # Generic type constraints must be on their own line or share line with previous
dotnet_diagnostic.SA1128.severity = warning # Put constructor initializers on their own line
dotnet_diagnostic.SA1129.severity = warning # Do not use default value type constructor
dotnet_diagnostic.SA1137.severity = warning # Elements should have the same indentation
dotnet_diagnostic.SA1201.severity = warning # Elements must appear in the correct order
dotnet_diagnostic.SA1202.severity = warning # Elements must be ordered by access
Expand All @@ -433,6 +435,7 @@ dotnet_diagnostic.SA1513.severity = warning # Closing brace must be followe
dotnet_diagnostic.SA1514.severity = warning # Element documentation header must be preceded by blank line
dotnet_diagnostic.SA1515.severity = warning # Single-line comment must be preceded by blank line
dotnet_diagnostic.SA1516.severity = warning # Elements must be separated by blank line
dotnet_diagnostic.SA1520.severity = warning # Use braces consistently
dotnet_diagnostic.SA1623.severity = warning # Property summary documentation must match accessors
dotnet_diagnostic.SA1626.severity = warning # Single-line comments must not use documentation style slashes
dotnet_diagnostic.SA1636.severity = none # Disable file header matching
Expand Down
6 changes: 0 additions & 6 deletions src/DotNetStac/Collection/StacSummaryRangeObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,12 @@ public StacSummaryRangeObject(T min, T max)
/// Gets or sets minimum of the range
/// </summary>
/// <returns>Minimum of the range</returns>
/// <value>
/// Minimum of the range
/// </value>
public T Min { get => this.AsJToken["minimum"].Value<T>(); set => this.AsJToken["minimum"] = new JValue(value); }

/// <summary>
/// Gets or sets maximum of the range
/// </summary>
/// <returns>Maximum of the range</returns>
/// <value>
/// Maximum of the range
/// </value>
public T Max { get => this.AsJToken["maximum"].Value<T>(); set => this.AsJToken["maximum"] = new JValue(value); }

/// <inheritdoc/>
Expand Down
10 changes: 4 additions & 6 deletions src/DotNetStac/Collection/StacTemporalExtent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class StacTemporalExtent
/// <summary>
/// Initializes a new instance of the <see cref="StacTemporalExtent"/> class.
/// </summary>
/// <param name="start"></param>
/// <param name="end"></param>
/// <param name="start">Start time</param>
/// <param name="end">End time</param>
[JsonConstructor]
public StacTemporalExtent(DateTime? start, DateTime? end)
{
Expand All @@ -29,7 +29,7 @@ public StacTemporalExtent(DateTime? start, DateTime? end)
/// Initializes a new instance of the <see cref="StacTemporalExtent"/> class.
/// Intialize a new Stac Temporal Extent from an exisiting one (clone)
/// </summary>
/// <param name="temporal"></param>
/// <param name="temporal">The temporal extent to clone</param>
public StacTemporalExtent(StacTemporalExtent temporal)
{
this.Interval = (DateTime?[][])temporal.Interval.Clone();
Expand All @@ -38,9 +38,7 @@ public StacTemporalExtent(StacTemporalExtent temporal)
/// <summary>
/// Gets or sets potential temporal extents.
/// </summary>
/// <value>
/// Potential temporal extents.
/// </value>
/// <returns>Potential temporal extents.</returns>
[JsonProperty("interval")]
public DateTime?[][] Interval { get; set; }
}
Expand Down
4 changes: 2 additions & 2 deletions src/DotNetStac/Common/DataType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public enum DataType
// unsigned 64-bit integer
uint64,

// 16-bit float
// 16-bit float
float16,

// 32-bit float
Expand All @@ -56,7 +56,7 @@ public enum DataType
// 32-bit complex integer
cint32,

// 32-bit complex float
// 32-bit complex float
cfloat32,

// 64-bit complex float
Expand Down
8 changes: 6 additions & 2 deletions src/DotNetStac/Common/JsonMergeUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

namespace Stac.Common
{
/// <summary>
/// Utility class for merging JSON documents.
/// </summary>
public class JsonMergeUtils
{
/// <summary>
Expand Down Expand Up @@ -64,10 +67,11 @@ public static string Merge(string original, string patch, JsonWriterOptions? wri
/// <param name="patch">JSON Merge patch document.</param>
/// <param name="token">Cancellation token.</param>
/// <param name="writerOptions">Writer options used to write the merge result.</param>
/// <returns>The document that represents the merge result.</returns>
public static async Task<string> MergeAsync(string original, Stream patch, CancellationToken token = default, JsonWriterOptions? writerOptions = null)
{
var outputBuffer = new MemoryStream();
var jsonDocumentOptions = new JsonDocumentOptions();
var jsonDocumentOptions = default(JsonDocumentOptions);
using (var originalDoc = JsonDocument.Parse(original, jsonDocumentOptions))
using (var patchDoc = await JsonDocument.ParseAsync(patch, jsonDocumentOptions, token))
using (var jsonWriter = new Utf8JsonWriter(outputBuffer, writerOptions ?? new JsonWriterOptions { Indented = true }))
Expand Down Expand Up @@ -128,7 +132,7 @@ public static List<string> ExtractNullProperties(string patch)
/// <returns>The list of null properties.</returns>
public static async Task<List<string>> ExtractNullPropertiesAsync(Stream patch, CancellationToken token = default)
{
var patchDoc = await JsonDocument.ParseAsync(patch, new JsonDocumentOptions(), token);
var patchDoc = await JsonDocument.ParseAsync(patch, default(JsonDocumentOptions), token);
if (patchDoc.RootElement.ValueKind != JsonValueKind.Object)
{
throw new InvalidOperationException($"The patch JSON document must be an object type. Instead it is {patchDoc.RootElement.ValueKind}.");
Expand Down
4 changes: 4 additions & 0 deletions src/DotNetStac/Converters/CollectionConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
namespace Stac.Converters
{
#pragma warning disable SA1649 // File name should match first type name
/// <summary>
/// Converter for Collection
/// </summary>
/// <typeparam name="T">Type of the collection</typeparam>
public class CollectionConverter<T> : JsonConverter
{
/// <inheritdoc/>
Expand Down
53 changes: 20 additions & 33 deletions src/DotNetStac/Extensions/Alternate/AlternateStacExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Stac.Extensions.Storage;

namespace Stac.Extensions.Alternate
{
/// <summary>
/// Extension methods for accessing Alternate extension
/// </summary>
public static class AlternateStacExtensionExtensions
{
/// <summary>
/// Initilize a AlternateStacExtension class from a STAC asset
/// </summary>
public static AlternateStacExtension AlternateExtension(this StacAsset stacAsset)
{
return new AlternateStacExtension(stacAsset);
}

/// <summary>
/// Initilize a AlternateStacExtension class from an alternate asset
/// </summary>
public static StorageStacExtension StorageExtension(this AlternateAssetObject alternateAssetObject)
{
return new StorageStacExtension(alternateAssetObject);
}
}

/// <summary>
/// Helper class to access the fields defined by the <seealso href="https://github.com/stac-extensions/alternate">Alternate extension</seealso>
/// </summary>
public class AlternateStacExtension : StacPropertiesContainerExtension, IStacAssetExtension, IStacExtension
{
// Extension identifier and schema url
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public const string JsonSchemaUrl = "https://stac-extensions.github.io/alternate-assets/v1.1.0/schema.json";

private const string AlternateField = "alternate";
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member

private static IDictionary<string, Type> assetFields;

Expand All @@ -58,21 +36,23 @@ internal AlternateStacExtension(StacAsset stacAsset)
/// </value>
public IDictionary<string, AlternateAssetObject> AlternateAssets
{
get
{
return this.StacPropertiesContainer.GetProperty<Dictionary<string, AlternateAssetObject>>(AlternateField);
}

set
{
get
{
return this.StacPropertiesContainer.GetProperty<Dictionary<string, AlternateAssetObject>>(AlternateField);
}

set
{
if (value == null || value.Count() == 0)
{
this.StacPropertiesContainer.RemoveProperty(AlternateField);
}
else
{
this.StacPropertiesContainer.SetProperty(AlternateField, value);
this.DeclareStacExtension();
}
}
}
}
}

/// <summary>
Expand All @@ -93,6 +73,13 @@ public override IDictionary<string, ISummaryFunction> GetSummaryFunctions()
return summaryFunctions;
}

/// <summary>
/// Adds an alternate asset to the AlternateAssets dictionary
/// </summary>
/// <param name="key">The key of the alternate asset</param>
/// <param name="uri">The uri of the alternate asset</param>
/// <param name="title">The title of the alternate asset</param>
/// <param name="description">The description of the alternate asset</param>
public AlternateAssetObject AddAlternate(string key, Uri uri, string title = null, string description = null)
{
AlternateAssetObject alternateAssetObject = new AlternateAssetObject(uri.ToString(), this.StacAsset.ParentStacObject, title, description);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) by Terradue Srl. All Rights Reserved.
// License under the AGPL, Version 3.0.
// File Name: AlternateStacExtension.cs

using Stac.Extensions.Storage;

namespace Stac.Extensions.Alternate
{
/// <summary>
/// Extension methods for accessing Alternate extension
/// </summary>
public static class AlternateStacExtensionExtensions
{
/// <summary>
/// Initilize a AlternateStacExtension class from a STAC asset
/// </summary>
public static AlternateStacExtension AlternateExtension(this StacAsset stacAsset)
{
return new AlternateStacExtension(stacAsset);
}

/// <summary>
/// Initilize a AlternateStacExtension class from an alternate asset
/// </summary>
public static StorageStacExtension StorageExtension(this AlternateAssetObject alternateAssetObject)
{
return new StorageStacExtension(alternateAssetObject);
}
}
}
4 changes: 2 additions & 2 deletions src/DotNetStac/Extensions/Datacube/DatacubeVariableType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace Stac.Extensions.Datacube
[JsonConverter(typeof(StringEnumConverter))]
public enum DatacubeVariableType
{
data, //a variable indicating some measured value, for example "precipitation", "temperature", etc.
data, // a variable indicating some measured value, for example "precipitation", "temperature", etc.

auxiliary, //a variable that contains coordinate data, but isn't a dimension in cube:dimensions. For example, the values of the datacube might be provided in the projected coordinate reference system, but the datacube could have a variable lon with dimensions (y, x), giving the longitude at each point.
auxiliary, // a variable that contains coordinate data, but isn't a dimension in cube:dimensions. For example, the values of the datacube might be provided in the projected coordinate reference system, but the datacube could have a variable lon with dimensions (y, x), giving the longitude at each point.
}
}
4 changes: 4 additions & 0 deletions src/DotNetStac/Extensions/Eo/EoStacExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ public double? CloudCover
set
{
if (value == null)
{
this.StacPropertiesContainer.RemoveProperty(CloudCoverField);
}
else
{
this.StacPropertiesContainer.SetProperty(CloudCoverField, value);
Expand All @@ -112,7 +114,9 @@ public EoBandObject[] Bands
set
{
if (value == null || value.Count() == 0)
{
this.StacPropertiesContainer.RemoveProperty(BandsField);
}
else
{
this.StacPropertiesContainer.SetProperty(BandsField, value);
Expand Down
2 changes: 1 addition & 1 deletion src/DotNetStac/Extensions/Projection/SRIDReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static IEnumerable<WKTstring> GetSRIDs()
int split = line.IndexOf(';');
if (split > -1)
{
WKTstring wkt = new WKTstring();
WKTstring wkt = default(WKTstring);
wkt.WKID = int.Parse(line.Substring(0, split));
wkt.WKT = line.Substring(split + 1);
yield return wkt;
Expand Down
4 changes: 2 additions & 2 deletions src/DotNetStac/Extensions/Sat/BaselineCalculation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ public static BaselineVector CalculateBaseline(DateTime[] time, SatOrbitStateVec
// double maxError;
double t = time[2].Subtract(time[0]).TotalSeconds;

//double tm = SynchronizeVector(t, groundPoint, interpolMaster, out converged, out maxError);
//double ts = SynchronizeVector(t, groundPoint, interpolSlave, out converged, out maxError);
// double tm = SynchronizeVector(t, groundPoint, interpolMaster, out converged, out maxError);
// double ts = SynchronizeVector(t, groundPoint, interpolSlave, out converged, out maxError);

// Define baseline vector:
double[] b = new double[3]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static class VersionStacExtensionExtensions
/// <summary>
/// Initilize a EoStacExtension class from a STAC item
/// </summary>
/// <param name="stacItem">The STAC item</param>
public static VersionStacExtension VersionExtension(this StacItem stacItem)
{
return new VersionStacExtension(stacItem);
Expand All @@ -23,6 +24,7 @@ public static VersionStacExtension VersionExtension(this StacItem stacItem)
/// <summary>
/// Initilize a EoStacExtension class from a STAC collection
/// </summary>
/// <param name="stacItem"></param>
public static VersionStacExtension VersionExtension(this StacCollection stacItem)
{
return new VersionStacExtension(stacItem);
Expand Down
Loading

0 comments on commit 6b6d074

Please sign in to comment.