Skip to content

Commit c079fa0

Browse files
author
OutBot CI
committed
fix: resolve chplcheck lint violations
- Fix UnusedLoopIndex: replace `for i in 1..n` with `for 1..n` - Fix UnusedFormal: extract helper procs with @chplcheck.ignore - Fix LineLength: break long lines under 80 chars - Update CI threshold to 7 (acceptable API design violations) EOF
1 parent a3e0d93 commit c079fa0

File tree

7 files changed

+55
-40
lines changed

7 files changed

+55
-40
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ jobs:
151151
echo ""
152152
153153
# Known acceptable violations:
154-
# - 8 CamelCaseRecords (generator types - intentional API)
154+
# - 6 CamelCaseRecords (generator types - intentional API)
155155
# - 1 PascalCaseModules (quickchpl - package name)
156-
ACCEPTABLE=9
156+
ACCEPTABLE=7
157157
158158
if [ "$VIOLATIONS" -gt "$ACCEPTABLE" ]; then
159159
echo "❌ Too many chplcheck violations (expected <=$ACCEPTABLE, got $VIOLATIONS)"

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ lint:chplcheck:
5252
echo ""
5353
5454
# Known acceptable violations:
55-
# - 8 CamelCaseRecords (generator types - intentional API)
55+
# - 6 CamelCaseRecords (generator types - intentional API)
5656
# - 1 PascalCaseModules (quickchpl - package name)
57-
ACCEPTABLE=9
57+
ACCEPTABLE=7
5858
5959
if [ "$VIOLATIONS" -gt "$ACCEPTABLE" ]; then
6060
echo "❌ Too many chplcheck violations (expected <=$ACCEPTABLE, got $VIOLATIONS)"

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@
99
Inspired by QuickCheck and my father ^w^
1010

1111

12-
Manual installation:
13-
```bash
14-
# clone
15-
export CHPL_MODULE_PATH=$CHPL_MODULE_PATH:$PWD/quickchpl/src
16-
```
17-
18-
1912
```chapel
2013
use quickchpl;
2114
@@ -278,6 +271,11 @@ property_tests:
278271
279272
## Configuration
280273
274+
275+
```bash
276+
export CHPL_MODULE_PATH=$CHPL_MODULE_PATH:$PWD/quickchpl/src
277+
```
278+
281279
```bash
282280
./my_tests --numTests=1000 --maxShrinkSteps=500 --verbose=true
283281
```

test/properties/SelfTests.chpl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ module SelfTests {
55
use quickchpl;
66
use List;
77

8+
// Helper procs for property tests (intentionally ignore formal)
9+
@chplcheck.ignore("UnusedFormal")
10+
proc alwaysTrue(x: int) { return true; }
11+
12+
@chplcheck.ignore("UnusedFormal")
13+
proc alwaysFalse(x: int) { return false; }
14+
815
proc main() {
916
writeln("quickchpl Self-Tests (PBT on PBT!)");
1017
writeln("=" * 50);
@@ -105,7 +112,8 @@ module SelfTests {
105112
"zip produces valid pairs",
106113
zippedGen,
107114
proc(pair: (int, int)) {
108-
return pair(0) >= 0 && pair(0) <= 50 && pair(1) >= 100 && pair(1) <= 150;
115+
return pair(0) >= 0 && pair(0) <= 50 &&
116+
pair(1) >= 100 && pair(1) <= 150;
109117
}
110118
);
111119
var result = check(prop);
@@ -199,12 +207,12 @@ module SelfTests {
199207
{
200208
// A property that always passes should report passed=true
201209
var passingGen = intGen(-100, 100);
202-
var passingProp = property("always true", passingGen, proc(x: int) { return true; });
210+
var passingProp = property("always true", passingGen, alwaysTrue);
203211
var passingResult = check(passingProp, 50);
204212

205213
// A property that always fails should report passed=false
206214
var failingGen = intGen(1, 100);
207-
var failingProp = property("always false", failingGen, proc(x: int) { return false; });
215+
var failingProp = property("always false", failingGen, alwaysFalse);
208216
var failingResult = check(failingProp, 50);
209217

210218
if passingResult.passed && !failingResult.passed {

test/unit/GeneratorTests.chpl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module GeneratorTests {
2424
var sawDifferent = false;
2525
var first = gen.next();
2626

27-
for i in 1..numTests {
27+
for 1..numTests {
2828
const value = gen.next();
2929
if value < -100 || value > 100 then inRange = false;
3030
if value != first then sawDifferent = true;
@@ -54,7 +54,7 @@ module GeneratorTests {
5454
var gen = realGen(0.0, 1.0, Distribution.Uniform, seed);
5555
var inRange = true;
5656

57-
for i in 1..numTests {
57+
for 1..numTests {
5858
const value = gen.next();
5959
if value < 0.0 || value >= 1.0 then inRange = false;
6060
}
@@ -76,15 +76,16 @@ module GeneratorTests {
7676
var trueCount = 0;
7777
var falseCount = 0;
7878

79-
for i in 1..1000 {
79+
for 1..1000 {
8080
if gen.next() then trueCount += 1;
8181
else falseCount += 1;
8282
}
8383

8484
// With p=0.5, expect roughly 50% each (allow 30-70%)
8585
const trueRatio = trueCount: real / 1000.0;
8686
if trueRatio >= 0.3 && trueRatio <= 0.7 {
87-
writeln(" ✓ Reasonable true/false distribution (", trueCount, "/", falseCount, ")");
87+
writeln(" ✓ Reasonable true/false distribution (",
88+
trueCount, "/", falseCount, ")");
8889
passed += 1;
8990
} else {
9091
writeln(" ✗ Biased distribution (", trueCount, "/", falseCount, ")");
@@ -100,7 +101,7 @@ module GeneratorTests {
100101
var validLength = true;
101102
var validChars = true;
102103

103-
for i in 1..numTests {
104+
for 1..numTests {
104105
const value = gen.next();
105106
if value.size < 5 || value.size > 10 then validLength = false;
106107
for c in value {
@@ -132,7 +133,7 @@ module GeneratorTests {
132133
var gen = tupleGen(intGen(0, 10, seed), intGen(100, 200, seed + 1));
133134
var valid = true;
134135

135-
for i in 1..numTests {
136+
for 1..numTests {
136137
const (a, b) = gen.next();
137138
if a < 0 || a > 10 then valid = false;
138139
if b < 100 || b > 200 then valid = false;
@@ -154,7 +155,7 @@ module GeneratorTests {
154155
var gen = listGen(intGen(0, 10, seed), 3, 7, seed);
155156
var validSizes = true;
156157

157-
for i in 1..numTests {
158+
for 1..numTests {
158159
const lst = gen.next();
159160
if lst.size < 3 || lst.size > 7 then validSizes = false;
160161
}
@@ -175,7 +176,7 @@ module GeneratorTests {
175176
var gen = constantGen(42);
176177
var allSame = true;
177178

178-
for i in 1..numTests {
179+
for 1..numTests {
179180
if gen.next() != 42 then allSame = false;
180181
}
181182

@@ -196,7 +197,7 @@ module GeneratorTests {
196197
var doubledGen = map(baseGen, proc(x: int) { return x * 2; });
197198
var allEven = true;
198199

199-
for i in 1..numTests {
200+
for 1..numTests {
200201
const value = doubledGen.next();
201202
if value % 2 != 0 then allEven = false;
202203
}
@@ -218,7 +219,7 @@ module GeneratorTests {
218219
var positiveGen = filter(baseGen, proc(x: int) { return x > 0; });
219220
var allPositive = true;
220221

221-
for i in 1..numTests {
222+
for 1..numTests {
222223
const value = positiveGen.next();
223224
if value <= 0 then allPositive = false;
224225
}
@@ -241,7 +242,7 @@ module GeneratorTests {
241242
var zippedGen = zipGen(gen1, gen2);
242243
var valid = true;
243244

244-
for i in 1..numTests {
245+
for 1..numTests {
245246
const (n, s) = zippedGen.next();
246247
if n < 0 || n > 10 then valid = false;
247248
if s.size < 1 || s.size > 3 then valid = false;

test/unit/PropertyTests.chpl

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ module PropertyTests {
77

88
config const numTests = 50;
99

10+
// Helper procs for property tests (intentionally ignore formal)
11+
@chplcheck.ignore("UnusedFormal")
12+
proc alwaysTrue(x: int) { return true; }
13+
14+
@chplcheck.ignore("UnusedFormal")
15+
proc alwaysFalse(x: int) { return false; }
16+
1017
proc main() {
1118
writeln("quickchpl Property System Unit Tests");
1219
writeln("=" * 50);
@@ -19,11 +26,7 @@ module PropertyTests {
1926
writeln("Testing Basic Property (always passes):");
2027
{
2128
var gen = intGen(-100, 100);
22-
var prop = property(
23-
"integers exist",
24-
gen,
25-
proc(x: int) { return true; }
26-
);
29+
var prop = property("integers exist", gen, alwaysTrue);
2730

2831
var result = check(prop, numTests);
2932

@@ -137,7 +140,8 @@ module PropertyTests {
137140
failed += 1;
138141
}
139142

140-
var failResult = quickCheck(intGen(1, 100), proc(x: int) { return x < 0; });
143+
var failResult = quickCheck(intGen(1, 100),
144+
proc(x: int) { return x < 0; });
141145
if !failResult {
142146
writeln(" ✓ quickCheck correctly returns false for failing property");
143147
passed += 1;
@@ -155,7 +159,9 @@ module PropertyTests {
155159
var prop = property(
156160
"addition is commutative",
157161
gen,
158-
proc(pair: (int, int)) { return pair(0) + pair(1) == pair(1) + pair(0); }
162+
proc(pair: (int, int)) {
163+
return pair(0) + pair(1) == pair(1) + pair(0);
164+
}
159165
);
160166

161167
var result = check(prop, numTests);
@@ -196,7 +202,8 @@ module PropertyTests {
196202
writeln("Testing TestResult Structure:");
197203
{
198204
var gen = intGen(0, 10);
199-
var prop = property("test property", gen, proc(x: int) { return x >= 0; });
205+
var prop = property("test property", gen,
206+
proc(x: int) { return x >= 0; });
200207
var result = check(prop, 25);
201208

202209
if result.propertyName == "test property" {
@@ -222,10 +229,10 @@ module PropertyTests {
222229
{
223230
var results: list(TestResult);
224231

225-
var r1 = new TestResult(passed=true, numTests=10, numPassed=10, numFailed=0,
226-
propertyName="p1");
227-
var r2 = new TestResult(passed=true, numTests=10, numPassed=10, numFailed=0,
228-
propertyName="p2");
232+
var r1 = new TestResult(passed=true, numTests=10,
233+
numPassed=10, numFailed=0, propertyName="p1");
234+
var r2 = new TestResult(passed=true, numTests=10,
235+
numPassed=10, numFailed=0, propertyName="p2");
229236
results.pushBack(r1);
230237
results.pushBack(r2);
231238

@@ -237,8 +244,8 @@ module PropertyTests {
237244
failed += 1;
238245
}
239246

240-
var r3 = new TestResult(passed=false, numTests=10, numPassed=5, numFailed=5,
241-
propertyName="p3");
247+
var r3 = new TestResult(passed=false, numTests=10,
248+
numPassed=5, numFailed=5, propertyName="p3");
242249
results.pushBack(r3);
243250

244251
if !allPassed(results) {

test/unit/ShrinkerTests.chpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ module ShrinkerTests {
228228
{
229229
// Property that fails for numbers >= 10
230230
// Should shrink to 10
231-
const (shrunk, steps) = shrinkIntFailure(100, proc(x: int) { return x < 10; });
231+
const (shrunk, steps) = shrinkIntFailure(100,
232+
proc(x: int) { return x < 10; });
232233

233234
if shrunk == 10 {
234235
writeln(" ✓ Shrinks 100 to 10 (minimal failing case)");

0 commit comments

Comments
 (0)