Skip to content

Commit 9ea006d

Browse files
committed
Quality suggestions from Rider
1 parent 777fe4c commit 9ea006d

File tree

5 files changed

+22
-21
lines changed

5 files changed

+22
-21
lines changed

RDFSharp/Model/Serializers/RDFTurtle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ orderby triple.Subject.ToString(), triple.Predicate.ToString()
15231523
{
15241524
subj = triple.Subject.ToString(),
15251525
pred = triple.Predicate.ToString()
1526-
});
1526+
}).ToList();
15271527
var lastGroupOfTriples = triplesGroupedBySubjectAndPredicate.LastOrDefault();
15281528
#endregion
15291529

RDFSharp/Model/Validation/Abstractions/RDFShapesGraph.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ limitations under the License.
1616

1717
using System.Collections;
1818
using System.Collections.Generic;
19+
using System.Linq;
1920
using System.Threading.Tasks;
2021

2122
namespace RDFSharp.Model
@@ -131,8 +132,7 @@ public RDFGraph ToRDFGraph()
131132
{
132133
RDFGraph result = new RDFGraph();
133134

134-
foreach (RDFShape shape in this)
135-
result = result.UnionWith(shape.ToRDFGraph());
135+
result = this.Aggregate(result, (current, shape) => current.UnionWith(shape.ToRDFGraph()));
136136

137137
result.SetContext(URI);
138138
return result;

RDFSharp/Model/Validation/RDFValidationHelper.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,10 @@ internal static List<RDFPatternMember> GetValueNodesOf(this RDFGraph dataGraph,
106106
//Compute property path on the given focus node
107107
DataTable pathResult = new RDFQueryEngine().ApplyPropertyPath(
108108
isAlternativePath ? propertyShape.AlternativePath : propertyShape.SequencePath, dataGraph);
109-
foreach (DataRow pathResultRow in pathResult.Rows)
110-
{
111-
string prValue = pathResultRow["?END"]?.ToString();
112-
if (!string.IsNullOrEmpty(prValue))
113-
result.Add(RDFQueryUtilities.ParseRDFPatternMember(prValue));
114-
}
109+
result.AddRange(from DataRow pathResultRow
110+
in pathResult.Rows
111+
select pathResultRow["?END"]?.ToString() into prValue where !string.IsNullOrEmpty(prValue)
112+
select RDFQueryUtilities.ParseRDFPatternMember(prValue));
115113

116114
//Recontextualize property path to the initial configuration
117115
if (isAlternativePath)
@@ -152,8 +150,7 @@ internal static List<RDFPatternMember> GetInstancesOfClass(this RDFGraph dataGra
152150
#endregion
153151

154152
//rdf:type
155-
foreach (RDFTriple triple in dataGraph[null, RDFVocabulary.RDF.TYPE, className, null])
156-
result.Add(triple.Subject);
153+
result.AddRange(dataGraph[null, RDFVocabulary.RDF.TYPE, className, null].Select(triple => triple.Subject));
157154

158155
//rdfs:subClassOf
159156
foreach (RDFTriple triple in dataGraph[null, RDFVocabulary.RDFS.SUB_CLASS_OF, className, null])

RDFSharp/Query/Mirella/Algebra/Expressions/RDFComparisonExpression.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ internal override RDFPatternMember ApplyExpression(DataRow row)
151151
{
152152
#region Evaluate Arguments
153153
//Evaluate left argument (Expression VS Variable)
154-
RDFPatternMember leftArgumentPMember = null;
154+
RDFPatternMember leftArgumentPMember;
155155
if (LeftArgument is RDFExpression leftArgumentExpression)
156156
leftArgumentPMember = leftArgumentExpression.ApplyExpression(row);
157157
else

RDFSharp/Query/Mirella/Algebra/Modifiers/RDFGroupByModifier.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,26 +117,29 @@ internal override DataTable ApplyModifier(DataTable table)
117117
private void ConsistencyChecks(DataTable table)
118118
{
119119
//Every partition variable must be found in the working table as a column
120-
IEnumerable<string> unavailablePartitionVariables = PartitionVariables.Where(pv => !table.Columns.Contains(pv.ToString()))
121-
.Select(pv => pv.ToString());
120+
List<string> unavailablePartitionVariables = PartitionVariables.Where(pv => !table.Columns.Contains(pv.ToString()))
121+
.Select(pv => pv.ToString())
122+
.ToList();
122123
if (unavailablePartitionVariables.Any())
123124
throw new RDFQueryException($"Cannot apply GroupBy modifier because the working table does not contain the following columns needed for partitioning: {string.Join(",", unavailablePartitionVariables.Distinct())}");
124125

125126
//Every aggregator variable must be found in the working table as a column
126-
IEnumerable<string> unavailableAggregatorVariables = Aggregators.Where(ag => !table.Columns.Contains(ag.AggregatorVariable.ToString()))
127-
.Select(ag => ag.AggregatorVariable.ToString());
127+
List<string> unavailableAggregatorVariables = Aggregators.Where(ag => !table.Columns.Contains(ag.AggregatorVariable.ToString()))
128+
.Select(ag => ag.AggregatorVariable.ToString())
129+
.ToList();
128130
if (unavailableAggregatorVariables.Any())
129131
throw new RDFQueryException($"Cannot apply GroupBy modifier because the working table does not contain the following columns needed for aggregation: {string.Join(",", unavailableAggregatorVariables.Distinct())}");
130132

131133
//There should NOT be intersection between partition variables (GroupBy) and projection variables (Aggregators)
132-
IEnumerable<string> commonPartitionProjectionVariables = PartitionVariables.Where(pv => Aggregators.Any(ag => (!(ag is RDFPartitionAggregator)) && pv.Equals(ag.ProjectionVariable)))
133-
.Select(pav => pav.ToString());
134+
List<string> commonPartitionProjectionVariables = PartitionVariables.Where(pv => Aggregators.Any(ag => (!(ag is RDFPartitionAggregator)) && pv.Equals(ag.ProjectionVariable)))
135+
.Select(pav => pav.ToString())
136+
.ToList();
134137
if (commonPartitionProjectionVariables.Any())
135138
throw new RDFQueryException($"Cannot apply GroupBy modifier because the following variables have been specified both for partitioning (in GroupBy) and projection (in Aggregator): {string.Join(",", commonPartitionProjectionVariables.Distinct())}");
136139
}
137140

138141
/// <summary>
139-
/// Executes partition algorythm
142+
/// Executes partition algorithm
140143
/// </summary>
141144
private void ExecutePartitionAlgorythm(DataTable table)
142145
{
@@ -170,8 +173,9 @@ private DataTable ExecuteFilterAlgorythm(DataTable resultTable)
170173
{
171174
DataTable filteredTable = resultTable.Clone();
172175
IEnumerator rowsEnum = resultTable.Rows.GetEnumerator();
173-
IEnumerable<RDFComparisonFilter> havingFilters = Aggregators.Where(ag => ag.HavingClause.Item1)
174-
.Select(ag => new RDFComparisonFilter(ag.HavingClause.Item2, ag.ProjectionVariable, ag.HavingClause.Item3));
176+
List<RDFComparisonFilter> havingFilters = Aggregators.Where(ag => ag.HavingClause.Item1)
177+
.Select(ag => new RDFComparisonFilter(ag.HavingClause.Item2, ag.ProjectionVariable, ag.HavingClause.Item3))
178+
.ToList();
175179
#region ExecuteFilters
176180
while (rowsEnum.MoveNext())
177181
{

0 commit comments

Comments
 (0)