Skip to content

Commit 6df6374

Browse files
committed
- Fix LINT issues
1 parent 8881d77 commit 6df6374

File tree

6 files changed

+33
-27
lines changed

6 files changed

+33
-27
lines changed

src/JSONPredicate/Expression.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static (string Path, string Operator, string Value) Parse(string expressi
3232

3333
// Define operators in order of length (longer first) to avoid partial matches
3434
var operators = new[] { "gte", "lte", "not", "eq", "gt", "lt", "in" };
35-
35+
3636
for (int i = 0; i < expr.Length; i++)
3737
{
3838
// Skip if inside quotes
@@ -53,31 +53,31 @@ public static (string Path, string Operator, string Value) Parse(string expressi
5353
}
5454
continue;
5555
}
56-
56+
5757
// Check for operator at this position (not in quotes)
5858
foreach (var op in operators)
5959
{
60-
if (i + op.Length <= expr.Length &&
60+
if (i + op.Length <= expr.Length &&
6161
expr.Substring(i, op.Length).Equals(op, StringComparison.OrdinalIgnoreCase))
6262
{
6363
// Verify it's surrounded by whitespace or string boundaries
6464
bool beforeOk = i == 0 || char.IsWhiteSpace(expr[i - 1]);
6565
bool afterOk = i + op.Length == expr.Length || char.IsWhiteSpace(expr[i + op.Length]);
66-
66+
6767
if (beforeOk && afterOk)
6868
{
6969
var path = expr.Substring(0, i).Trim();
7070
var value = expr.Substring(i + op.Length).Trim();
71-
71+
7272
if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(value))
7373
throw new ArgumentException($"Invalid expression format: {expression}");
74-
74+
7575
return (path, op, value);
7676
}
7777
}
7878
}
7979
}
80-
80+
8181
throw new ArgumentException($"Invalid expression format: {expression}");
8282
}
8383
}

src/JSONPredicate/JsonPath.cs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,39 @@
11
using System.Linq;
2-
using System.Text.Json;
32
using System.Reflection;
3+
using System.Text.Json;
44

55
namespace JSONPredicate
66
{
77
internal static class JsonPath
88
{
99
public static object Evaluate(object obj, string path)
1010
{
11-
if (obj == null) return null;
12-
11+
if (obj == null)
12+
return null;
13+
1314
var properties = path.Split('.');
1415
object current = obj;
15-
16+
1617
foreach (var property in properties)
1718
{
18-
if (current == null) return null;
19-
19+
if (current == null)
20+
return null;
21+
2022
// Check if it's an indexed access: array[0] or list[1]
2123
if (property.Contains("[") && property.EndsWith("]"))
2224
{
2325
var parts = property.Split('[');
2426
var propName = parts[0];
2527
var indexStr = parts[1].TrimEnd(']');
26-
28+
2729
// First get the property
28-
var propInfo = current.GetType().GetProperty(propName,
30+
var propInfo = current.GetType().GetProperty(propName,
2931
BindingFlags.Public | BindingFlags.Instance);
30-
if (propInfo == null) return null;
31-
32+
if (propInfo == null)
33+
return null;
34+
3235
var propValue = propInfo.GetValue(current);
33-
36+
3437
// Then access array/list element if applicable
3538
if (propValue is System.Collections.IList list)
3639
{
@@ -50,14 +53,15 @@ public static object Evaluate(object obj, string path)
5053
}
5154
else
5255
{
53-
var propInfo = current.GetType().GetProperty(property,
56+
var propInfo = current.GetType().GetProperty(property,
5457
BindingFlags.Public | BindingFlags.Instance);
55-
if (propInfo == null) return null;
56-
58+
if (propInfo == null)
59+
return null;
60+
5761
current = propInfo.GetValue(current);
5862
}
5963
}
60-
64+
6165
return current;
6266
}
6367

src/JSONPredicate/JsonPredicate.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections.Concurrent;
33
using System.Collections.Generic;
44
using System.Linq;
5-
using JSONPredicate;
65
using JSONPredicate.Operators;
76

87
namespace JSONPredicate
@@ -26,7 +25,7 @@ static JSONPredicate()
2625
{ Expression.Comparison.EndsWithOperator, (left, right) => EndsWithOperator.Evaluate(left, right)},
2726
{ Expression.Comparison.ContainsOperator, (left, right) => ContainsOperator.Evaluate(left, right)}
2827
};
29-
28+
3029
ComparisonOperators = new ConcurrentDictionary<string, Func<object, object, bool>>(operators);
3130
}
3231

src/JSONPredicate/Operators/ContainsOperator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ internal static class ContainsOperator
44
{
55
public static bool Evaluate(object left, object right)
66
{
7-
if (left == null || right == null) return false;
7+
if (left == null || right == null)
8+
return false;
89
var leftStr = left.ToString();
910
var rightStr = right.ToString();
1011
return leftStr.IndexOf(rightStr, System.StringComparison.OrdinalIgnoreCase) >= 0;

src/JSONPredicate/Operators/EndsWithOperator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ internal static class EndsWithOperator
44
{
55
public static bool Evaluate(object left, object right)
66
{
7-
if (left == null || right == null) return false;
7+
if (left == null || right == null)
8+
return false;
89
var leftStr = left.ToString();
910
var rightStr = right.ToString();
1011
return leftStr.EndsWith(rightStr, System.StringComparison.OrdinalIgnoreCase);

src/JSONPredicate/Operators/StartsWithOperator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ internal static class StartsWithOperator
44
{
55
public static bool Evaluate(object left, object right)
66
{
7-
if (left == null || right == null) return false;
7+
if (left == null || right == null)
8+
return false;
89
var leftStr = left.ToString();
910
var rightStr = right.ToString();
1011
return leftStr.StartsWith(rightStr, System.StringComparison.OrdinalIgnoreCase);

0 commit comments

Comments
 (0)