blib/lib/MarpaX/Hoonlint/Policy/Test/Whitespace.pm

filter: Statementstmt 43.3% 1156 / 2664 Branchbran 37.9% 321 / 846 Conditioncond 29.7% 55 / 185 MC/DCmcdc 13.2% 14 / 106 Subroutinesub 57.9% 51 / 88 Podpod 0.0% 0 / 81 totaltotal 40.2% 1597 / 3970 CC 508 SCAR 48.1
CC
508
Cov
41%
checkGapComments
650.5
checkBackdented
326.9
checkRunning
205.1
CRAP 122.4
↑ Summary blib/lib/MarpaX/Hoonlint/yahc.pm »
1 # Hoon whitespace "test" policy
2  
3 package MarpaX::Hoonlint::Policy::Test::Whitespace;
4  
5 6 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶no warnings 'recursion';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # use Carp::Always;
11 6 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 6 ▶use English qw( -no_match_vars );
Subroutine BEGIN: called CC=1 SCAR=0.0
13 6 ▶use Scalar::Util qw(looks_like_number weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 # say STDERR join " ", __FILE__, __LINE__, "hi";
16  
17 6 my %reanchorings = ();
18  
19 6 my $reanchorings = \<<'EOS';
20 bardot:
21 kettis # fixes 6, breaks 0
22 cenlus # fixes 4, breaks 0
23 luslus # fixes 3, breaks 2
24 cenhep # fixes 1, breaks 0
25 barhep:
26 # 1 ^=
27 # 1 =.
28 kettis # fixes 1, breaks 0
29 tisdot # fixes 1, breaks 0
30 # bartar
31 bartar:
32 # 1 ++
33 # luslus # fixes 1, breaks 14
34 # bartis
35 bartis:
36 # 2 :-
37 # 2 %+
38 # 1 %-
39 # 1 ++
40 colhep # fixes 2, breaks 0
41 # tallCenlus # fixes 2, breaks 6
42 # tallCenhep # fixes 1, breaks 3
43 # luslus # fixes 1, breaks 24
44 # buctis
45 buctis:
46 # tallBuccol # fixes 1, breaks 2
47 # cendot
48 cendot:
49 # 4 |=
50 # 3 =<
51 # 1 =-
52 # 1 %-
53 bartis # fixes 7, breaks 0
54 # tallTisgal # fixes 1, breaks 2
55 # tallTishep # fixes 0, breaks 1
56 cenhep
57 cenhep:
58 # 6 %-
59 # 4 =+
60 # 1 =<
61 # 1 :-
62 cenhep # fixes 6, breaks 1
63 tislus # fixes 4, breaks 2
64 tisgal # fixes 1, breaks 0
65 colhep # fixes 1, breaks 0
66 # cenket
67 cenket:
68 # 1 =.
69 # tallCendot # fixes 0, breaks 0
70 cenlus:
71 cenhep # fixes 8, breaks 0
72 tislus # fixes 11, breaks 2
73 colcab:
74 colcab # fixes 13, breaks 0
75 cenhep # fixes 12, breaks 0
76 cenlus # fixes 6, breaks 0
77 # 'tallColhep' # fixes 1, breaks 2
78 colhep:
79 # 'tallColhep' # fixes 2, breaks 4
80 cenlus # fixes 3, breaks 0
81 colcab # fixes 3, breaks 0
82 # 'tallColsig' # fixes 0, breaks 5
83 dottis:
84 # 1 ?.
85 kethep:
86 barhep # Needed for examples to work
87 bartis
88 cenhep
89 colhep # fixes 3, breaks 2
90 tistar
91 barsig
92 ketsig
93 tisfas
94 kethep # fixes 4, breaks 0
95 tishep # partially fixes one
96 tisgal # partially fixes one
97 tisdot # fixes 1, breaks 0
98 # 'tallBarket' # fixes 3, breaks 9
99 siglus # fixes 1, breaks 0
100 zapgar # fixes 1, breaks 0
101 cenlus # fixes 3, breaks 0
102 bardot # fixes 1, breaks 0
103 # luslus # breaks tic-tac-toe, line 55
104 # =+ ^= [...] ^- occurs a lot, and the reanchoring
105 # seems to want to be at the KETTIS, not the TISLUS.
106 # But where not followed by KETTIS, reanchoring
107 # at TISLUS seems to be indicated in a lot of places.
108 # This accounts for a lot of aberrations.
109 kettis
110 # 'tallTislus' # fixes 30, breaks 76
111 ketlus:
112 barhep # Needed for examples to work
113 bartis # fixes 97, breaks 0
114 tisgal # fixes 8, breaks 0
115 bardot # fixes 8, breaks 0
116 bartar # fixes 4, breaks 0
117 cenhep # fixes 2, breaks 0
118 # ketsig
119 ketsig:
120 # 1 %+
121 cenlus # fixes 1, breaks 0
122 kettis:
123 # tallTislus # breaks 109, fixes 24
124 ketwut:
125 luslus
126 buccab
127 sigcab:
128 # 1 |=
129 bartis # fixes 1, breaks 0
130 sigfas:
131 luslus # fixes 44, breaks 4
132 # siglus
133 siglus:
134 # 25 %+
135 # 3 ++
136 # 2 |=
137 # 1 =+
138 # 1 |.
139 cenlus # fixes 26, breaks 0
140 # luslus # fixes 1, breaks 1
141 bartis # fixes 1, breaks 0
142 # tislus # fixes 0, breaks 0
143 bardot # fixes 1, breaks 0
144 # tisbar
145 tisbar:
146 # 1 |=
147 # 1 $_
148 bartis # fixes 1, breaks 0
149 buccab # fixes 1, breaks 0
150 # tiscom
151 tiscom:
152 # 1 =,
153 tiscom # fixes 1, breaks 0
154 # tisdot
155 tisdot:
156 # 1 =+
157 tislus # fixes 1, breaks 0
158 tisgal:
159 bartis # fixes 20, breaks 0
160 tisgal # fixes 14, breaks 0
161 cenhep # fixes 7, breaks 0
162 ketlus # fixes 4, breaks 0
163 tisgar # fixes 2, breaks 0
164 cenlus # fixes 1, breaks 1
165 # tisgar
166 tisgar:
167 # 3 %+
168 # 2 ++
169 # 2 =+
170 # 1 =>
171 # 1 =-
172 cenlus # fixes 1, breaks 0
173 # luslus # fixes 0, breaks 1
174 # tislus # fixes 0, breaks 1
175 tisgar # fixes 1, breaks 0
176 # tishep # fixes 0, breaks 1
177 # tislus
178 tislus:
179 wutcol:
180 barhep # fixes 6, breaks 0
181 wutcol # fixes 3, breaks 0
182 # tallTisdot # fixes 0, breaks 8
183 # tallTislus # fixes 0, breaks 1
184 cenhep # fixes 1, breaks 0
185 # wutdot
186 wutdot:
187 # 3 |-
188 # 1 =.
189 # 1 ?.
190 barhep # fixes 5, breaks 0
191 # tallTisdot # fixes 1, breaks 3
192 # tallWutdot # fixes 0, breaks 0
193 # wutgal
194 wutgal:
195 # 1 |-
196 barhep # fixes 1, breaks 0
197 # wutgar
198 wutgar:
199 # 2 ~|
200 sigbar # fixes 2, breaks 0
201 wutsig:
202 wutsig # fixes 3, breaks 0
203 tislus # fixes 2, break 1
204 # tallBarhep # fixes 3, breaks 5
205 zapcol:
206 luslus # fixes 8, breaks 1
207 # zapdot
208 zapdot:
209 # 6 ++
210 luslus # fixes 6, breaks 0
211 zapgar:
212 cenhep # fixes 89, breaks 0
213 EOS
214  
215 {
216  
217 # special cases for grammar names
218 6 my %grammarNames = (
219 luslus => 'LuslusCell',
220 lustis => 'LustisCell',
221 lushep => 'LushepCell',
222 );
223  
224 6 my $currentSource;
225  
226 6 ITEM: for my $itemLine ( split "\n", ${$reanchorings} ) {
227 1158 my $rawItemLine = $itemLine;
228 1158 $itemLine =~ s/\s*[#].*$//; # remove comments and preceding whitespace
229 1158 $itemLine =~ s/^\s*//; # remove leading whitespace
230 1158 $itemLine =~ s/\s*$//; # remove trailing whitespace
231 1158 ▶ next ITEM unless $itemLine;
Branch: 1 branch
BranchTrueFalseTotal
unless $itemLine 510 648 1158
232  
233 648 ▶ if (my ($source) = $itemLine =~ m/^(.*) *:$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($source) = $itemLine =~ /^(.*) *:$/) 204 444 648
234 204 $currentSource = $source;
235 204 next ITEM;
236 }
237  
238 444 ▶ die qq{Error in inline reanchorings: No source rune\n}
Branch: 1 branch
BranchTrueFalseTotal
unless $currentSource 0 444 444
239 . qq{ Problem with line: $rawItemLine\n}
240 if not $currentSource;
241  
242 444 chomp $itemLine;
243 444 my $target = $itemLine;
244  
245 444 my $grammarName = $grammarNames{$target};
246 444 ▶ if (not defined $grammarName) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $grammarName) 414 30 444
247 414 $grammarName = 'tall' . ucfirst $target;
248 }
249  
250 444 $reanchorings{$currentSource}{$grammarName} = 1;
251  
252 }
253 }
254  
255 # die Data::Dumper::Dumper(\%reanchorings);
256  
257 # TODO: delete indents in favor of tree traversal
258  
259 6 my $gapCommentDSL = <<'END_OF_DSL';
260 :start ::= gapComments
261 gapComments ::= OptExceptions Body
262 gapComments ::= OptExceptions
263 Body ::= InterPart PrePart
264 Body ::= InterPart
265 Body ::= PrePart
266 InterPart ::= InterComponent
267 InterPart ::= InterruptedInterComponents
268 InterPart ::= InterruptedInterComponents InterComponent
269  
270 InterruptedInterComponents ::= InterruptedInterComponent+
271 InterruptedInterComponent ::= InterComponent Exceptions
272 InterComponent ::= Staircases
273 InterComponent ::= Staircases InterComments
274 InterComponent ::= InterComments
275  
276 InterComments ::= InterComment+
277  
278 Staircases ::= Staircase+
279 Staircase ::= UpperRisers Tread LowerRisers
280 UpperRisers ::= UpperRiser+
281 LowerRisers ::= LowerRiser+
282  
283 PrePart ::= ProperPreComponent OptPreComponents
284 ProperPreComponent ::= PreComment
285 OptPreComponents ::= PreComponent*
286 PreComponent ::= ProperPreComponent
287 PreComponent ::= Exception
288  
289 OptExceptions ::= Exception*
290 Exceptions ::= Exception+
291 Exception ::= MetaComment
292 Exception ::= BadComment
293 Exception ::= BlankLine
294  
295 unicorn ~ [^\d\D]
296 BadComment ~ unicorn
297 BlankLine ~ unicorn
298 InterComment ~ unicorn
299 LowerRiser ~ unicorn
300 MetaComment ~ unicorn
301 PreComment ~ unicorn
302 Tread ~ unicorn
303 UpperRiser ~ unicorn
304  
305 END_OF_DSL
306  
307 # Format line and 0-based column as string
308 204 ▶sub describeLC {
Subroutine describeLC: called CC=1 SCAR=0.0
Pod undocumented
309 204 my ( $line, $column ) = @_;
310 204 return '@' . $line . ':' . ( $column + 1 );
311 }
312  
313 6 ▶sub describeMisindent {
Subroutine describeMisindent: called CC=3 SCAR=16.0
Pod undocumented
314 6 my ($difference) = @_;
315 6 ▶ if ( $difference > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($difference > 0) 6 0 6
316 6 return "overindented by $difference";
317 }
318 0 ▶ if ( $difference < 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($difference < 0) 0 0 0
319 0 return "underindented by " . ( -$difference );
320 }
321 0 return "correctly indented";
322 }
323  
324 6 ▶sub describeMisindent2 {
Subroutine describeMisindent2: called CC=2 SCAR=7.1
Pod undocumented
325 6 my ( $got, $sought ) = @_;
326 6 ▶ $DB::single = 1 if not defined $sought;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sought 0 6 6
327 6 return describeMisindent( $got - $sought );
328 }
329  
330 48 ▶sub setInheritedAttribute {
Subroutine setInheritedAttribute: called CC=1 SCAR=0.0
Pod undocumented
331 48 my ( $policy, $node, $attribute, $value ) = @_;
332 48 my $nodeIX = $node->{IX};
333 48 $policy->{perNode}->{$nodeIX}->{$attribute} = $value;
334 }
335  
336 531 ▶sub getInheritedAttribute {
Subroutine getInheritedAttribute: called CC=3 SCAR=11.0
Pod undocumented
337 531 my ( $policy, $node, $attribute ) = @_;
338 531 my $nodeIX = $node->{IX};
339 531 my $value = $policy->{perNode}->{$nodeIX}->{$attribute};
340 531 ▶ return $value if defined $value;
Branch: 1 branch
BranchTrueFalseTotal
if defined $value 147 384 531
341 384 $node = $node->{PARENT};
342 384 ▶ die qq{Ascended tree but did not find attributee "$attribute"} if not $node;
Branch: 1 branch
BranchTrueFalseTotal
unless $node 0 384 384
343 384 $value = $policy->getInheritedAttribute($node, $attribute);
344 384 return $value;
345 }
346  
347 12 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod undocumented
348 12 my ( $class, $lintInstance ) = @_;
349 12 my $policy = {};
350 12 $policy->{lint} = $lintInstance;
351 12 my %chainable = ();
352 12 for my $key (keys %{ $lintInstance->{backdentedRule} }, keys %{ $lintInstance->{tallNoteRule} }) {
353 888 $chainable{$key} = 1;
354 }
355 12 $policy->{chainable} = \%chainable;
356 12 Scalar::Util::weaken( $policy->{lint} );
357 $policy->{gapGrammar} =
358 12 Marpa::R2::Scanless::G->new( { source => \$gapCommentDSL } );
359 12 return bless $policy, $class;
360 }
361  
362 # Return Perl true is node is chainable
363 375 ▶sub chainable {
Subroutine chainable: called CC=2 SCAR=6.9
Pod undocumented
364 375 my ( $policy, $node ) = @_;
365 375 my $chainable = $policy->{chainable};
366 375 my $instance = $policy->{lint};
367 375 my $grammar = $instance->{grammar};
368 375 my $ruleID = $node->{ruleID};
369 375 ▶ return if not $ruleID;
Branch: 1 branch
BranchTrueFalseTotal
unless $ruleID 0 375 375
370 375 my ($lhs) = $grammar->rule_expand( $node->{ruleID} );
371 375 my $lhsName = $grammar->symbol_name($lhs);
372 # say STDERR join ' ', __FILE__, __LINE__, $lhsName, ($chainable->{$lhsName} // 'na');
373 375 return $chainable->{$lhsName};
374 }
375  
376 # Return the node tag for the subpolicy field.
377 # Archetypally, this is the 6-character form of
378 # rune for the node's brick.
379 399 ▶sub runeName {
Subroutine runeName: called CC=6 SCAR=21.5
Pod undocumented
380 399 my ( $policy, $node ) = @_;
381 399 my $instance = $policy->{lint};
382 399 my $name = $instance->forceBrickName($node);
383 399 ▶ if ( my ($tag) = $name =~ /^(Lus[b-z][aeiou][b-z])Cell$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($tag) = $name =~ /^(Lus[b-z][aeiou][b-z])Cell$/) 69 330 399
384 69 return lc $tag;
385 }
386 330 ▶ if ( my ($tag) = $name =~ /^optFord([B-Z][aeoiu][b-z][b-z][aeiou][b-z])$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($tag) = $name =~ /^optFord([B-Z][aeoiu][b-z][b-z][aeiou][b-z])$/) 0 330 330
387 0 return lc $tag;
388 }
389 330 ▶ if ( my ($tag) = $name =~ /^ford([B-Z][aeoiu][b-z][b-z][aeiou][b-z])$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($tag) = $name =~ /^ford([B-Z][aeoiu][b-z][b-z][aeiou][b-z])$/) 0 330 330
390 0 return lc $tag;
391 }
392 330 ▶ if ( my ($tag) = $name =~ /^tall([B-Z][aeoiu][b-z][b-z][aeiou][b-z])$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($tag) = $name =~ /^tall([B-Z][aeoiu][b-z][b-z][aeiou][b-z])$/) 330 0 330
393 330 return lc $tag;
394 }
395 0 ▶ if ( my ($tag) = $name =~ /^tall([B-Z][aeoiu][b-z][b-z][aeiou][b-z])Mold$/ )
Branch: 1 branch
BranchTrueFalseTotal
if (my($tag) = $name =~ /^tall([B-Z][aeoiu][b-z][b-z][aeiou][b-z])Mold$/) 0 0 0
396 {
397 0 return lc $tag;
398 }
399 0 return lc $name;
400 }
401  
402 0 ▶sub nodeSubpolicy {
Subroutine nodeSubpolicy: not called CC=1 SCAR=6.9
Pod undocumented
403 0 my ( $policy, $node ) = @_;
404 0 return $policy->runeName($node);
405 }
406  
407 # return standard anchor "detail" line
408 12 ▶sub anchorDetailsBasic {
Subroutine anchorDetailsBasic: called CC=2 SCAR=7.0
Pod undocumented
409 12 my ( $policy, $rune, $anchorColumn ) = @_;
410 12 my $instance = $policy->{lint};
411 12 my ( $runeLine, $runeColumn ) = $instance->nodeLC($rune);
412 12 my $anchorLiteral = $instance->literalLine($runeLine);
413 12 my $anchorLexeme = substr $anchorLiteral, $anchorColumn;
414 12 $anchorLexeme =~ s/[\s].*\z//xms;
415 12 ▶ my $typeVerb = ( $anchorColumn == $runeColumn ) ? "anchor" : "re-anchor";
Branch: 1 branch
BranchTrueFalseTotal
$anchorColumn == $runeColumn ? : 12 0 12
416 12 return [qq{$typeVerb column is }
417 . describeLC( $runeLine, $anchorColumn )
418 . qq{ "$anchorLexeme"} ];
419 }
420  
421 153 ▶sub anchorDetails {
Subroutine anchorDetails: called CC=2 SCAR=6.9
Pod undocumented
422 153 my ( $policy, $rune, $anchorData ) = @_;
423 153 my @desc = ();
424 153 my $instance = $policy->{lint};
425 153 my $brick = $anchorData->{brick};
426  
427 153 my ( $runeLine, $runeColumn ) = $instance->nodeLC($rune);
428 153 my ( $brickLine, $brickColumn ) = $instance->nodeLC($brick);
429 153 my $anchorColumn = $anchorData->{column};
430 153 my $offset = $anchorData->{offset};
431 153 my $runeLineLiteral = $instance->literalLine($runeLine);
432 153 $runeLineLiteral =~ s/\n\z//xms;
433  
434 153 ▶ if ( $anchorColumn == $runeColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($anchorColumn == $runeColumn) 138 15 153
435 138 my $brickLiteral = $instance->literalLine($runeLine);
436 138 my $brickLexeme = substr $brickLiteral, $brickColumn;
437 138 $brickLexeme =~ s/[\s].*\z//xms;
438 138 return [sprintf 'anchor column is "%s" %s',
439 $brickLexeme,
440 describeLC( $runeLine, $anchorColumn )
441 ];
442 }
443 15 push @desc,
444 sprintf
445 're-anchor column (%d) = anchor brick column (%d) + re-anchor offset (%d)',
446 $anchorColumn + 1, $brickColumn + 1, $offset;
447 15 my $maxNumWidth = $instance->maxNumWidth();
448 15 my $pointersPrefix = ( ' ' x $maxNumWidth );
449 15 my $prefixLength = length $pointersPrefix;
450 15 push @desc, sprintf '%s%s', $pointersPrefix, $runeLineLiteral;
451 15 my $pointerLine = ( ' ' x ( $runeColumn + $prefixLength ) ) . q{^};
452 15 substr( $pointerLine, ( $brickColumn + $prefixLength ), 1 ) = q{^};
453 15 substr( $pointerLine, ( $anchorColumn + $prefixLength ), 1 ) = q{!};
454 15 push @desc, $pointerLine;
455 15 return \@desc;
456 }
457  
458 # first brick node in $node's line,
459 # by inclusion list.
460 # $node if there is no prior included brick node
461 141 ▶sub reanchorInc {
Subroutine reanchorInc: called CC=9 SCAR=22.0
Pod undocumented
462 141 my ( $policy, $node, $inclusions ) = @_;
463 141 my $instance = $policy->{lint};
464  
465 141 my ($currentLine) = $instance->nodeLC($node);
466 141 my $thisNode = $node;
467 141 my $firstBrickNode = $node;
468 141 my @nodes = ();
469  
470 # Accumulate a list of the nodes on the same line as
471 # the argument node
472 141 ▶ NODE: while ($thisNode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($thisNode) 669 15 684
473 669 my ($thisLine) = $instance->nodeLC($thisNode);
474 669 ▶ last NODE if $thisLine != $currentLine;
Branch: 1 branch
BranchTrueFalseTotal
if $thisLine != $currentLine 126 543 669
475 543 push @nodes, $thisNode;
476 543 $thisNode = $thisNode->{PARENT};
477 }
478 141 my $topNodeIX;
479 141 my $brick = $node;
480 141 my $reanchorOffset = 0;
481 SET_DATA: {
482 141 ▶ PICK_NODE: for ( my $nodeIX = $#nodes ; $nodeIX >= 0 ; $nodeIX-- ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nodeIX >= 0) 498 69 567
483 498 my $thisNode = $nodes[$nodeIX];
484 498 my $brickName = $instance->brickName($thisNode);
485 498 ▶ if ( defined $brickName and $inclusions->{$brickName} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $brickName and $inclusions->{$brickName}) 72 426 498
Condition100%3/3
defined $brickName and $inclusions->{$brickName}
!ll&&!rl&&r
3458172
MC/DC100%2/2
defined $brickName and $inclusions->{$brickName}
defined $brickName $inclusions->{$brickName}
Truth table100%3/3
A and B
A= defined $brickNameB= $inclusions->{$brickName}
ABresult
0X0
100
111
486 72 $topNodeIX = $nodeIX;
487 72 last PICK_NODE;
488 }
489 }
490 141 ▶ last SET_DATA if not defined $topNodeIX;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $topNodeIX 69 72 141
491 72 ▶ for (
Branch: 1 branch
BranchTrueFalseTotal
if ($nodeIX <= $topNodeIX) 45 72 117
492 my $nodeIX = 1 ; # do not include first node
493 $nodeIX <= $topNodeIX ; $nodeIX++
494 )
495 {
496 45 my $thisNode = $nodes[$nodeIX];
497 45 my $nodeID = $thisNode->{IX};
498 my $thisReanchorOffset =
499 45 ▶ $policy->{perNode}->{$nodeID}->{reanchorOffset} // 0;
Condition50%1/2
$policy->{"perNode"}{$nodeID}{"reanchorOffset"} // 0
l!l
045
MC/DC0%0/1
$policy->{"perNode"}{$nodeID}{"reanchorOffset"} // 0
$policy->{"perNode"}{$nodeID}{"reanchorOffset"}
Truth table50%1/2
A
A= $policy->{"perNode"}{$nodeID}{"reanchorOffset"}
Aresult
11
00
500 45 $reanchorOffset += $thisReanchorOffset;
501 }
502 72 $brick = $nodes[$topNodeIX];
503 }
504 141 my ( $brickLine, $brickColumn ) = $instance->nodeLC($brick);
505 141 my $column = $brickColumn + $reanchorOffset;
506 141 my %results = (
507 brick => $brick,
508 offset => $reanchorOffset,
509 column => $column,
510 line => $brickLine
511 );
512 141 return $column, \%results;
513 }
514  
515 # A "gapSeq" is an ordered subset of a node's children.
516 # It consists of the first child, followed by zero or more
517 # pairs of nodes, where each pair is a gap and it post-gap
518 # symbol. It is assumed that the first child is not a gap,
519 # and no post-gap child is a gap. The sequence will always
520 # be of odd length.
521 #
522 # Intuitively, this is usually the subset of the children with
523 # information useful for parsing.
524 39 ▶sub gapSeq {
Subroutine gapSeq: called CC=4 SCAR=13.9
Pod undocumented
525 39 my ( $policy, $node ) = @_;
526 39 my $instance = $policy->{lint};
527 39 my $symbolReverseDB = $instance->{symbolReverseDB};
528 39 my $children = $node->{children};
529 39 my $child = $children->[0];
530 39 my @gapSeq = ($child);
531  
532 39 my $childIX = 1;
533 39 ▶ CHILD: while ( $childIX < $#$children ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($childIX < $children->$#*) 108 39 147
534 108 $child = $children->[$childIX];
535 108 my $symbol = $child->{symbol};
536 108 ▶ if ( not defined $symbol
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $symbol and $symbolReverseDB->{$symbol}{"gap"}) 18 90 108
Condition66%2/3
defined $symbol and $symbolReverseDB->{$symbol}{"gap"}
!ll&&!rl&&r
01890
MC/DC50%1/2
defined $symbol and $symbolReverseDB->{$symbol}{"gap"}
defined $symbol $symbolReverseDB->{$symbol}{"gap"}
Truth table66%2/3
A and B
A= defined $symbolB= $symbolReverseDB->{$symbol}{"gap"}
ABresult
0X0
100
111
537 or not $symbolReverseDB->{$symbol}->{gap} )
538 {
539 18 $childIX++;
540 18 next CHILD;
541 }
542 90 my $nextChild = $children->[ $childIX + 1 ];
543 90 push @gapSeq, $child, $nextChild;
544 90 $childIX += 2;
545 }
546 39 return \@gapSeq;
547 }
548  
549 # A variant of "gapSeq" which relaxes the assumption that
550 # the first child is not a gap, and which returns an
551 # alternating sequence of gap and post-gap. It assumes
552 # that a gap does not follow another gap.
553 444 ▶sub gapSeq0 {
Subroutine gapSeq0: called CC=4 SCAR=13.9
Pod undocumented
554 444 my ( $policy, $node ) = @_;
555 444 my $instance = $policy->{lint};
556 444 my $symbolReverseDB = $instance->{symbolReverseDB};
557 444 my $children = $node->{children};
558 444 my @gapSeq = ();
559  
560 444 my $childIX = 0;
561 444 ▶ CHILD: while ( $childIX < $#$children ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($childIX < $children->$#*) 1236 444 1680
562 1236 my $child = $children->[$childIX];
563 1236 my $symbol = $child->{symbol};
564 1236 ▶ if ( not defined $symbol
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $symbol and $symbolReverseDB->{$symbol}{"gap"}) 276 960 1236
Condition66%2/3
defined $symbol and $symbolReverseDB->{$symbol}{"gap"}
!ll&&!rl&&r
0276960
MC/DC50%1/2
defined $symbol and $symbolReverseDB->{$symbol}{"gap"}
defined $symbol $symbolReverseDB->{$symbol}{"gap"}
Truth table66%2/3
A and B
A= defined $symbolB= $symbolReverseDB->{$symbol}{"gap"}
ABresult
0X0
100
111
565 or not $symbolReverseDB->{$symbol}->{gap} )
566 {
567 276 $childIX++;
568 276 next CHILD;
569 }
570 960 my $nextChild = $children->[ $childIX + 1 ];
571 960 push @gapSeq, $child, $nextChild;
572 960 $childIX += 2;
573 }
574 444 return \@gapSeq;
575 }
576  
577 # Checks a gap to see if it is OK as a pseudo-join.
578 # If so, returns the column at which code may resume.
579 # Otherwise returns -1;
580  
581 33 ▶sub pseudojoinColumn {
Subroutine pseudojoinColumn: called CC=10 SCAR=26.4
Pod undocumented
582 33 my ( $policy, $gap ) = @_;
583 33 my $instance = $policy->{lint};
584 33 my $gapLiteral = $instance->literalNode($gap);
585 33 my $gapStart = $gap->{start};
586 33 my $gapEnd = $gap->{start} + $gap->{length};
587  
588 33 ▶ if ($instance->runeGapNode($gap)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($instance->runeGapNode($gap)) 0 33 33
589 0 $gapLiteral = substr( $gapLiteral, 2 );
590 0 $gapStart += 2;
591 }
592  
593 33 my ( $startLine, $startColumn ) = $instance->line_column($gapStart);
594 33 my ( $endLine, $endColumn ) = $instance->line_column($gapEnd);
595  
596 33 my $commentColumn;
597  
598 # first partial line (must exist)
599 33 my $firstNewline = index $gapLiteral, "\n";
600 33 ▶ return if $firstNewline < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $firstNewline < 0 0 33 33
601 33 my $firstColon = index $gapLiteral, ':';
602 33 ▶ if ( $firstColon >= 0 and $firstColon < $firstNewline ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($firstColon >= 0 and $firstColon < $firstNewline) 24 9 33
Condition66%2/3
$firstColon >= 0 and $firstColon < $firstNewline
!ll&&!rl&&r
9024
MC/DC50%1/2
$firstColon >= 0 and $firstColon < $firstNewline
$firstColon >= 0 $firstColon < $firstNewline
Truth table66%2/3
A and B
A= $firstColon >= 0B= $firstColon < $firstNewline
ABresult
0X0
100
111
603 24 ( undef, $commentColumn ) =
604 $instance->line_column( $gapStart + $firstColon );
605 }
606  
607 # say STDERR join ' ', __FILE__, __LINE__;
608 33 ▶ return -1 if not $commentColumn;
Branch: 1 branch
BranchTrueFalseTotal
unless $commentColumn 9 24 33
609 # say STDERR join ' ', __FILE__, __LINE__;
610  
611 # If the last line of the gap does not end in a newline,
612 # it **cannot** contain a comment, because the parser would
613 # recognize the whole comment as part of the gap.
614 # So we only look for properly aligned comments in full
615 # (that is, newline-terminated) lines.
616  
617 24 ▶ my $lastFullLine =
Branch: 1 branch
BranchTrueFalseTotal
substr($gapLiteral, -1, 1) eq "\n" ? : 0 24 24
618 ( substr $gapLiteral, -1, 1 ) eq "\n" ? $endLine : $endLine - 1;
619 24 for my $lineNum ( $startLine + 1 .. $lastFullLine ) {
620 0 my $literalLine = $instance->literalLine($lineNum);
621 0 my $commentOffset = index $literalLine, ':';
622  
623 # say STDERR join ' ', __FILE__, __LINE__;
624 0 ▶ return -1 if $commentOffset < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $commentOffset < 0 0 0 0
625 # say STDERR join ' ', __FILE__, __LINE__, $commentOffset, $commentColumn;
626 0 ▶ return -1 if $commentOffset != $commentColumn;
Branch: 1 branch
BranchTrueFalseTotal
if $commentOffset != $commentColumn 0 0 0
627 # say STDERR join ' ', __FILE__, __LINE__;
628 }
629 24 return $commentColumn;
630 }
631  
632 # Is this a valid join gap?
633 # Return undef if not.
634 # Return -1 if flat join.
635 # Return pseudo-join column if pseudo-join.
636 12 ▶sub checkJoinGap {
Subroutine checkJoinGap: called CC=4 SCAR=21.1
Pod undocumented
637 12 my ( $policy, $gap ) = @_;
638 12 my $instance = $policy->{lint};
639 12 my $gapLiteral = $instance->literalNode($gap);
640  
641 # say join ' ', __FILE__, __LINE__;
642 # say join q{}, '[', $gapLiteral, ']';
643 12 ▶ return -1 if $gapLiteral =~ m/\A [ ]* \z/xms;
Branch: 1 branch
BranchTrueFalseTotal
if $gapLiteral =~ /\A [ ]* \z/msx 12 0 12
644  
645 # say join ' ', __FILE__, __LINE__;
646 0 my $column = $policy->pseudojoinColumn($gap);
647 0 ▶ return $column if defined $column and $column >= 0;
Branch: 1 branch
BranchTrueFalseTotal
if defined $column and $column >= 0 0 0 0
Condition0%0/3
defined $column and $column >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $column and $column >= 0
defined $column $column >= 0
Truth table0%0/3
A and B
A= defined $columnB= $column >= 0
ABresult
0X0
100
111
648 0 return;
649 }
650  
651 39 ▶sub deComment {
Subroutine deComment: called CC=1 SCAR=0.0
Pod undocumented
652 39 my ( $policy, $string ) = @_;
653 39 $string =~ s/ ([+][|]|[:][:]|[:][<]|[:][>]) .* \z//xms;
654 39 return $string;
655 }
656  
657 # Is this a one-line gap, or its equivalent?
658 345 ▶sub checkOneLineGap {
Subroutine checkOneLineGap: called CC=22 SCAR=40.6
Pod undocumented
659 345 my ( $policy, $gap, $options ) = @_;
660 345 my $instance = $policy->{lint};
661 345 my $start = $gap->{start};
662 345 my $length = $gap->{length};
663 345 ▶ if ( $instance->runeGapNode($gap) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($instance->runeGapNode($gap)) 6 339 345
664 6 $start += 2;
665 6 $length -= 2;
666 }
667  
668 345 my $runeName = $options->{runeName};
669 345 my $details = $options->{details};
670 345 my $elementNumber = $options->{elementNumber};
671  
672 345 my @topicLines = ();
673 345 my $topicLines = $options->{topicLines};
674 345 ▶ push @topicLines, @{$topicLines} if $topicLines;
Branch: 1 branch
BranchTrueFalseTotal
if $topicLines 333 12 345
675  
676 345 my @mistakes = ();
677 345 my $end = $start + $length;
678 345 my ( $startLine, $startColumn ) = $instance->line_column($start);
679 345 my ( $endLine, $endColumn ) = $instance->line_column($end);
680  
681 # say STDERR Data::Dumper::Dumper($options);
682  
683 345 my ( $mainLine, $mainColumn );
684 345 ▶ if ( my $mainNode = $options->{mainNode} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mainNode = $options->{"mainNode"}) 0 345 345
685 0 ( $mainLine, $mainColumn ) = $instance->nodeLC($mainNode);
686 }
687 345 ▶ $mainColumn //= $options->{mainColumn} // -1;
Condition50%2/4
$mainColumn //= $options->{"mainColumn"} // -1
l!l
0345
$options->{"mainColumn"} // -1
l!l
3450
MC/DC0%0/1
$mainColumn //= $options->{"mainColumn"} // -1
$mainColumn
Truth table50%1/2
A
A= $mainColumn
Aresult
11
00
688  
689 345 my ( $preLine, $preColumn );
690 345 ▶ if ( my $preNode = $options->{preNode} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $preNode = $options->{"preNode"}) 0 345 345
691 0 ( $preLine, $preColumn ) = $instance->nodeLC($preNode);
692 }
693 345 ▶ $preColumn //= $options->{preColumn} // -1;
Condition75%3/4
$preColumn //= $options->{"preColumn"} // -1
l!l
0345
$options->{"preColumn"} // -1
l!l
30639
MC/DC0%0/1
$preColumn //= $options->{"preColumn"} // -1
$preColumn
Truth table50%1/2
A
A= $preColumn
Aresult
11
00
694  
695 345 my @subpolicyElements = ();
696 SET_SUBPOLICY: {
697 345 my $subpolicyArg = $options->{subpolicy};
698 345 ▶ last SET_SUBPOLICY if not defined $subpolicyArg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $subpolicyArg 0 345 345
699 345 ▶ if ( not ref $subpolicyArg ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $subpolicyArg) 0 345 345
700 0 push @subpolicyElements, $subpolicyArg;
701 0 last SET_SUBPOLICY;
702 }
703 345 push @subpolicyElements, @{$subpolicyArg};
704 }
705  
706 # Criss-cross TISTIS lines are a special case
707 # say STDERR join " ", __FILE__, __LINE__, $startLine, $endLine;
708 345 ▶ if ( $startLine == $endLine
Branch: 1 branch
BranchTrueFalseTotal
if ($startLine == $endLine and $instance->literal($start - 2, 2) ne "==" and $instance->literal($start - 2, 2) ne "--") 0 345 345
Condition33%2/6
$startLine == $endLine and $instance->literal($start - 2, 2) ne "==" and $instance->literal($start - 2, 2) ne "--"
!ll&&!rl&&r
34500
$startLine == $endLine and $instance->literal($start - 2, 2) ne "=="
!ll&&!rl&&r
34500
MC/DC0%0/3
$startLine == $endLine and $instance->literal($start - 2, 2) ne "==" and $instance->literal($start - 2, 2) ne "--"
$startLine == $endLine $instance->literal($start - 2, 2) ne "==" $instance->literal($start - 2, 2) ne "--"
Truth table25%1/4
A and B and C
A= $startLine == $endLineB= $instance->literal($start - 2, 2) ne "=="C= $instance->literal($start - 2, 2) ne "--"
ABCresult
0XX0
10X0
1100
1111
709 and $instance->literal( $start - 2, 2 ) ne '=='
710 and $instance->literal( $start - 2, 2 ) ne '--' )
711 {
712 0 my $msg = sprintf
713 "%s %s; %s %s",
714 $runeName,
715 describeLC( $startLine, $startColumn ),
716 "missing newline ",
717 , describeLC( $startLine, $startColumn );
718 return [
719 {
720 0 desc => $msg,
721 subpolicy =>
722 ( join ':', @subpolicyElements, 'missing-newline' ),
723 runeName => $runeName,
724 line => $startLine,
725 column => $startColumn,
726 reportLine => $startLine,
727 reportColumn => $startColumn,
728 topicLines => \@topicLines,
729 details => $details,
730 }
731 ];
732 }
733  
734 345 ▶ my $bodyStartLine = $start == 0 ? $startLine : $startLine + 1;
Branch: 1 branch
BranchTrueFalseTotal
$start == 0 ? : 0 345 345
735 345 my $lineToPos = $instance->{lineToPos};
736 345 ▶ if ( $bodyStartLine < $#$lineToPos ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyStartLine < $lineToPos->$#*) 345 0 345
737 345 my $literalFirstLine = $instance->literalLine($bodyStartLine);
738 345 ▶ if ( $literalFirstLine =~ /'''/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($literalFirstLine =~ /'''/) 0 345 345
739  
740 # say join ' ', __FILE__, __LINE__, qq{"$literalFirstLine"};
741 0 $bodyStartLine++;
742 }
743 345 ▶ if ( $literalFirstLine =~ /"""/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($literalFirstLine =~ /"""/) 0 345 345
744  
745 # say join ' ', __FILE__, __LINE__, qq{"$literalFirstLine"};
746 0 $bodyStartLine++;
747 }
748 }
749 345 my $results = $policy->checkGapComments( $bodyStartLine, $endLine - 1,
750 $mainColumn, $preColumn );
751 345 RESULT: for my $result ( @{$results} ) {
752 0 my $type = $result->[0];
753 0 ▶ if ( $type eq 'vgap-blank-line' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "vgap-blank-line") 0 0 0
754 0 my ( undef, $lineNum, $offset ) = @{$result};
755 0 my $msg = sprintf
756 "%s %s; %s",
757 $runeName,
758 describeLC( $lineNum, 0 ),
759 "empty line in comment";
760 0 push @mistakes,
761 {
762 desc => $msg,
763 subpolicy => ( join ':', @subpolicyElements, 'empty-line' ),
764 runeName => $runeName,
765 reportLine => $lineNum,
766 reportColumn => 0,
767 line => $lineNum,
768 column => 0,
769 topicLines => \@topicLines,
770 details => $details,
771 };
772 0 next RESULT;
773 }
774 0 ▶ if ( $type eq 'vgap-bad-comment' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "vgap-bad-comment") 0 0 0
775 0 my ( undef, $lineNum, $offset, $expectedOffset ) = @{$result};
776  
777 0 my $msg;
778 0 ▶ if ( defined $elementNumber ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $elementNumber) { } 0 0 0
779 0 $msg = sprintf
780 "%s child %d %s; %s %s",
781 $runeName,
782 $elementNumber,
783 describeLC( $lineNum, $offset ),
784 "comment",
785 describeMisindent2( $offset, $expectedOffset );
786 }
787 else {
788 0 $msg = sprintf
789 "%s d %s; %s %s",
790 $runeName,
791 describeLC( $lineNum, $offset ),
792 "comment",
793 describeMisindent2( $offset, $expectedOffset );
794 }
795 0 push @mistakes,
796 {
797 desc => $msg,
798 subpolicy => ( join ':', @subpolicyElements, 'comment-indent' ),
799 runeName => $runeName,
800 reportLine => $lineNum,
801 reportColumn => $offset,
802 line => $lineNum,
803 column => $offset,
804 topicLines => \@topicLines,
805 details => $details,
806 };
807 }
808 }
809  
810 345 return \@mistakes;
811 }
812  
813  
814 345 ▶sub checkGapComments {
Subroutine checkGapComments: called CC=47 SCAR=64.8
Pod undocumented
815 345 my ( $policy, $firstLine, $lastLine, $interOffset, $preOffset ) = @_;
816  
817 345 ▶ return if $lastLine < $firstLine;
Branch: 1 branch
BranchTrueFalseTotal
if $lastLine < $firstLine 330 15 345
818 15 my $instance = $policy->{lint};
819 15 my $pSource = $instance->{pHoonSource};
820 15 my $lineToPos = $instance->{lineToPos};
821 SET_PREOFFSET: {
822 15 ▶ last SET_PREOFFSET if not defined $preOffset;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $preOffset 0 15 15
823 15 ▶ if ( $preOffset < 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($preOffset < 0) 0 15 15
824 0 $preOffset = undef; # negative offset == undefined
825 0 last SET_PREOFFSET;
826 }
827 15 ▶ if ( $preOffset == $interOffset ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($preOffset == $interOffset) 3 12 15
828  
829 # Do not allow pre-offset to be equal to inter-offset
830 3 $preOffset = undef;
831 3 last SET_PREOFFSET;
832 }
833 }
834 15 my @mistakes = ();
835  
836 15 my $grammar = $policy->{gapGrammar};
837 15 my $recce = Marpa::R2::Scanless::R->new( { grammar => $grammar } );
838 15 my $startPos = $lineToPos->[$firstLine];
839 15 my $input = $instance->literal( $startPos,
840 ( $lineToPos->[ $lastLine + 1 ] - $startPos ) );
841  
842 # say STDERR join ' ', __FILE__, __LINE__, "$firstLine-$lastLine", qq{"$input"};
843  
844 15 ▶ if ( not defined eval { $recce->read( $pSource, $startPos, 0 ); 1 } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined eval { do { $recce->read($pSource, $startPos, 0); 1 } }) 0 15 15
845  
846 0 my $eval_error = $EVAL_ERROR;
847 0 chomp $eval_error;
848 0 say STDERR join ' ', __FILE__, __LINE__, "$firstLine-$lastLine",
849 qq{"$input"};
850 0 die $eval_error, "\n";
851 }
852  
853 15 my $lineNum = 0;
854 LINE:
855 15 ▶ for ( my $lineNum = $firstLine ; $lineNum <= $lastLine ; $lineNum++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lineNum <= $lastLine) 15 15 30
856 15 my $line = $instance->literalLine($lineNum);
857  
858 # say STDERR join ' ', __FILE__, __LINE__, $lineNum, qq{"$line"};
859  
860 FIND_ALTERNATIVES: {
861 15 my $expected = $recce->terminals_expected();
862  
863 # say Data::Dumper::Dumper($expected);
864 15 my $tier1_ok;
865 15 my @tier2 = ();
866 15 my @failedOffsets = ();
867 15 TIER1: for my $terminal ( @{$expected} ) {
868  
869 # say STDERR join ' ', __FILE__, __LINE__, $terminal;
870 90 ▶ if ( $terminal eq 'InterComment' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($terminal eq "InterComment") 15 75 90
871 15 $line =~ m/^ [ ]* ([+][|]|[:][:]|[:][<]|[:][>]) /x;
872 15 my $commentOffset = $LAST_MATCH_START[1];
873 15 ▶ $commentOffset //= -1;
Condition50%1/2
$commentOffset //= -1
l!l
150
MC/DC0%0/1
$commentOffset //= -1
$commentOffset
Truth table50%1/2
A
A= $commentOffset
Aresult
11
00
874  
875 # say STDERR join ' ', __FILE__, __LINE__, qq{"$line"};
876 # say STDERR join ' ', __FILE__, __LINE__, $commentOffset;
877 15 ▶ if ( $commentOffset == $interOffset ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($commentOffset == $interOffset) 15 0 15
878  
879 # say STDERR join ' ', __FILE__, __LINE__;
880 15 $recce->lexeme_alternative( $terminal, $line );
881 15 $tier1_ok = 1;
882 15 next TIER1;
883 }
884 0 push @failedOffsets, $interOffset;
885 0 next TIER1;
886 }
887 75 ▶ if ( $terminal eq 'Tread' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($terminal eq "Tread") 0 75 75
888 0 $line =~ m/^ [ ]* ([:][:][:][:][ \n]) /x;
889 0 my $commentOffset = $LAST_MATCH_START[1];
890 0 ▶ $commentOffset //= -1;
Condition0%0/2
$commentOffset //= -1
l!l
00
MC/DC0%0/1
$commentOffset //= -1
$commentOffset
Truth table0%0/2
A
A= $commentOffset
Aresult
11
00
891  
892 # say STDERR join ' ', __FILE__, __LINE__, $commentOffset;
893 0 ▶ if ( $commentOffset == $interOffset ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($commentOffset == $interOffset) 0 0 0
894  
895 # say STDERR join ' ', __FILE__, __LINE__;
896 0 $recce->lexeme_alternative( $terminal, $line );
897 0 $tier1_ok = 1;
898 0 next TIER1;
899 }
900 0 push @failedOffsets, $interOffset;
901 0 next TIER1;
902 }
903 75 ▶ if ( $terminal eq 'UpperRiser' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($terminal eq "UpperRiser") 15 60 75
904 15 $line =~ m/^ [ ]* ([:][:]) /x;
905 15 my $commentOffset = $LAST_MATCH_START[1];
906 15 ▶ $commentOffset //= -1;
Condition50%1/2
$commentOffset //= -1
l!l
150
MC/DC0%0/1
$commentOffset //= -1
$commentOffset
Truth table50%1/2
A
A= $commentOffset
Aresult
11
00
907  
908 # say STDERR join ' ', __FILE__, __LINE__, $commentOffset;
909 15 ▶ if ( $commentOffset == $interOffset ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($commentOffset == $interOffset) 15 0 15
910  
911 # say STDERR join ' ', __FILE__, __LINE__;
912 15 $recce->lexeme_alternative( $terminal, $line );
913 15 $tier1_ok = 1;
914 15 next TIER1;
915 }
916 0 push @failedOffsets, $interOffset;
917 0 next TIER1;
918 }
919 60 ▶ if ( $terminal eq 'LowerRiser' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($terminal eq "LowerRiser") 0 60 60
920 0 $line =~ m/^ [ ]* ([:][:]) /x;
921 0 my $commentOffset = $LAST_MATCH_START[1];
922 0 ▶ $commentOffset //= -1;
Condition0%0/2
$commentOffset //= -1
l!l
00
MC/DC0%0/1
$commentOffset //= -1
$commentOffset
Truth table0%0/2
A
A= $commentOffset
Aresult
11
00
923  
924 # say STDERR join ' ', __FILE__, __LINE__, $commentOffset;
925 0 ▶ if ( $commentOffset == $interOffset + 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($commentOffset == $interOffset + 2) 0 0 0
926  
927 # say STDERR join ' ', __FILE__, __LINE__;
928 0 $recce->lexeme_alternative( $terminal, $line );
929 0 $tier1_ok = 1;
930 0 next TIER1;
931 }
932 0 push @failedOffsets, $interOffset;
933 0 next TIER1;
934 }
935 60 push @tier2, $terminal;
936 }
937  
938 # If we found a tier 1 lexeme, do not look for the "backup"
939 # lexemes on the other tiers
940 15 ▶ last FIND_ALTERNATIVES if $tier1_ok;
Branch: 1 branch
BranchTrueFalseTotal
if $tier1_ok 15 0 15
941  
942 0 my $tier2_ok;
943 0 my @tier3 = ();
944 0 TIER2: for my $terminal (@tier2) {
945 0 ▶ if ( $terminal eq 'PreComment' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($terminal eq "PreComment") 0 0 0
946 0 ▶ next TIER2 if not defined $preOffset;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $preOffset 0 0 0
947 0 $line =~ m/^ [ ]* ([+][|]|[:][:]|[:][<]|[:][>]) /x;
948 0 my $commentOffset = $LAST_MATCH_START[1];
949 0 ▶ $commentOffset //= -1;
Condition0%0/2
$commentOffset //= -1
l!l
00
MC/DC0%0/1
$commentOffset //= -1
$commentOffset
Truth table0%0/2
A
A= $commentOffset
Aresult
11
00
950  
951 # say STDERR join ' ', __FILE__, __LINE__, $commentOffset;
952 0 ▶ if ( $commentOffset == $preOffset ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($commentOffset == $preOffset) 0 0 0
953  
954 # say STDERR join ' ', __FILE__, __LINE__;
955 0 $recce->lexeme_alternative( $terminal, $line );
956 0 $tier2_ok = 1;
957 0 next TIER2;
958 }
959 0 push @failedOffsets, $preOffset;
960 0 next TIER2;
961 }
962 0 push @tier3, $terminal;
963 }
964  
965 # If we found a tier 2 lexeme, do not look for the "backup"
966 # lexemes on the other tiers
967 0 ▶ last FIND_ALTERNATIVES if $tier2_ok;
Branch: 1 branch
BranchTrueFalseTotal
if $tier2_ok 0 0 0
968  
969 0 my @tier4 = ();
970 0 TIER3: for my $terminal (@tier3) {
971 0 ▶ if ( $terminal eq 'MetaComment' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($terminal eq "MetaComment") 0 0 0
972 0 $line =~ m/^ [ ]* ([+][|]|[:][:]|[:][<]|[:][>]) /x;
973 0 my $commentOffset = $LAST_MATCH_START[1];
974 0 ▶ next TIER3 if not defined $commentOffset;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $commentOffset 0 0 0
975 0 ▶ if ( $commentOffset == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($commentOffset == 0) 0 0 0
976 0 $recce->lexeme_alternative( $terminal, $line );
977  
978 # anything in this tier terminates the finding of alternatives
979 0 last FIND_ALTERNATIVES;
980 }
981 0 push @failedOffsets, $interOffset;
982 }
983 0 push @tier4, $terminal;
984 }
985  
986 0 TIER4: for my $terminal (@tier4) {
987 0 ▶ if ( $terminal eq 'BlankLine' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($terminal eq "BlankLine") 0 0 0
988  
989 # say STDERR join ' ', __FILE__, __LINE__, $lineNum, qq{"$line"};
990 0 ▶ if ( $line =~ m/\A [\n ]* \z/xms ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /\A [\n ]* \z/msx) 0 0 0
991 0 $recce->lexeme_alternative( $terminal, $line );
992  
993 # anything in this tier terminates the finding of alternatives
994 0 push @mistakes, [ 'vgap-blank-line', $lineNum ];
995 0 last FIND_ALTERNATIVES;
996 }
997 }
998 0 ▶ if ( $terminal eq 'BadComment' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($terminal eq "BadComment") 0 0 0
999 0 ▶ if ( $line =~ m/^ [ ]* ([+][|]|[:][:]|[:][<]|[:][>]) /x ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^ [ ]* ([+][|]|[:][:]|[:][<]|[:][>]) /x) 0 0 0
1000 0 $recce->lexeme_alternative( $terminal, $line );
1001 0 my $commentOffset = $LAST_MATCH_START[1];
1002  
1003 0 my $closestHiOffset;
1004 my $closestLoOffset;
1005  
1006 0 for my $failedOffset (@failedOffsets) {
1007 0 ▶ if ( $failedOffset > $commentOffset ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($failedOffset > $commentOffset) 0 0 0
1008 0 ▶ if ( not defined $closestHiOffset
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $closestHiOffset or $failedOffset < $closestHiOffset) 0 0 0
Condition0%0/3
not defined $closestHiOffset or $failedOffset < $closestHiOffset
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $closestHiOffset or $failedOffset < $closestHiOffset
not defined $closestHiOffset $failedOffset < $closestHiOffset
Truth table0%0/3
not(A) or B
A= not defined $closestHiOffsetB= $failedOffset < $closestHiOffset
ABresult
1X1
011
000
1009 or $failedOffset < $closestHiOffset )
1010 {
1011 0 $closestHiOffset = $failedOffset;
1012 }
1013 }
1014 0 ▶ if ( $failedOffset < $commentOffset ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($failedOffset < $commentOffset) 0 0 0
1015 0 ▶ if ( not defined $closestLoOffset
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $closestLoOffset or $failedOffset > $closestLoOffset) 0 0 0
Condition0%0/3
not defined $closestLoOffset or $failedOffset > $closestLoOffset
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $closestLoOffset or $failedOffset > $closestLoOffset
not defined $closestLoOffset $failedOffset > $closestLoOffset
Truth table0%0/3
not(A) or B
A= not defined $closestLoOffsetB= $failedOffset > $closestLoOffset
ABresult
1X1
011
000
1016 or $failedOffset > $closestLoOffset )
1017 {
1018 0 $closestLoOffset = $failedOffset;
1019 }
1020 }
1021 }
1022 0 ▶ my $closestOffset =
Condition0%0/3
$closestLoOffset // $closestHiOffset
l!l&&r!l&&!r
000
MC/DC0%0/2
$closestLoOffset // $closestHiOffset
$closestLoOffset $closestHiOffset
Truth table0%0/3
A // B
A= $closestLoOffsetB= $closestHiOffset
ABresult
1X1
011
000
1023 ( $closestLoOffset // $closestHiOffset );
1024  
1025 # say STDERR join ' ', __LINE__, 'vgap-bad-comment', $lineNum, $commentOffset, $closestOffset ;
1026 0 push @mistakes,
1027 [
1028 'vgap-bad-comment', $lineNum,
1029 $commentOffset, $closestOffset
1030 ];
1031  
1032 # anything in this tier terminates the finding of alternatives
1033 0 last FIND_ALTERNATIVES;
1034 }
1035 }
1036 }
1037  
1038 }
1039 15 my $startPos = $lineToPos->[$lineNum];
1040  
1041 # say STDERR join ' ', __FILE__, __LINE__;
1042 15 my $eval_ok = eval {
1043 15 $recce->lexeme_complete( $startPos,
1044 ( $lineToPos->[ $lineNum + 1 ] - $startPos ) );
1045 15 1;
1046 };
1047 15 ▶ if ( not $eval_ok ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($eval_ok) 0 15 15
1048  
1049 0 my $eval_error = $EVAL_ERROR;
1050 0 chomp $eval_error;
1051  
1052 # say STDERR join ' ', __FILE__, __LINE__, "$firstLine-$lastLine",
1053 # qq{"$input"};
1054 0 die $eval_error, "\n";
1055 }
1056 }
1057 15 my $metric = $recce->ambiguity_metric();
1058 15 ▶ if ( $metric != 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($metric != 1) 0 15 15
1059 0 ▶ my $issue = $metric ? "ambiguous" : "no parse";
Branch: 1 branch
BranchTrueFalseTotal
$metric ? : 0 0 0
1060 0 say STDERR $recce->show_progress( 0, -1 );
1061 0 say STDERR $input;
1062  
1063 # say STDERR join " ", __FILE__, __LINE__, $policy, $firstLine, $lastLine, $interOffset, $preOffset;
1064 0 die "Bad gap combinator parse: $issue\n";
1065 }
1066 15 return \@mistakes;
1067 }
1068  
1069 # TODO: refactor all pseudojoins to call the
1070 # checkPseudojoin() method.
1071  
1072 # If a pseudo-join,
1073 # return a (possible empty) list of mistakes.
1074 # Otherwise, return undef.
1075 6 ▶sub checkPseudojoin {
Subroutine checkPseudojoin: called CC=13 SCAR=29.1
Pod undocumented
1076 6 my ( $policy, $gap, $options ) = @_;
1077 6 my $instance = $policy->{lint};
1078 # say STDERR '[' . $instance->literalNode($gap) . ']';
1079 6 my @mistakes = ();
1080  
1081 # Assume that the gap is not the top of the tree.
1082 6 my $parent = $gap->{PARENT};
1083 6 my ( $parentLine, $parentColumn ) = $instance->nodeLC($parent);
1084  
1085 6 my $expected = $options->{lengths};
1086 6 my $desc = $options->{desc};
1087 6 my $details = $options->{details};
1088 6 ▶ my $runeName = $options->{runeName} // $policy->runeName($parent);
Condition33%1/3
$options->{"runeName"} // $policy->runeName($parent)
l!l&&r!l&&!r
060
MC/DC0%0/2
$options->{"runeName"} // $policy->runeName($parent)
$options->{"runeName"} $policy->runeName($parent)
Truth table33%1/3
A // B
A= $options->{"runeName"}B= $policy->runeName($parent)
ABresult
1X1
011
000
1089 6 ▶ my $subpolicy = $options->{subpolicy} // [$runeName];
Condition50%1/2
$options->{"subpolicy"} // [$runeName]
l!l
60
MC/DC0%0/1
$options->{"subpolicy"} // [$runeName]
$options->{"subpolicy"}
Truth table50%1/2
A
A= $options->{"subpolicy"}
Aresult
11
00
1090  
1091 # say STDERR Data::Dumper::Dumper($options);
1092  
1093 6 my $gapLength = $gap->{length};
1094 6 my ( $gapLine, $gapColumn ) = $instance->nodeLC($gap);
1095 6 my $nextLexemeOffset = $gap->{start} + $gapLength;
1096 6 ▶ if ($instance->runeGapNode($gap)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($instance->runeGapNode($gap)) 0 6 6
1097 0 $gapColumn += 2;
1098 0 $gapLength -= 2;
1099 }
1100 6 my ( $nextLexemeLine, $nextLexemeColumn ) =
1101 $instance->line_column( $nextLexemeOffset );
1102  
1103 6 ▶ if ( not $expected ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($expected) 6 0 6
1104  
1105 # default is to be tightly aligned
1106 6 $expected = [['tight', 2, 1]];
1107 }
1108  
1109 6 my @expectedColumns = ();
1110 6 LENGTH: for my $expectedItem ( @{$expected} ) {
1111 6 my ($alignDesc, $column, $isLength ) = @{$expectedItem};
1112 # say STDERR "alignDesc, column, isLength; $alignDesc, $column, $isLength ";
1113 # say STDERR "gap L,C: $gapLine, $gapColumn";
1114 6 ▶ $column += $gapColumn if $isLength;
Branch: 1 branch
BranchTrueFalseTotal
if $isLength 6 0 6
1115 # say STDERR "alignDesc, column, isLength; $alignDesc, $column, $isLength ";
1116 6 push @expectedColumns, [ $alignDesc, $column ];
1117 }
1118  
1119 # If here, we are checking for pseudojoin
1120 6 my $pseudojoinColumn = $policy->pseudojoinColumn($gap);
1121 # say STDERR "pseudojoinColumn ", Data::Dumper::Dumper($pseudojoinColumn);
1122  
1123 # Return undef to show vertical gap is not a pseudojoin
1124 6 ▶ return if not defined $pseudojoinColumn;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pseudojoinColumn 0 6 6
1125 6 ▶ return if $pseudojoinColumn < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $pseudojoinColumn < 0 3 3 6
1126  
1127 # Pseudojoin of desired length
1128 3 my $isPseudojoin;
1129 3 TEST_FOR_PSEUDOJOIN: for my $expectedColumnItem (@expectedColumns) {
1130 3 my ($alignDesc, $alignColumn) = @{$expectedColumnItem};
1131 # say STDERR "pseudojoinColumn alignColumn; $pseudojoinColumn, $alignColumn";
1132 3 ▶ if ($pseudojoinColumn == $alignColumn) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pseudojoinColumn == $alignColumn) 0 3 3
1133 0 $isPseudojoin = 1;
1134 0 last TEST_FOR_PSEUDOJOIN;
1135 }
1136 }
1137  
1138 3 ▶ return if not $isPseudojoin;
Branch: 1 branch
BranchTrueFalseTotal
unless $isPseudojoin 3 0 3
1139  
1140 0 ▶ return [] if $nextLexemeColumn == $pseudojoinColumn;
Branch: 1 branch
BranchTrueFalseTotal
if $nextLexemeColumn == $pseudojoinColumn 0 0 0
1141  
1142 # If here, it is a problematic pseudojoin
1143 0 my $msg = sprintf
1144 '%s %s; %s',
1145 $desc,
1146 describeLC( $nextLexemeLine, $nextLexemeColumn ),
1147 describeMisindent2( $nextLexemeColumn, $pseudojoinColumn );
1148 push @mistakes, {
1149 desc => $msg,
1150 0 subpolicy => [ @{$subpolicy}, 'pseudojoin' ],
1151 line => $nextLexemeLine,
1152 column => $nextLexemeColumn,
1153 reportLine => $nextLexemeLine,
1154 reportColumn => $nextLexemeColumn,
1155 topicLines => [$parentLine],
1156 details => $details,
1157 };
1158  
1159 0 return \@mistakes;
1160 }
1161  
1162 # Replace all TISTIS logic with this
1163 18 ▶sub checkTistis {
Subroutine checkTistis: called CC=6 SCAR=20.3
Pod undocumented
1164 18 my ( $policy, $tistis, $options ) = @_;
1165 18 my $expectedColumn = $options->{expectedColumn};
1166 18 my $tag = $options->{tag};
1167 18 my $instance = $policy->{lint};
1168 18 my $parent = $tistis->{PARENT};
1169 18 my @mistakes = ();
1170  
1171 # TODO: Delete after development
1172 18 ▶ die if defined $options->{subpolicyTag};
Branch: 1 branch
BranchTrueFalseTotal
if defined $options->{"subpolicyTag"} 0 18 18
1173  
1174 18 my @subpolicy = ();
1175 SET_SUBPOLICY: {
1176 18 my $subpolicy = $options->{subpolicy};
1177 18 ▶ if (defined $subpolicy) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $subpolicy) 18 0 18
1178 18 push @subpolicy, @{$subpolicy};
1179 18 last SET_SUBPOLICY;
1180 }
1181 0 push @subpolicy, $policy->nodeSubpolicy($parent);
1182 }
1183  
1184 18 my ( $parentLine, $parentColumn ) = $instance->nodeLC($parent);
1185 18 my ( $tistisLine, $tistisColumn ) = $instance->nodeLC($tistis);
1186 18 my $literalLine = $instance->literalLine($tistisLine);
1187  
1188 18 my $runeName = $policy->runeName($parent);
1189  
1190 18 $literalLine = $policy->deComment($literalLine);
1191 18 $literalLine =~ s/\n//g;
1192 18 $literalLine =~ s/==//g;
1193 18 ▶ if ( $literalLine =~ m/[^ ]/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($literalLine =~ /[^ ]/) 0 18 18
1194 0 my $runeLC = describeLC($parentLine, $parentColumn);
1195 0 my $msg =
1196 sprintf q{TISTIS %s should only share line with other TISTIS's},
1197 describeLC( $tistisLine, $tistisColumn );
1198 0 push @mistakes,
1199 {
1200 desc => $msg,
1201 subpolicy => [ @subpolicy, 'tistis-alone' ],
1202 parentLine => $parentLine,
1203 parentColumn => $parentColumn,
1204 line => $tistisLine,
1205 column => $tistisColumn,
1206 reportLine => $tistisLine,
1207 reportColumn => $tistisColumn,
1208 details => [ ["Starts at $runeLC"] ],
1209 };
1210 0 return \@mistakes;
1211 }
1212  
1213 18 my $tistisIsMisaligned = $tistisColumn != $expectedColumn;
1214  
1215 18 ▶ if ($tistisIsMisaligned) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tistisIsMisaligned) 0 18 18
1216 0 my $lineToPos = $instance->{lineToPos};
1217 0 my $tistisPos = $lineToPos->[$tistisLine] + $expectedColumn;
1218 0 my $tistisLiteral = $instance->literal( $tistisPos, 2 );
1219  
1220 0 $tistisIsMisaligned = $tistisLiteral ne '==';
1221 }
1222 18 ▶ if ($tistisIsMisaligned) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tistisIsMisaligned) 0 18 18
1223 0 my $runeLC = describeLC($parentLine, $parentColumn);
1224 0 my $msg = sprintf 'TISTIS %s; %s',
1225 describeLC( $tistisLine, $tistisColumn ),
1226 describeMisindent2( $tistisColumn, $expectedColumn );
1227 0 push @mistakes,
1228 {
1229 desc => $msg,
1230 subpolicy => [ @subpolicy, 'tistis-indent' ],
1231 parentLine => $parentLine,
1232 parentColumn => $parentColumn,
1233 line => $tistisLine,
1234 column => $tistisColumn,
1235 reportLine => $tistisLine,
1236 reportColumn => $tistisColumn,
1237 details => [ ["Starts at $runeLC"] ],
1238 };
1239 }
1240  
1241 18 return \@mistakes;
1242 }
1243  
1244 # SIGGAR/SIGGAL "hints"
1245 0 ▶sub checkBont {
Subroutine checkBont: not called CC=4 SCAR=30.0
Pod undocumented
1246 0 my ( $policy, $node ) = @_;
1247 0 my $instance = $policy->{lint};
1248  
1249 # bont5d ::= CEN4H SYM4K (- DOT GAP -) tall5d
1250 # bont5d ::= wideBont5d
1251 0 my ( $cen, $sym, $dot, $gap, $body ) = @{ $node->{children} };
1252 0 ▶ return if not defined $gap;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $gap 0 0 0
1253  
1254 0 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
1255 0 my ( $bodyLine, $bodyColumn ) = $instance->nodeLC($body);
1256  
1257 # Hint's are an integral part of SIGGAR/SIGGAL which follow a
1258 # basically standard backdenting scheme, so this is not really
1259 # "re-anchoring".
1260 0 my $anchor =
1261 $instance->ancestorByLHS( $node, { tallSiggar => 1, tallSiggal => 1 } );
1262 0 my ( $anchorLine, $anchorColumn ) = $instance->nodeLC($anchor);
1263 0 my $runeName = $policy->runeName($anchor);
1264  
1265 0 my @mistakes = ();
1266  
1267 BODY_ISSUES: {
1268 0 ▶ if ( $parentLine == $bodyLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parentLine == $bodyLine) 0 0 0
1269 0 my $msg =
1270 sprintf 'SIGGAR/SIGGAL hint body must not be on rune line',
1271 describeLC( $bodyLine, $bodyColumn );
1272 0 push @mistakes,
1273 {
1274 desc => $msg,
1275 subpolicy => [ $runeName, 'hint-body-joined' ],
1276 parentLine => $parentLine,
1277 parentColumn => $parentColumn,
1278 line => $bodyLine,
1279 column => $bodyColumn,
1280 reportLine => $bodyLine,
1281 reportColumn => $bodyColumn,
1282 };
1283 0 last BODY_ISSUES;
1284 }
1285  
1286 # If here parent line != body line
1287 0 my $expectedBodyColumn = $anchorColumn + 4;
1288 push @mistakes,
1289 @{
1290 0 $policy->checkOneLineGap(
1291 $gap,
1292 {
1293 mainColumn => $expectedBodyColumn,
1294 subpolicy => [ $runeName, 'hint' ],
1295 runeName => $runeName,
1296 subpolicy => [$runeName],
1297 }
1298 )
1299 };
1300  
1301 0 ▶ if ( $bodyColumn != $expectedBodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyColumn != $expectedBodyColumn) 0 0 0
1302 0 my $msg =
1303 sprintf 'SIGGAL/SIGGAR hint body %s; %s',
1304 describeLC( $bodyLine, $bodyColumn ),
1305 describeMisindent2( $bodyColumn, $expectedBodyColumn );
1306 0 push @mistakes,
1307 {
1308 desc => $msg,
1309 subpolicy => [ $runeName, 'hint-body-indent' ],
1310 parentLine => $parentLine,
1311 parentColumn => $parentColumn,
1312 line => $bodyLine,
1313 column => $bodyColumn,
1314 reportLine => $bodyLine,
1315 reportColumn => $bodyColumn,
1316 };
1317 }
1318 }
1319  
1320 0 return \@mistakes;
1321 }
1322  
1323 # bonz5d ::= (- TIS TIS GAP -) optBonzElements (- GAP TIS TIS -)
1324 # bonz5d ::= wideBonz5d
1325 0 ▶sub checkBonz5d {
Subroutine checkBonz5d: not called CC=3 SCAR=24.8
Pod undocumented
1326 0 my ( $policy, $node ) = @_;
1327 0 my $instance = $policy->{lint};
1328  
1329 0 my ($initialTis1, undef, $gap, $bonzElements, $tistisGap, $finalTistis) = @{$node->{children}};
1330 0 ▶ return [] if not defined $gap;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $gap 0 0 0
1331 0 my $runeName = 'sigcen';
1332 0 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
1333 0 my ( $elementsLine, $elementsColumn ) = $instance->nodeLC($bonzElements);
1334 0 my ( $tistisLine, $tistisColumn ) = $instance->nodeLC($finalTistis);
1335 0 my $anchorColumn = $parentColumn;
1336 0 my $expectedElementsColumn = $anchorColumn + 2;
1337  
1338 0 my @mistakes = ();
1339 push @mistakes,
1340 @{
1341 0 $policy->checkOneLineGap(
1342 $gap,
1343 {
1344 mainColumn => $anchorColumn,
1345 preColumn => $elementsColumn,
1346 runeName => $runeName,
1347 subpolicy => [ $runeName, 'formulas-initial-vgap' ],
1348 }
1349 )
1350 };
1351  
1352 0 ▶ if ( $expectedElementsColumn != $elementsColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expectedElementsColumn != $elementsColumn) 0 0 0
1353  
1354 0 my $msg = sprintf 'formula %s; %s',
1355 describeLC( $elementsLine, $elementsColumn ),
1356 describeMisindent2( $elementsColumn, $expectedElementsColumn );
1357 0 push @mistakes,
1358 {
1359 desc => $msg,
1360 subpolicy => [ $runeName, 'formula-body-indent' ],
1361 parentLine => $parentLine,
1362 parentColumn => $parentColumn,
1363 line => $elementsLine,
1364 column => $elementsColumn,
1365 reportLine => $elementsLine,
1366 reportColumn => $elementsColumn,
1367 };
1368 }
1369  
1370 push @mistakes,
1371 @{
1372 0 $policy->checkOneLineGap(
1373 $tistisGap,
1374 {
1375 mainColumn => $anchorColumn,
1376 preColumn => $elementsColumn,
1377 runeName => $runeName,
1378 subpolicy => [ $runeName, 'formulas-final-gap' ],
1379 topicLines => [$tistisLine],
1380 }
1381 )
1382 };
1383  
1384 push @mistakes,
1385 @{
1386 0 $policy->checkTistis(
1387 $finalTistis,
1388 {
1389 expectedColumn => $anchorColumn,
1390 tag => $runeName,
1391 subpolicy => [ $runeName, 'formulas-final-tistis' ],
1392 }
1393 )
1394 };
1395  
1396 0 return \@mistakes;
1397  
1398 }
1399  
1400 # optBonzElements ::= bonzElement* separator=>GAP proper=>1
1401 # bonzElement ::= CEN SYM4K (- GAP -) tall5d
1402 0 ▶sub checkBonzElements {
Subroutine checkBonzElements: not called CC=2 SCAR=17.9
Pod undocumented
1403 0 my ( $policy, $node ) = @_;
1404 0 my $children = $node->{children};
1405 0 my @nodesToAlign = ();
1406 0 ▶ for (my $childIX = 0; $childIX <= $#$children; $childIX += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($childIX <= $children->$#*) 0 0 0
1407 0 my $element = $children->[$childIX];
1408 0 my ($cen, $sym, $gap, $body) = @{ $element->{children} };
1409 0 push @nodesToAlign, $gap, $body;
1410 }
1411 0 my $alignmentData = $policy->findAlignment( \@nodesToAlign );
1412 0 $policy->setInheritedAttribute($node, 'formulaAlignmentData', $alignmentData);
1413 0 return $policy->checkSeq( $node, 'sigcen-formula' );
1414 }
1415  
1416 0 ▶sub checkBonzElement {
Subroutine checkBonzElement: not called CC=4 SCAR=30.0
Pod undocumented
1417 0 my ( $policy, $node ) = @_;
1418 0 my $instance = $policy->{lint};
1419  
1420 # bonzElement ::= CEN SYM4K (- GAP -) tall5d
1421 0 my ( $bodyGap, $body ) = @{ $policy->gapSeq0($node) };
1422  
1423 0 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
1424 0 my ( $bodyLine, $bodyColumn ) = $instance->nodeLC($body);
1425  
1426 0 my $alignmentData = $policy->getInheritedAttribute($node, 'formulaAlignmentData');
1427 0 my $bodyAlignmentColumn = @{$alignmentData};
1428  
1429 0 my @mistakes = ();
1430 0 my $runeName = 'sigcen';
1431  
1432 BODY_ISSUES: {
1433 0 ▶ if ( $parentLine != $bodyLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parentLine != $bodyLine) 0 0 0
1434 0 my $msg = sprintf 'formula body %s; must be on rune line',
1435 describeLC( $bodyLine, $bodyColumn );
1436 0 push @mistakes,
1437 {
1438 desc => $msg,
1439 subpolicy => [ $runeName, 'formula-split' ],
1440 parentLine => $parentLine,
1441 parentColumn => $parentColumn,
1442 line => $bodyLine,
1443 column => $bodyColumn,
1444 reportLine => $bodyLine,
1445 reportColumn => $bodyColumn,
1446 };
1447 0 last BODY_ISSUES;
1448 }
1449  
1450 # If here, bodyLine == parentLine
1451 0 ▶ last BODY_ISSUES if $bodyColumn = $bodyAlignmentColumn;
Branch: 1 branch
BranchTrueFalseTotal
if $bodyColumn = $bodyAlignmentColumn 0 0 0
1452 0 my $gapLiteral = $instance->literalNode($bodyGap);
1453 0 my $gapLength = $bodyGap->{length};
1454 0 ▶ last BODY_ISSUES if $gapLength == 2;
Branch: 1 branch
BranchTrueFalseTotal
if $gapLength == 2 0 0 0
1455 0 my ( undef, $bodyGapColumn ) = $instance->nodeLC($bodyGap);
1456  
1457 0 my $msg = sprintf 'formula body %s; %s',
1458 describeLC( $bodyLine, $bodyColumn ),
1459 describeMisindent2( $gapLength, 2 );
1460 0 push @mistakes,
1461 {
1462 desc => $msg,
1463 subpolicy => [ $runeName, 'formula-body-indent' ],
1464 parentLine => $parentLine,
1465 parentColumn => $parentColumn,
1466 line => $bodyLine,
1467 column => $bodyColumn,
1468 reportLine => $bodyLine,
1469 reportColumn => $bodyColumn,
1470 };
1471 }
1472  
1473 0 return \@mistakes;
1474 }
1475  
1476 # assumes this is a <tallAttributes> node
1477 0 ▶sub sailAttributeBodyAlignment {
Subroutine sailAttributeBodyAlignment: not called CC=3 SCAR=24.8
Pod undocumented
1478 0 my ( $policy, $node ) = @_;
1479 0 my $instance = $policy->{lint};
1480 0 my $children = $node->{children};
1481 0 my $firstBodyColumn;
1482 0 my %firstLine = ();
1483 0 my %bodyColumnCount = ();
1484 0 my @nodesToAlign = ();
1485  
1486 # Traverse first to last to make it easy to record
1487 # first line of occurrence of each body column
1488 CHILD:
1489 0 ▶ for ( my $childIX = $#$children ; $childIX >= 0 ; $childIX-- ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($childIX >= 0) 0 0 0
1490 0 my $attribute = $children->[$childIX];
1491 0 my ( undef, $head, $gap, $body ) = @{ $policy->gapSeq0($attribute) };
1492 0 my ( $headLine, $headColumn ) = $instance->nodeLC($head);
1493 0 my ( $bodyLine, $bodyColumn ) = $instance->nodeLC($body);
1494 0 ▶ next CHILD if $headLine != $bodyLine;
Branch: 1 branch
BranchTrueFalseTotal
if $headLine != $bodyLine 0 0 0
1495 0 push @nodesToAlign, $gap, $body;
1496 }
1497 0 return $policy->findAlignment( \@nodesToAlign );
1498 }
1499  
1500 0 ▶sub checkSailAttribute {
Subroutine checkSailAttribute: not called CC=6 SCAR=37.4
Pod undocumented
1501 0 my ( $policy, $node ) = @_;
1502 0 my $instance = $policy->{lint};
1503  
1504 0 my ( $headGap, $head, $bodyGap, $body ) = @{ $policy->gapSeq0($node) };
1505  
1506 0 my ( $headLine, $headColumn ) = $instance->nodeLC($head);
1507 0 my ( $bodyLine, $bodyColumn ) = $instance->nodeLC($body);
1508  
1509 0 my $sailApex = $instance->ancestorByLHS( $node, { sailApex5d => 1 } );
1510 0 my ( $sailApexLine, $sailApexColumn ) = $instance->nodeLC($sailApex);
1511 0 my $attributes = $instance->ancestorByLHS( $node, { tallAttributes => 1 } );
1512 0 my $expectedHeadColumn = $sailApexColumn + 4;
1513 0 my ($expectedBodyColumn, $expectBodyColumnDetails) = @{$policy->sailAttributeBodyAlignment($attributes)};
1514  
1515 0 my @mistakes = ();
1516  
1517 # Not really a rune name
1518 0 my $runeName = 'sail';
1519  
1520 # We deal with the elements list in its own node
1521  
1522 push @mistakes,
1523 @{
1524 0 $policy->checkOneLineGap(
1525 $headGap,
1526 {
1527 mainColumn => $expectedHeadColumn,
1528 runeName => $runeName,
1529 subpolicy => [ $runeName, 'head-vgap' ],
1530 topicLines => [$headLine],
1531 }
1532 )
1533 };
1534  
1535 0 ▶ if ( $headColumn != $expectedHeadColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headColumn != $expectedHeadColumn) 0 0 0
1536 0 my $msg = sprintf
1537 "Sail attribute head %s; %s",
1538 describeLC( $headLine, $headColumn ),
1539 describeMisindent2( $headColumn, $expectedHeadColumn );
1540 0 push @mistakes,
1541 {
1542 desc => $msg,
1543 subpolicy => [ $runeName, 'head-indent' ],
1544 parentLine => $sailApexLine,
1545 parentColumn => $sailApexColumn,
1546 line => $headLine,
1547 column => $headColumn,
1548 reportLine => $headLine,
1549 reportColumn => $headColumn,
1550 topicLines => [$headLine],
1551 };
1552 }
1553  
1554 CHECK_BODY: {
1555 0 ▶ if ( $headLine != $bodyLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headLine != $bodyLine) 0 0 0
1556 0 my $msg = sprintf
1557 "Sail split attribute NYI %s",
1558 describeLC( $headLine, $headColumn );
1559 0 push @mistakes,
1560 {
1561 desc => $msg,
1562 subpolicy => [ $runeName, 'split-sail' ],
1563 parentLine => $sailApexLine,
1564 parentColumn => $sailApexColumn,
1565 line => $headLine,
1566 column => $headColumn,
1567 reportLine => $headLine,
1568 reportColumn => $headColumn,
1569 topicLines => [$headLine],
1570 };
1571 0 last CHECK_BODY;
1572 }
1573  
1574 0 my $bodyGapLength = $bodyGap->{length};
1575 CHECK_GAP: {
1576 0 ▶ last CHECK_GAP if $bodyGapLength == 2;
Branch: 1 branch
BranchTrueFalseTotal
if $bodyGapLength == 2 0 0 0
1577 0 ▶ if ( $expectedBodyColumn < 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expectedBodyColumn < 0) 0 0 0
1578 0 my $msg = sprintf
1579 "Sail attribute body %s; %s",
1580 describeLC( $bodyLine, $bodyColumn ),
1581 describeMisindent2( $bodyGapLength, 2 );
1582 0 push @mistakes,
1583 {
1584 desc => $msg,
1585 subpolicy => [ $runeName, 'body-tight-indent' ],
1586 parentLine => $sailApexLine,
1587 parentColumn => $sailApexColumn,
1588 line => $bodyLine,
1589 column => $bodyColumn,
1590 reportLine => $bodyLine,
1591 reportColumn => $bodyColumn,
1592 topicLines => [$bodyLine],
1593 };
1594 0 last CHECK_GAP;
1595 }
1596 0 ▶ if ( $bodyColumn != $expectedBodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyColumn != $expectedBodyColumn) 0 0 0
1597 0 my $msg = sprintf
1598 "Sail attribute body %s; %s",
1599 describeLC( $bodyLine, $bodyColumn ),
1600 describeMisindent2( $bodyColumn, $expectedBodyColumn );
1601 0 push @mistakes,
1602 {
1603 desc => $msg,
1604 subpolicy => [ $runeName, 'body-align-indent' ],
1605 parentLine => $sailApexLine,
1606 parentColumn => $sailApexColumn,
1607 line => $bodyLine,
1608 column => $bodyColumn,
1609 reportLine => $bodyLine,
1610 reportColumn => $bodyColumn,
1611 topicLines => [$bodyLine],
1612 };
1613 }
1614 }
1615 }
1616  
1617 0 return \@mistakes;
1618 }
1619  
1620 # tagged sail statement
1621 0 ▶sub checkTailOfElem {
Subroutine checkTailOfElem: not called CC=2 SCAR=17.9
Pod undocumented
1622 0 my ( $policy, $node ) = @_;
1623 0 my $instance = $policy->{lint};
1624 0 my $lineToPos = $instance->{lineToPos};
1625  
1626 0 my ( $tallKids, $tistisGap, $tistis ) = @{ $node->{children} };
1627 0 ▶ return [] if $instance->symbol($tallKids) ne 'tallKidsOfElem';
Branch: 1 branch
BranchTrueFalseTotal
if $instance->symbol($tallKids) ne "tallKidsOfElem" 0 0 0
1628  
1629 0 my $tallTopSail = $instance->ancestor( $node, 2 );
1630 0 my ( $tallTopSailLine, $tallTopSailColumn ) =
1631 $instance->nodeLC($tallTopSail);
1632 0 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
1633 0 my ( $tistisLine, $tistisColumn ) = $instance->nodeLC($tistis);
1634 0 my $anchorColumn = $policy->getInheritedAttribute($node, 'sailAnchorColumn');
1635  
1636 # There is always a SEM before <tallTopSail> and this is our
1637 # anchor column
1638  
1639 0 my @mistakes = ();
1640 0 my $runeName = 'sail';
1641  
1642 0 my $elementColumn = $anchorColumn + 2;
1643  
1644 push @mistakes,
1645 @{
1646 0 $policy->checkOneLineGap(
1647 $tistisGap,
1648 {
1649 mainColumn => $anchorColumn,
1650 preColumn => $elementColumn,
1651 runeName => $runeName,
1652 subpolicy => [ $runeName, 'elem-tail' ],
1653 topicLines => [$tistisLine],
1654 }
1655 )
1656 };
1657  
1658 push @mistakes,
1659 @{
1660 0 $policy->checkTistis(
1661 $tistis,
1662 {
1663 tag => $runeName,
1664 subpolicy => [ $runeName, 'elem-tail' ],
1665 expectedColumn => $anchorColumn,
1666 }
1667 )
1668 };
1669  
1670 0 return \@mistakes;
1671 }
1672  
1673 0 ▶sub isTopKidsJoined {
Subroutine isTopKidsJoined: not called CC=1 SCAR=6.9
Pod undocumented
1674 0 my ( $policy, $topKids ) = @_;
1675 0 my $instance = $policy->{lint};
1676 0 my ($gapSem, $tallTopKidSeq) = @{ $topKids->{children} };
1677 0 my ( $topKidsLine ) = $instance->nodeLC($topKids);
1678 0 my ( $bodyLine ) = $instance->nodeLC($tallTopKidSeq);
1679 0 return $topKidsLine == $bodyLine;
1680 }
1681  
1682 # tallTailOfTop ::= tallKidsOfTop (- GAP TIS TIS -)
1683 0 ▶sub checkTailOfTop {
Subroutine checkTailOfTop: not called CC=2 SCAR=17.9
Pod undocumented
1684 0 my ( $policy, $node ) = @_;
1685 0 my $instance = $policy->{lint};
1686  
1687 0 my ( $topKids, $tistisGap, $tistis ) = @{ $node->{children} };
1688  
1689 0 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
1690 0 my ( $tistisLine, $tistisColumn ) = $instance->nodeLC($tistis);
1691 0 my $anchorColumn = $policy->getInheritedAttribute($node, 'sailAnchorColumn');
1692 0 my $isJoined = $policy->isTopKidsJoined($topKids);
1693 0 ▶ my $kidColumn = $isJoined ? $anchorColumn + 4 : $anchorColumn + 2;
Branch: 1 branch
BranchTrueFalseTotal
$isJoined ? : 0 0 0
1694  
1695 0 my @mistakes = ();
1696 0 my $runeName = 'sail';
1697  
1698 push @mistakes,
1699 @{
1700 0 $policy->checkOneLineGap(
1701 $tistisGap,
1702 {
1703 mainColumn => $anchorColumn,
1704 preColumn => $kidColumn,
1705 subpolicy => [ $runeName, 'top-tail' ],
1706 runeName => $runeName,
1707 topicLines => [$tistisLine],
1708 }
1709 )
1710 };
1711  
1712 push @mistakes,
1713 @{
1714 0 $policy->checkTistis(
1715 $tistis,
1716 {
1717 tag => $runeName,
1718 subpolicy => [ $runeName, 'top-tail' ],
1719 expectedColumn => $anchorColumn,
1720 }
1721 )
1722 };
1723  
1724 0 return \@mistakes;
1725 }
1726  
1727 # Deals with SEMHEP (;-), SEMLUS (;+), SEMTAR (;*), and SEMCEN (;%).
1728 0 ▶sub checkTopSail {
Subroutine checkTopSail: not called CC=4 SCAR=30.0
Pod undocumented
1729 0 my ( $policy, $node ) = @_;
1730 0 my $instance = $policy->{lint};
1731 0 my $grammar = $instance->{grammar};
1732 0 my $ruleID = $node->{ruleID};
1733 0 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
1734  
1735 0 $policy->setInheritedAttribute($node, 'sailAnchorColumn', $parentColumn - 1);
1736  
1737 # say STDERR "top sail:", '[' . $instance->literalNode($node) . ']';
1738 0 my ($tunaMode, $bodyGap, $body) = @{$node->{children}};
1739 # Note: GAP before CRAM is treated as free-form
1740 0 ▶ return [] if $instance->symbol($tunaMode) ne 'tunaMode';
Branch: 1 branch
BranchTrueFalseTotal
if $instance->symbol($tunaMode) ne "tunaMode" 0 0 0
1741  
1742 0 my ( $bodyLine, $bodyColumn ) = $instance->nodeLC($body);
1743  
1744 0 my @mistakes = ();
1745  
1746 0 my $runeName = 'sail';
1747  
1748 0 my $expectedColumn;
1749  
1750 BODY_ISSUES: {
1751 0 ▶ if ( $parentLine != $bodyLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parentLine != $bodyLine) 0 0 0
1752 my $msg = join " ",
1753 (
1754 sprintf 'Top sail body %s; must be on rune line',
1755 describeLC( $bodyLine, $bodyColumn )
1756 ),
1757 0 ( map { $grammar->symbol_display_form($_) }
1758 $grammar->rule_expand($ruleID) );
1759 0 push @mistakes,
1760 {
1761 desc => $msg,
1762 subpolicy => [ $runeName, 'top-sail', 'split' ],
1763 parentLine => $parentLine,
1764 parentColumn => $parentColumn,
1765 line => $bodyLine,
1766 column => $bodyColumn,
1767 reportLine => $bodyLine,
1768 reportColumn => $bodyColumn,
1769 };
1770 0 last BODY_ISSUES;
1771 }
1772  
1773 # If here, bodyLine == parentLine
1774 0 my $gapLiteral = $instance->literalNode($bodyGap);
1775 0 my $gapLength = $bodyGap->{length};
1776 0 ▶ last BODY_ISSUES if $gapLength == 2;
Branch: 1 branch
BranchTrueFalseTotal
if $gapLength == 2 0 0 0
1777  
1778 0 my $msg = sprintf 'sail runechild %s; %s',
1779 describeLC( $bodyLine, $bodyColumn ),
1780 describeMisindent2( $gapLength, 2 );
1781 0 push @mistakes,
1782 {
1783 desc => $msg,
1784 subpolicy => [ $runeName, 'top-sail', 'indent' ],
1785 parentLine => $parentLine,
1786 parentColumn => $parentColumn,
1787 line => $bodyLine,
1788 column => $bodyColumn,
1789 reportLine => $bodyLine,
1790 reportColumn => $bodyColumn,
1791 };
1792 }
1793  
1794 0 return \@mistakes;
1795 }
1796  
1797 0 ▶sub checkTopKids {
Subroutine checkTopKids: not called CC=8 SCAR=42.8
Pod undocumented
1798 0 my ( $policy, $node ) = @_;
1799 0 my $instance = $policy->{lint};
1800 0 my $grammar = $instance->{grammar};
1801 0 my $ruleID = $node->{ruleID};
1802  
1803 0 my $children = $node->{children};
1804 0 my ($gapSem, $tallTopKidSeq) = @{$children};
1805 0 ▶ return [] if $instance->symbol($tallTopKidSeq) eq 'CRAM';
Branch: 1 branch
BranchTrueFalseTotal
if $instance->symbol($tallTopKidSeq) eq "CRAM" 0 0 0
1806 # Note: GAP before CRAM is treated as free-form
1807  
1808 0 my $anchorColumn = $policy->getInheritedAttribute($node, 'sailAnchorColumn');
1809 0 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
1810 0 my ( $bodyLine, $bodyColumn ) = $instance->nodeLC($tallTopKidSeq);
1811 0 $bodyColumn -= 1; # adjust for SEM in GAP_SEM
1812  
1813 0 my @mistakes = ();
1814  
1815 0 my $runeName = 'sail';
1816 0 my $isJoined = $parentLine == $bodyLine;
1817 0 ▶ my $expectedBodyColumn = $isJoined ? $anchorColumn + 4 : $anchorColumn + 2;
Branch: 1 branch
BranchTrueFalseTotal
$isJoined ? : 0 0 0
1818 0 my $topSail = $instance->ancestorByLHS( $node, { tallTopSail => 1 } );
1819 0 $policy->setInheritedAttribute($topSail, 'sailIsJoined', $isJoined);
1820  
1821 FIRST_KID_ISSUES: {
1822 0 ▶ if ( not $isJoined ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($isJoined) 0 0 0
1823 push @mistakes,
1824 @{
1825 0 $policy->checkOneLineGap(
1826 $gapSem,
1827 {
1828 mainColumn => $anchorColumn,
1829 preColumn => $expectedBodyColumn,
1830 runeName => $runeName,
1831 subpolicy => [$runeName],
1832 details => [
1833 [
1834 ( sprintf 'sail elem kid #1' ),
1835 'inter-comment indent should be '
1836 . ( $anchorColumn + 1 ),
1837 'pre-comment indent should be '
1838 . ( $expectedBodyColumn + 1 ),
1839 ]
1840 ],
1841 }
1842 )
1843 };
1844  
1845 0 ▶ if ( $expectedBodyColumn != $bodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expectedBodyColumn != $bodyColumn) 0 0 0
1846 0 my $msg = sprintf 'Sail elem kid #1 body %s; %s',
1847 describeLC( $bodyLine, $bodyColumn ),
1848 describeMisindent2( $bodyColumn, $expectedBodyColumn );
1849 0 push @mistakes,
1850 {
1851 desc => $msg,
1852 subpolicy => [ $runeName, 'elem-kids', 'body-indent' ],
1853 parentLine => $parentLine,
1854 parentColumn => $parentColumn,
1855 line => $bodyLine,
1856 column => $bodyColumn,
1857 reportLine => $bodyLine,
1858 reportColumn => $bodyColumn,
1859 };
1860 }
1861 0 last FIRST_KID_ISSUES;
1862 }
1863  
1864 # If here, bodyLine == parentLine
1865 0 my $gapLiteral = $instance->literalNode($gapSem);
1866 0 my $gapLength = $gapSem->{length};
1867 0 ▶ last FIRST_KID_ISSUES if $gapLength == 3; # length is 3 to allow for SEM in GAP_SEM
Branch: 1 branch
BranchTrueFalseTotal
if $gapLength == 3 0 0 0
1868 0 my ( undef, $gapSemColumn ) = $instance->nodeLC($gapSem);
1869  
1870 0 my $msg = sprintf 'Sail kids body %s; %s',
1871 describeLC( $bodyLine, $bodyColumn ),
1872 describeMisindent2( $gapLength, 2 );
1873 0 push @mistakes,
1874 {
1875 desc => $msg,
1876 subpolicy => [ $runeName, 'top-kids', 'body-indent' ],
1877 parentLine => $parentLine,
1878 parentColumn => $parentColumn,
1879 line => $bodyLine,
1880 column => $bodyColumn,
1881 reportLine => $bodyLine,
1882 reportColumn => $bodyColumn,
1883 };
1884 }
1885  
1886 # tallTopKidSeq ::= tallTopSail+ separator=>GAP_SEM proper=>1
1887 0 my $kids = $tallTopKidSeq->{children};
1888 # say STDERR join " ", __FILE__, __LINE__, $instance->symbol($tallTopKidSeq),
1889 # describeLC($instance->nodeLC($node));
1890 # say STDERR join " ", __FILE__, __LINE__, $instance->symbol($tallTopKidSeq),
1891 # "top kids:", ( scalar @{$kids} );
1892 0 my $childIX = 0;
1893 0 ▶ KID: for (my $childIX = 1; $childIX + 1 <= $#$kids; $childIX+=2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($childIX + 1 <= $kids->$#*) 0 0 0
1894 0 my $kidGap = $kids->[$childIX];
1895 0 my $kid = $kids->[$childIX+1];
1896 0 my ( $kidLine, $kidColumn ) = $instance->nodeLC($kid);
1897 0 $kidColumn -= 1; # adjust for SEM in GAP_SEM
1898  
1899 0 my $kidNumber = ($childIX + 1)/2;
1900 # say STDERR join " ", __FILE__, __LINE__, 'kid of top [' . $instance->literalNode($kid) . ']';
1901 push @mistakes,
1902 @{
1903 0 $policy->checkOneLineGap(
1904 $kidGap,
1905 {
1906 mainColumn => $anchorColumn,
1907 preColumn => $expectedBodyColumn,
1908 runeName => $runeName,
1909 subpolicy => [$runeName],
1910 details => [
1911 [
1912 ( sprintf 'sail elem kid #%d', $kidNumber),
1913 'inter-comment indent should be '
1914 . ( $anchorColumn + 1 ),
1915 'pre-comment indent should be '
1916 . ( $expectedBodyColumn + 1 ),
1917 ]
1918 ],
1919 }
1920 )
1921 };
1922  
1923 0 ▶ if ( $expectedBodyColumn != $bodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expectedBodyColumn != $bodyColumn) 0 0 0
1924 0 my $msg = sprintf 'Sail elem kid #%d body %s; %s',
1925 $kidNumber,
1926 describeLC( $bodyLine, $bodyColumn ),
1927 describeMisindent2( $bodyColumn, $expectedBodyColumn );
1928 0 push @mistakes,
1929 {
1930 desc => $msg,
1931 subpolicy => [ $runeName, 'elem-kids', 'body-indent' ],
1932 parentLine => $parentLine,
1933 parentColumn => $parentColumn,
1934 line => $kidLine,
1935 column => $kidColumn,
1936 reportLine => $kidLine,
1937 reportColumn => $kidColumn,
1938 };
1939 }
1940 }
1941  
1942 0 return \@mistakes;
1943 }
1944  
1945 0 ▶sub checkElemKids {
Subroutine checkElemKids: not called CC=4 SCAR=30.0
Pod undocumented
1946 0 my ( $policy, $node ) = @_;
1947 0 my $instance = $policy->{lint};
1948 0 my $grammar = $instance->{grammar};
1949 0 my $ruleID = $node->{ruleID};
1950  
1951 0 my $children = $node->{children};
1952 0 my ( $gapSem, $tallElemKidSeq ) = @{$children};
1953 0 ▶ return [] if $instance->symbol($gapSem) ne 'GAP_SEM';
Branch: 1 branch
BranchTrueFalseTotal
if $instance->symbol($gapSem) ne "GAP_SEM" 0 0 0
1954  
1955 0 my ( $bodyGap, $body ) = @{ $policy->gapSeq0($node) };
1956  
1957 0 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
1958 0 my $anchorColumn = $policy->getInheritedAttribute($node, 'sailAnchorColumn');
1959 0 my ( $bodyLine, $bodyColumn ) = $instance->nodeLC($body);
1960  
1961 0 my @mistakes = ();
1962  
1963 0 my $runeName = 'sail';
1964  
1965 # tallKidsOfElem ::= tallKidOfElem+
1966 # tallKidOfElem ::= (- GAP_SEM -) tallTopSail
1967 0 my $kids = $tallElemKidSeq->{children};
1968 0 my $expectedKidColumn = $anchorColumn + 2;
1969 0 ▶ KID: for ( my $childIX = 0 ; $childIX + 1 <= $#$kids ; $childIX += 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($childIX + 1 <= $kids->$#*) 0 0 0
1970 # say STDERR join " ", __FILE__, __LINE__, $childIX;
1971 0 my $kidGap = $kids->[$childIX];
1972 0 my $kidBody = $kids->[ $childIX + 1 ];
1973 0 my ( $kidBodyLine, $kidBodyColumn ) = $instance->nodeLC($kidBody);
1974 0 $kidBodyColumn -= 1; # Adjust for SEM in GAP_SEM
1975  
1976 # say STDERR join " ", __FILE__, __LINE__, "kidBodyColumn: $kidBodyColumn";
1977 # say STDERR join " ", __FILE__, __LINE__, "anchorColumn: $anchorColumn";
1978 # say STDERR join " ", __FILE__, __LINE__, "$childIX: [" . $instance->symbol($kidBody) . ']';
1979 # say STDERR join " ", __FILE__, __LINE__, "$childIX: [" . $instance->literalNode($kidBody) . ']';
1980  
1981 push @mistakes,
1982 @{
1983 0 $policy->checkOneLineGap(
1984 $kidGap,
1985 {
1986 mainColumn => $anchorColumn,
1987 preColumn => $expectedKidColumn,
1988 runeName => $runeName,
1989 subpolicy => [$runeName],
1990 details => [
1991 [
1992 ( sprintf 'sail elem kid #%d', $childIX ),
1993 'inter-comment indent should be '
1994 . ( $anchorColumn + 1 ),
1995 'pre-comment indent should be '
1996 . ( $kidBodyColumn + 1 ),
1997 ]
1998 ],
1999 }
2000 )
2001 };
2002  
2003 0 ▶ if ( $expectedKidColumn != $kidBodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expectedKidColumn != $kidBodyColumn) 0 0 0
2004 0 my $msg = sprintf 'Sail elem kid #%d body %s; %s',
2005 $childIX,
2006 describeLC( $kidBodyLine, $kidBodyColumn ),
2007 describeMisindent2( $kidBodyColumn, $expectedKidColumn );
2008 0 push @mistakes,
2009 {
2010 desc => $msg,
2011 subpolicy => [ $runeName, 'elem-kids', 'body-indent' ],
2012 parentLine => $parentLine,
2013 parentColumn => $parentColumn,
2014 line => $kidBodyLine,
2015 column => $kidBodyColumn,
2016 reportLine => $kidBodyLine,
2017 reportColumn => $kidBodyColumn,
2018 };
2019 }
2020  
2021 }
2022  
2023 0 return \@mistakes;
2024 }
2025  
2026 # Common logic for checking the running element of a hoon.
2027 # returns a (possibly empty) list of mistakes.
2028 #
2029 # TODO: Some of these arguments can (should?) be computed from others.
2030 #
2031 12 ▶sub checkRunning {
Subroutine checkRunning: called CC=33 SCAR=53.2
Pod undocumented
2032 12 my ( $policy, $options ) = @_;
2033 12 my $instance = $policy->{lint};
2034 12 my $runningChildren = $options->{children};
2035 12 my $anchorColumn = $options->{anchorColumn};
2036 12 my $expectedColumn = $options->{expectedColumn};
2037 12 my $pseudojoin = $options->{pseudojoin};
2038  
2039 12 my @subpolicy = ();
2040 12 my $subpolicy = $options->{subpolicy};
2041 12 ▶ push @subpolicy, @{$subpolicy} if defined $subpolicy;
Branch: 1 branch
BranchTrueFalseTotal
if defined $subpolicy 12 0 12
2042  
2043 # by default, in fact always at this point, the running can be
2044 # found as the parent of the last running child, and the parent
2045 # can be found as the parent
2046 12 my $running = $runningChildren->[-1]->{PARENT};
2047 12 my $parent = $running->{PARENT};
2048  
2049 12 my ( $runeLine, $runeColumn ) = $instance->nodeLC($parent);
2050 12 my ( $runningLine, $runningColumn ) = $instance->nodeLC($running);
2051  
2052 my $anchorDetails = $options->{anchorDetails}
2053 12 ▶ // $policy->anchorDetailsBasic( $parent, $anchorColumn );
Condition33%1/3
$options->{"anchorDetails"} // $policy->anchorDetailsBasic($parent, $anchorColumn)
l!l&&r!l&&!r
0120
MC/DC0%0/2
$options->{"anchorDetails"} // $policy->anchorDetailsBasic($parent, $anchorColumn)
$options->{"anchorDetails"} $policy->anchorDetailsBasic($parent, $anchorColumn)
Truth table33%1/3
A // B
A= $options->{"anchorDetails"}B= $policy->anchorDetailsBasic($parent, $anchorColumn)
ABresult
1X1
011
000
2054  
2055 12 my $runeName = $policy->runeName($parent);
2056 12 my @mistakes = ();
2057  
2058 12 my $skipFirst = $options->{skipFirst};
2059 12 ▶ my $childIX = $skipFirst ? 3 : 2;
Branch: 1 branch
BranchTrueFalseTotal
$skipFirst ? : 0 12 12
2060  
2061 # Call an column of runsteps with the same row
2062 # position a "pile" because "column" and the other terms are
2063 # too overloaded.
2064 12 my @runStepsToAlignByPile = ();
2065 12 RUNNING_LINE: while (1) {
2066  
2067 # The index into the runstep alignment array.
2068 # The alignment of the 2nd runstep
2069 # in a row (or line) is at index 0.
2070 30 my $pileIX = 0;
2071 30 RUNSTEP: while (1) {
2072 30 ▶ last RUNNING_LINE if $childIX + 1 > $#$runningChildren;
Branch: 1 branch
BranchTrueFalseTotal
if $childIX + 1 > $runningChildren->$#* 12 18 30
2073 18 my $gap = $runningChildren->[$childIX];
2074 18 my $runStep = $runningChildren->[ $childIX + 1 ];
2075 18 my ($gapLine) = $instance->nodeLC($gap);
2076 18 my ( $runStepLine, $runStepColumn ) = $instance->nodeLC($runStep);
2077 18 ▶ last RUNSTEP if $gapLine != $runStepLine;
Branch: 1 branch
BranchTrueFalseTotal
if $gapLine != $runStepLine 18 0 18
2078  
2079 # Uses Perl's autoinstantiation
2080 0 push @{ $runStepsToAlignByPile[$pileIX] }, $gap, $runStep;
2081 0 $pileIX += 1;
2082 0 $childIX += 2;
2083 }
2084  
2085 # In this loop, childIX always points to a gap
2086 18 $childIX += 2;
2087 }
2088  
2089 12 my @pileAlignments = ();
2090 ELEMENT:
2091 12 ▶ for ( my $pileIX = 0 ; $pileIX <= $#runStepsToAlignByPile ; $pileIX++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pileIX <= $#runStepsToAlignByPile) 0 12 12
2092 0 my $runStepsToAlign = $runStepsToAlignByPile[$pileIX];
2093 0 ▶ if ( not $runStepsToAlign ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($runStepsToAlign) 0 0 0
2094 0 $pileAlignments[$pileIX] = [ -1, [] ];
2095 0 next ELEMENT;
2096 }
2097 0 $pileAlignments[$pileIX] =
2098 $policy->findAlignment($runStepsToAlign);
2099 }
2100  
2101 # If there are no alignments by runstep, then we check for
2102 # alignments among the running's children.
2103 12 my @nodesToAlignByElement;
2104 RUNNING_CHILD_ALIGNMENTS: {
2105 12 ▶ last RUNNING_CHILD_ALIGNMENTS if scalar @pileAlignments;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @pileAlignments 0 12 12
2106 12 my @bricks;
2107 RUNSTEP:
2108 12 ▶ for (
Branch: 2 branches
BranchTrueFalseTotal
$skipFirst ? : 0 12 12
if ($runStepIX <= $runningChildren->$#*) 30 12 42
2109 my $runStepIX = ( $skipFirst ? 2 : 1 ) ;
2110 $runStepIX <= $#$runningChildren ;
2111 $runStepIX += 2
2112 )
2113 {
2114 30 my $runStep = $runningChildren->[$runStepIX];
2115  
2116 30 my $brickDescendant = $instance->brickDescendant($runStep);
2117 30 ▶ last RUNSTEP if not $brickDescendant;
Branch: 1 branch
BranchTrueFalseTotal
unless $brickDescendant 0 30 30
2118  
2119 30 $instance->literalNode($brickDescendant);
2120 30 ▶ next RUNSTEP if not $policy->chainable($brickDescendant);
Branch: 1 branch
BranchTrueFalseTotal
unless $policy->chainable($brickDescendant) 30 0 30
2121  
2122 0 push @bricks, $brickDescendant;
2123 0 $instance->literalNode($brickDescendant);
2124 0 my $gapSeq = $policy->gapSeq0($brickDescendant);
2125 0 BRICK_ELEMENT: for ( my $elementIX = 0 ; ; $elementIX++ ) {
2126 0 my $seqIX = $elementIX * 2;
2127 0 ▶ last BRICK_ELEMENT if $seqIX >= $#$gapSeq;
Branch: 1 branch
BranchTrueFalseTotal
if $seqIX >= $gapSeq->$#* 0 0 0
2128 0 my $gap = $gapSeq->[$seqIX];
2129 0 my $element = $gapSeq->[ $seqIX + 1 ];
2130 0 push @{ $nodesToAlignByElement[$elementIX] }, $gap, $element;
2131 }
2132 }
2133  
2134 12 ▶ last RUNNING_CHILD_ALIGNMENTS unless scalar @nodesToAlignByElement;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @nodesToAlignByElement 12 0 12
2135  
2136 0 my @runStepChildAlignments = ();
2137 ELEMENT:
2138 0 ▶ for (
Branch: 1 branch
BranchTrueFalseTotal
if ($elementIX <= $#nodesToAlignByElement) 0 0 0
2139 my $elementIX = 0 ;
2140 $elementIX <= $#nodesToAlignByElement ;
2141 $elementIX++
2142 )
2143 {
2144 0 my $nodesToAlign = $nodesToAlignByElement[$elementIX];
2145 0 ▶ if ( not $nodesToAlign ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($nodesToAlign) 0 0 0
2146 0 $runStepChildAlignments[$elementIX] = [ -1, [] ];
2147 0 next ELEMENT;
2148 }
2149 0 $runStepChildAlignments[$elementIX] =
2150 $policy->findAlignment($nodesToAlign);
2151 }
2152  
2153  
2154 0 for my $brick (@bricks) {
2155 0 my $brickNodeIX = $brick->{IX};
2156 $policy->{perNode}->{$brickNodeIX}->{runningAlignments} =
2157 0 \@runStepChildAlignments;
2158 }
2159  
2160 }
2161  
2162 12 $childIX = 0;
2163 # Do the first run step
2164 12 my $gap = $runningChildren->[$childIX];
2165 12 my ( $gapLine, $gapColumn ) = $instance->nodeLC($gap);
2166 12 my $runStep = $runningChildren->[ $childIX + 1 ];
2167 12 my ( $thisRunStepLine, $runStepColumn ) = $instance->nodeLC($runStep);
2168  
2169 12 my $runStepCount = 1;
2170 CHECK_FIRST_RUNNING: {
2171 12 ▶ last CHECK_FIRST_RUNNING if $skipFirst;
Branch: 1 branch
BranchTrueFalseTotal
if $skipFirst 0 12 12
2172 12 ▶ last CHECK_FIRST_RUNNING if $runStepColumn == $expectedColumn;
Branch: 1 branch
BranchTrueFalseTotal
if $runStepColumn == $expectedColumn 12 0 12
2173 0 my @pseudojoin = ();
2174 0 ▶ push @pseudojoin, 'pseudojoin' if $pseudojoin;
Branch: 1 branch
BranchTrueFalseTotal
if $pseudojoin 0 0 0
2175 0 my $msg = sprintf
2176 "runstep #%d %s; %s",
2177 $runStepCount,
2178 describeLC( $thisRunStepLine, $runStepColumn ),
2179 describeMisindent2( $runStepColumn, $expectedColumn );
2180 push @mistakes,
2181 {
2182 desc => $msg,
2183 subpolicy => [ @subpolicy, 'runstep-indent' ],
2184 parentLine => $thisRunStepLine,
2185 parentColumn => $runStepColumn,
2186 line => $thisRunStepLine,
2187 column => $runStepColumn,
2188 reportLine => $thisRunStepLine,
2189 reportColumn => $runStepColumn,
2190 topicLines => [$runeLine],
2191 0 details => [ [ @pseudojoin, @{$anchorDetails} ] ],
2192 };
2193 }
2194  
2195 12 my $workingRunStepLine = $thisRunStepLine;
2196  
2197 # Initial runsteps may be on a single line,
2198 # separated by one stop
2199 12 $childIX = 2;
2200 12 $runStepCount = 2;
2201 12 ▶ RUN_STEP: while ( $childIX < $#$runningChildren ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($childIX < $runningChildren->$#*) 18 12 30
2202  
2203 18 my ( $thisRunStepLine, $runStepColumn ) ;
2204  
2205 18 INLINE_RUN_STEP: while (1) {
2206 18 ▶ if ( $childIX >= $#$runningChildren ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($childIX >= $runningChildren->$#*) 0 18 18
2207 0 last RUN_STEP;
2208 }
2209 18 $gap = $runningChildren->[$childIX];
2210 18 ( $gapLine, $gapColumn ) = $instance->nodeLC($gap);
2211 18 $runStep = $runningChildren->[ $childIX + 1 ];
2212 18 ( $thisRunStepLine, $runStepColumn ) = $instance->nodeLC($runStep);
2213 18 ▶ if ( $thisRunStepLine != $workingRunStepLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($thisRunStepLine != $workingRunStepLine) 18 0 18
2214 18 last INLINE_RUN_STEP;
2215 }
2216 CHECK_COLUMN: {
2217 0 my $tightColumn = $gapColumn + 2;
2218 0 ▶ last CHECK_COLUMN if $runStepColumn == $tightColumn;
Branch: 1 branch
BranchTrueFalseTotal
if $runStepColumn == $tightColumn 0 0 0
2219 0 my @allowedColumns =([ $tightColumn => 'tight' ]);
2220  
2221 0 my ( $pileAlignmentColumn, $pileAlignmentLines );
2222 0 my $thisAlignment = $pileAlignments[ $runStepCount - 2 ];
2223 0 ▶ if ($thisAlignment) {
Branch: 1 branch
BranchTrueFalseTotal
if ($thisAlignment) 0 0 0
2224 0 ( $pileAlignmentColumn, $pileAlignmentLines ) = @{$thisAlignment};
2225 0 ▶ last CHECK_COLUMN if $pileAlignmentColumn > $tightColumn
Branch: 1 branch
BranchTrueFalseTotal
if $pileAlignmentColumn > $tightColumn and $pileAlignmentColumn == $runStepColumn 0 0 0
Condition0%0/3
$pileAlignmentColumn > $tightColumn and $pileAlignmentColumn == $runStepColumn
!ll&&!rl&&r
000
MC/DC0%0/2
$pileAlignmentColumn > $tightColumn and $pileAlignmentColumn == $runStepColumn
$pileAlignmentColumn > $tightColumn $pileAlignmentColumn == $runStepColumn
Truth table0%0/3
A and B
A= $pileAlignmentColumn > $tightColumnB= $pileAlignmentColumn == $runStepColumn
ABresult
0X0
100
111
2226 and $pileAlignmentColumn == $runStepColumn;
2227 }
2228  
2229 0 my $details;
2230 0 my @topicLines = ();
2231 0 ▶ if (defined $pileAlignmentColumn and $pileAlignmentColumn >= $tightColumn) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pileAlignmentColumn and $pileAlignmentColumn >= $tightColumn) { } 0 0 0
Condition0%0/3
defined $pileAlignmentColumn and $pileAlignmentColumn >= $tightColumn
!ll&&!rl&&r
000
MC/DC0%0/2
defined $pileAlignmentColumn and $pileAlignmentColumn >= $tightColumn
defined $pileAlignmentColumn $pileAlignmentColumn >= $tightColumn
Truth table0%0/3
A and B
A= defined $pileAlignmentColumnB= $pileAlignmentColumn >= $tightColumn
ABresult
0X0
100
111
2232 0 push @allowedColumns, [ $pileAlignmentColumn => 'runstep' ];
2233 0 my $oneBasedColumn = $pileAlignmentColumn + 1;
2234 0 my $pileAlignmentLines = $pileAlignmentLines;
2235 0 push @topicLines, @{$pileAlignmentLines};
2236 $details = [
2237 [
2238 sprintf 'runstep alignment is %d, see %s',
2239 $oneBasedColumn,
2240 (
2241 join q{ },
2242 0 map { $_ . ':' . $oneBasedColumn }
2243 0 @{$pileAlignmentLines}
2244 )
2245 ]
2246 ];
2247 }
2248 else {
2249 0 $details = [ [ "no runstep alignment detected" ] ];
2250 }
2251  
2252 0 my @sortedColumns = sort { $a->[0] <=> $b->[0] } @allowedColumns;
2253 my $allowedDesc = join "; ",
2254 0 map { sprintf '@%d:%d (%s)', $thisRunStepLine, $_->[0]+1, $_->[1] } @sortedColumns;
2255 0 ▶ if (scalar @sortedColumns >= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @sortedColumns >= 2) 0 0 0
2256 0 $allowedDesc = 'one of ' . $allowedDesc;
2257 }
2258  
2259 0 my $msg = sprintf
2260 'runstep #%d of running %s, line %d is at %s; should be %s',
2261 $runStepCount,
2262 describeLC( $runeLine, $runeColumn ),
2263 $thisRunStepLine,
2264 describeLC( $thisRunStepLine, $runStepColumn ),
2265 $allowedDesc;
2266 0 push @mistakes,
2267 {
2268 desc => $msg,
2269 subpolicy => [ @subpolicy, 'runstep-hgap' ],
2270 parentLine => $runeLine,
2271 parentColumn => $runeColumn,
2272 line => $thisRunStepLine,
2273 column => $runStepColumn,
2274 reportLine => $thisRunStepLine,
2275 reportColumn => $runStepColumn,
2276 topicLines => \@topicLines,
2277 details => $details,
2278 };
2279 }
2280 0 $childIX += 2;
2281 0 $runStepCount++;
2282 }
2283  
2284 18 $workingRunStepLine = $thisRunStepLine;
2285  
2286 # If the run step is mis-indented, complaints about the comments are
2287 # misleading and confusing. Skip them.
2288 # TODO: Complain about blank lines anyway ?
2289 18 ▶ if ( $runStepColumn == $expectedColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($runStepColumn == $expectedColumn) 18 0 18
2290 push @mistakes,
2291 @{
2292 18 $policy->checkOneLineGap(
2293 $gap,
2294 {
2295 mainColumn => $anchorColumn,
2296 preColumn => $runStepColumn,
2297 runeName => $runeName,
2298 subpolicy => [ @subpolicy, 'runstep-vgap' ],
2299 parent => $runStep,
2300 topicLines => [$runeLine],
2301 details => [
2302 [
2303 'inter-comment indent should be '
2304 . ( $anchorColumn + 1 ),
2305 'pre-comment indent should be '
2306 . ( $expectedColumn + 1 ),
2307 18 @{$anchorDetails},
2308 ]
2309 ],
2310 }
2311 )
2312 };
2313 }
2314  
2315 18 ▶ if ( $runStepColumn != $expectedColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($runStepColumn != $expectedColumn) 0 18 18
2316 0 my $msg = sprintf
2317 "runstep #%d %s; %s",
2318 ( $childIX / 2 ) + 1,
2319 describeLC( $thisRunStepLine, $runStepColumn ),
2320 describeMisindent2( $runStepColumn, $expectedColumn );
2321 push @mistakes,
2322 {
2323 desc => $msg,
2324 subpolicy => [ @subpolicy, 'runstep-indent' ],
2325 parentLine => $thisRunStepLine,
2326 parentColumn => $runStepColumn,
2327 line => $thisRunStepLine,
2328 column => $runStepColumn,
2329 reportLine => $thisRunStepLine,
2330 reportColumn => $runStepColumn,
2331 topicLines => [$runeLine],
2332 0 details => [ [ @{$anchorDetails} ] ],
2333 };
2334 }
2335  
2336 18 $childIX += 2;
2337 18 $runStepCount = 2;
2338  
2339 }
2340  
2341 12 return \@mistakes;
2342  
2343 }
2344  
2345 12 ▶sub check_0Running {
Subroutine check_0Running: called CC=9 SCAR=26.3
Pod undocumented
2346 12 my ( $policy, $node ) = @_;
2347 12 my $instance = $policy->{lint};
2348 12 my ( $rune, $runningGap, $tistisGap, $tistis );
2349 12 my $runeName = $policy->runeName($node);
2350 12 my $runningChildren = [];
2351 12 my ( $runningLine, $runningColumn );
2352 {
2353 12 my $running;
2354 12 ▶ if ($runeName eq 'tissig') {
Branch: 1 branch
BranchTrueFalseTotal
if ($runeName eq 'tissig') { } 0 12 12
2355 0 my ( $firstRunstep, $firstRunningGap );
2356 ( $rune, $runningGap, $firstRunstep, $firstRunningGap, $running, $tistisGap, $tistis ) =
2357 0 @{ $policy->gapSeq($node) };
2358 0 push @{$runningChildren}, $runningGap, $firstRunstep, $firstRunningGap;
2359 0 ( $runningLine, $runningColumn ) = $instance->nodeLC($firstRunstep);
2360 } else {
2361 ( $rune, $runningGap, $running, $tistisGap, $tistis ) =
2362 12 @{ $policy->gapSeq($node) };
2363 12 push @{$runningChildren}, $runningGap;
2364 12 ( $runningLine, $runningColumn ) = $instance->nodeLC($running);
2365 }
2366 12 push @{$runningChildren}, @{ $running->{children} };
2367 }
2368  
2369 12 my ( $runeLine, $runeColumn ) = $instance->nodeLC($rune);
2370 12 my ( $anchorLine, $anchorColumn ) = ( $runeLine, $runeColumn );
2371 12 my $anchorData;
2372 CHECK_FOR_ANCHORING: {
2373 12 ▶ if ( $runeName eq 'colsig' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($runeName eq "colsig") 0 12 12
2374  
2375 0 ( $anchorColumn, $anchorData ) = $policy->reanchorInc(
2376 $node,
2377 {
2378 'tallCendot' => 1,
2379 'tallCenhep' => 1,
2380 'tallCenlus' => 1,
2381 'tallCollus' => 1,
2382 'tallKethep' => 1,
2383 'tallTisfas' => 1,
2384 'tallTisgar' => 1,
2385 }
2386 );
2387 0 last CHECK_FOR_ANCHORING;
2388 }
2389 12 ▶ if ( $runeName eq 'coltar' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($runeName eq "coltar") 0 12 12
2390  
2391 # TODO: Cleanup after development
2392 0 ( $anchorColumn, $anchorData ) = $policy->reanchorInc(
2393 $node,
2394 {
2395 'tallCenhep' => 1,
2396 }
2397 );
2398 0 last CHECK_FOR_ANCHORING;
2399 }
2400 12 ▶ if ( $runeName eq 'tissig' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($runeName eq "tissig") 0 12 12
2401 0 ( $anchorColumn, $anchorData ) = $policy->reanchorInc(
2402 $node,
2403 {
2404 'tallTisgar' => 1,
2405 'tallWutlus' => 1,
2406 }
2407 );
2408 0 last CHECK_FOR_ANCHORING;
2409 }
2410 }
2411 12 my $anchorDetails;
2412 12 ▶ $anchorDetails = $policy->anchorDetails( $node, $anchorData )
Branch: 1 branch
BranchTrueFalseTotal
if $anchorData 0 12 12
2413 if $anchorData;
2414  
2415 # Arguments for the checking methods, called by this method.
2416 12 my $checkArgs = {
2417 node => $node,
2418 rune => $rune,
2419 runningGap => $runningGap,
2420 runningChildren => $runningChildren,
2421 tistisGap => $tistisGap,
2422 tistis => $tistis,
2423 runningLine => $runningLine,
2424 runningColumn => $runningColumn,
2425 runeName => $runeName,
2426 anchorLine => $anchorLine,
2427 anchorColumn => $anchorColumn,
2428 anchorDetails => $anchorDetails,
2429 };
2430  
2431 # What kind of gap?
2432 12 my $column = $policy->checkJoinGap($runningGap);
2433  
2434 # If column is undef, then hoon is not joined, it is split.
2435 12 ▶ return $policy->checkSplit_0Running( $checkArgs ) if not defined $column;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $column 0 12 12
2436  
2437 # If column is -1, then hoon is joined.
2438 12 ▶ return $policy->checkJoined_0Running( $checkArgs, $column ) if $column == -1;
Branch: 1 branch
BranchTrueFalseTotal
if $column == -1 12 0 12
2439  
2440 # If here, it is a pseudo-join and $column is the column indicated
2441 # by gap.
2442 0 $checkArgs->{pseudojoin} = 1;
2443  
2444 # Treat it as a pseudo-join if $column matches the expected join colum
2445 0 ▶ return $policy->checkJoined_0Running( $checkArgs, $column )
Branch: 1 branch
BranchTrueFalseTotal
if $column == $runeColumn + 4 0 0 0
2446 if $column == $runeColumn + 4;
2447  
2448 # If here the pseudo-join column is a mismatch: Treat the supposed
2449 # pseudo-join as an ordinary comment and the running as if it was
2450 # split.
2451 0 return $policy->checkSplit_0Running( $checkArgs );
2452 }
2453  
2454 # assumes this is a <wisp5d> node
2455 # wisp5d ::= (- HEP HEP -)
2456 # wisp5d ::= whap5d GAP (- HEP HEP -)
2457 21 ▶sub wispCellBodyAlignment {
Subroutine wispCellBodyAlignment: called CC=2 SCAR=7.0
Pod undocumented
2458 21 my ( $policy, $node ) = @_;
2459 21 my $instance = $policy->{lint};
2460 21 my ($whap) = @{ $node->{children} };
2461 21 ▶ return [ -1, [] ]
Branch: 1 branch
BranchTrueFalseTotal
if "whap5d" ne $instance->symbol($whap) 0 21 21
2462 if 'whap5d' ne $instance->symbol($whap);
2463 21 return $policy->whapCellBodyAlignment($whap);
2464 }
2465  
2466 # assumes this is a <whap5d> node
2467 21 ▶sub whapCellBodyAlignment {
Subroutine whapCellBodyAlignment: called CC=3 SCAR=11.0
Pod undocumented
2468 21 my ( $policy, $node ) = @_;
2469 21 my $instance = $policy->{lint};
2470 21 my $children = $node->{children};
2471 21 my @nodesToAlign = ();
2472  
2473 CHILD:
2474 21 ▶ for ( my $childIX = 0 ; $childIX <= $#$children ; $childIX += 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($childIX <= $children->$#*) 69 21 90
2475 69 my $boog = $children->[$childIX];
2476 69 my $cell = $boog->{children}->[0];
2477 69 my ( undef, $head, $gap, $body ) = @{ $policy->gapSeq0($cell) };
2478 69 my ( $headLine ) = $instance->nodeLC($head);
2479 69 my ( $bodyLine ) = $instance->nodeLC($body);
2480 69 ▶ next CHILD unless $headLine == $bodyLine;
Branch: 1 branch
BranchTrueFalseTotal
unless $headLine == $bodyLine 27 42 69
2481 # say STDERR sprintf q{Gap: "%s"}, $instance->literalNode($gap);
2482 # say STDERR sprintf q{Body: "%s"}, $instance->literalNode($body);
2483 42 push @nodesToAlign, $gap, $body;
2484 }
2485 21 return $policy->findAlignment( \@nodesToAlign );
2486 }
2487  
2488 21 ▶sub checkWhap5d {
Subroutine checkWhap5d: called CC=7 SCAR=20.0
Pod undocumented
2489 21 my ( $policy, $node ) = @_;
2490 21 my $gapSeq = $policy->gapSeq($node);
2491 21 my $instance = $policy->{lint};
2492  
2493 21 my @mistakes = ();
2494 21 my $runeName = $policy->runeName($node);
2495  
2496 21 my $anchorNode = $instance->firstBrickOfLine($node);
2497 21 my ( $anchorLine, $anchorColumn ) = $instance->nodeLC($anchorNode);
2498 21 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
2499  
2500 # The battery is "joined" iff it starts on the same line as the anchor,
2501 # but at a different column. "Different column" to catch the case where
2502 # the anchor rune *is* the battery rune.
2503 21 ▶ my $joined =
Condition33%1/3
$anchorLine == $parentLine && $anchorColumn != $parentColumn
!ll&&!rl&&r
0210
MC/DC0%0/2
$anchorLine == $parentLine && $anchorColumn != $parentColumn
$anchorLine == $parentLine $anchorColumn != $parentColumn
Truth table33%1/3
A && B
A= $anchorLine == $parentLineB= $anchorColumn != $parentColumn
ABresult
0X0
100
111
2504 ( $anchorLine == $parentLine and $anchorColumn != $parentColumn );
2505 21 my $children = $node->{children};
2506 21 my $childIX = 0;
2507 21 ▶ my $expectedBoogColumn = $joined ? $parentColumn : $anchorColumn;
Branch: 1 branch
BranchTrueFalseTotal
$joined ? : 0 21 21
2508 21 ▶ my $expectedLine = $joined ? $parentLine : $anchorLine + 1;
Branch: 1 branch
BranchTrueFalseTotal
$joined ? : 0 21 21
2509  
2510 21 ▶ CHILD: while ( $childIX <= $#$children ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($childIX <= $children->$#*) 69 0 69
2511 69 my $boog = $children->[$childIX];
2512 69 my ( $boogLine, $boogColumn ) = $instance->nodeLC($boog);
2513  
2514 69 ▶ if ( $boogColumn != $expectedBoogColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($boogColumn != $expectedBoogColumn) 0 69 69
2515 0 my $msg = sprintf
2516 "cell #%d %s; %s",
2517 ( $childIX / 2 ) + 1,
2518 describeLC( $boogLine, $boogColumn ),
2519 describeMisindent2( $boogColumn, $expectedBoogColumn );
2520 0 push @mistakes,
2521 {
2522 desc => $msg,
2523 subpolicy => [$runeName, 'arm-indent'],
2524 parentLine => $boogLine,
2525 parentColumn => $boogColumn,
2526 line => $boogLine,
2527 column => $boogColumn,
2528 reportLine => $boogLine,
2529 reportColumn => $boogColumn,
2530 topicLines => [ $parentLine, $expectedLine ],
2531 };
2532 }
2533  
2534 69 $childIX++;
2535 69 ▶ last CHILD unless $childIX <= $#$children;
Branch: 1 branch
BranchTrueFalseTotal
unless $childIX <= $children->$#* 21 48 69
2536 48 my $boogGap = $children->[$childIX];
2537 48 my ( $boogGapLine, $boogGapColumn ) = $instance->nodeLC($boogGap);
2538  
2539 push @mistakes,
2540 @{
2541 48 $policy->checkOneLineGap(
2542 $boogGap,
2543 {
2544 mainColumn => $expectedBoogColumn,
2545 preColumn => $expectedBoogColumn+2,
2546 runeName => $runeName,
2547 subpolicy => [$runeName, 'arm-vgap'],
2548 topicLines => [ $parentLine, $boogGapLine ],
2549 }
2550 )
2551 };
2552  
2553 48 $childIX++;
2554 }
2555  
2556 21 return \@mistakes;
2557  
2558 }
2559  
2560 # wisp5d ::= (- HEP HEP -)
2561 # wisp5d ::= whap5d GAP (- HEP HEP -)
2562 21 ▶sub checkWisp5d {
Subroutine checkWisp5d: called CC=6 SCAR=19.3
Pod undocumented
2563 21 my ( $policy, $node ) = @_;
2564 21 my @mistakes = ();
2565 21 my $instance = $policy->{lint};
2566 21 my $runeName = $policy->runeName($node);
2567 21 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
2568  
2569 21 my $battery =
2570 $instance->ancestorByLHS( $node,
2571 { tallBarcab => 1, tallBarcen => 1, tallBarket => 1 } );
2572 21 my ( $batteryLine, $batteryColumn ) = $instance->nodeLC($battery);
2573 21 my $batteryLC = describeLC($batteryLine, $batteryColumn);
2574  
2575 21 my $anchorColumn = $policy->getInheritedAttribute($node, 'anchorColumn');
2576 21 ▶ $anchorColumn //= $batteryColumn;
Condition33%1/3
$anchorColumn //= $batteryColumn
l!l&&r!l&&!r
2100
MC/DC0%0/2
$anchorColumn //= $batteryColumn
$anchorColumn $batteryColumn
Truth table33%1/3
A //= B
A= $anchorColumnB= $batteryColumn
ABresult
1X1
011
000
2577  
2578 my ( $cellBodyColumn, $cellBodyColumnLines ) =
2579 21 @{ $policy->getInheritedAttribute($node, 'cellBodyAlignmentData') };
2580  
2581 21 my ( $whap, $gap, $hep ) = @{$node->{children}};
2582 21 ▶ return [] if $instance->symbol($whap) ne 'whap5d';
Branch: 1 branch
BranchTrueFalseTotal
if $instance->symbol($whap) ne "whap5d" 0 21 21
2583  
2584 push @mistakes,
2585 @{
2586 21 $policy->checkOneLineGap(
2587 $gap,
2588 {
2589 mainColumn => $parentColumn,
2590 preColumn => $anchorColumn+2,
2591 runeName => $runeName,
2592 subpolicy => [$runeName],
2593 topicLines => [$batteryLine],
2594 details => [ [ "Starts at $batteryLC", ] ],
2595 }
2596 )
2597 };
2598  
2599 21 my ( $hephepLine, $hephepColumn ) = $instance->nodeLC($hep);
2600  
2601 {
2602 21 my $literalLine = $instance->literalLine($hephepLine);
2603 21 $literalLine = $policy->deComment($literalLine);
2604 21 $literalLine =~ s/\n//g;
2605 21 $literalLine =~ s/--//g;
2606 21 ▶ if ( $literalLine =~ m/[^ ]/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($literalLine =~ /[^ ]/) 0 21 21
2607 0 my $msg =
2608 sprintf q{HEPHEP %s should only share line with other HEPHEP's},
2609 describeLC( $hephepLine, $hephepColumn );
2610 0 push @mistakes,
2611 {
2612 desc => $msg,
2613 subpolicy => [ $runeName, 'hephep-alone' ],
2614 parentLine => $parentLine,
2615 parentColumn => $parentColumn,
2616 line => $hephepLine,
2617 column => $hephepColumn,
2618 reportLine => $hephepLine,
2619 reportColumn => $hephepColumn,
2620 details => [ [ "Starts at $batteryLC", ] ],
2621 };
2622 }
2623 }
2624  
2625 21 my $expectedColumn = $anchorColumn;
2626 21 my $hephepIsMisaligned = $hephepColumn != $expectedColumn;
2627  
2628 21 ▶ if ($hephepIsMisaligned) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hephepIsMisaligned) 0 21 21
2629 0 my $lineToPos = $instance->{lineToPos};
2630 0 my $hephepPos = $lineToPos->[$hephepLine] + $expectedColumn;
2631 0 my $hephepLiteral = $instance->literal( $hephepPos, 2 );
2632 0 $hephepIsMisaligned = $hephepLiteral ne '--';
2633 }
2634 21 ▶ if ($hephepIsMisaligned) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hephepIsMisaligned) 0 21 21
2635 0 my $msg = sprintf
2636 'battery hephep %s; %s',
2637 describeLC( $hephepLine, $hephepColumn ),
2638 describeMisindent2( $hephepColumn, $expectedColumn );
2639 0 push @mistakes,
2640 {
2641 desc => $msg,
2642 subpolicy => [ $runeName, 'hephep-indent' ],
2643 parentLine => $parentLine,
2644 parentColumn => $parentColumn,
2645 line => $hephepLine,
2646 column => $hephepColumn,
2647 reportLine => $hephepLine,
2648 reportColumn => $hephepColumn,
2649 topicLines => [$batteryLine],
2650 details => [ [ "Starts at $batteryLC", ] ],
2651 };
2652 }
2653 21 return \@mistakes;
2654 }
2655  
2656 0 ▶sub checkSplitFascom {
Subroutine checkSplitFascom: not called CC=3 SCAR=24.8
Pod undocumented
2657 0 my ( $policy, $node ) = @_;
2658 0 my $instance = $policy->{lint};
2659 0 my $lineToPos = $instance->{lineToPos};
2660  
2661 # say STDERR join " ", __FILE__, __LINE__, $instance->literalNode($node);
2662 my ( $bodyGap, $body, $tistisGap, $tistis ) =
2663 0 @{ $policy->gapSeq0($node) };
2664  
2665 0 my ( $runeLine, $runeColumn ) = $instance->nodeLC($node);
2666 0 my ( $bodyLine, $bodyColumn ) = $instance->nodeLC($body);
2667 0 my ( $tistisLine, $tistisColumn ) = $instance->nodeLC($tistis);
2668  
2669 0 my $anchorLine = $runeLine;
2670 0 my ( $anchorColumn, $anchorData ) = $policy->reanchorInc(
2671 $node,
2672 {
2673 fordFascen => 1,
2674 }
2675 );
2676 0 my $anchorDetails = $policy->anchorDetails( $node, $anchorData );
2677  
2678 0 my $nodeIX = $node->{IX};
2679 0 my $chessSide = $policy->{perNode}->{$nodeIX}->{chessSide};
2680 0 my $queenside = $chessSide eq 'queenside';
2681 # say STDERR join " ", __FILE__, __LINE__, $chessSide;
2682  
2683 0 my @mistakes = ();
2684 0 my $runeName = $policy->runeName($node);
2685 0 my $tag = $runeName;
2686  
2687 # We deal with the elements list itself,
2688 # in its own node
2689  
2690 0 ▶ my $expectedColumn = $anchorColumn + $queenside ? 4 : 2;
Branch: 1 branch
BranchTrueFalseTotal
$anchorColumn + $queenside ? : 0 0 0
2691 0 my $expectedLine = $runeLine + 1;
2692  
2693 # say STDERR join " ", __FILE__, __LINE__, $chessSide, $expectedColumn;
2694  
2695 push @mistakes,
2696 @{
2697 0 $policy->checkOneLineGap(
2698 $bodyGap,
2699 {
2700 mainColumn => $anchorColumn,
2701 runeName => $tag,
2702 subpolicy => [ $runeName ],
2703 topicLines => [$bodyLine],
2704 }
2705 )
2706 };
2707  
2708 0 ▶ if ( $bodyColumn != $expectedColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyColumn != $expectedColumn) 0 0 0
2709 0 my $msg = sprintf
2710 "split %s %s; %s",
2711 $runeName,
2712 describeLC( $bodyLine, $bodyColumn ),
2713 describeMisindent2( $bodyColumn, $expectedColumn );
2714 push @mistakes,
2715 {
2716 desc => $msg,
2717 subpolicy => [ $runeName, 'body-indent' ],
2718 parentLine => $runeLine,
2719 parentColumn => $runeColumn,
2720 line => $bodyLine,
2721 column => $bodyColumn,
2722 reportLine => $bodyLine,
2723 reportColumn => $bodyColumn,
2724 topicLines => [ $runeLine, $expectedLine ],
2725 0 details => [ [ @{$anchorDetails} ] ],
2726 };
2727 }
2728  
2729 push @mistakes,
2730 @{
2731 0 $policy->checkOneLineGap(
2732 $tistisGap,
2733 {
2734 mainColumn => $anchorColumn,
2735 runeName => $tag,
2736 subpolicy => [ $runeName ],
2737 topicLines => [ $anchorLine, $tistisLine ],
2738 0 details => [ [ @{$anchorDetails} ] ],
2739 }
2740 )
2741 };
2742  
2743 push @mistakes,
2744 @{
2745 0 $policy->checkTistis(
2746 $tistis,
2747 {
2748 tag => $tag,
2749 expectedColumn => $anchorColumn,
2750 }
2751 )
2752 };
2753  
2754 0 return \@mistakes;
2755 }
2756  
2757 0 ▶sub checkJoinedFascom {
Subroutine checkJoinedFascom: not called CC=2 SCAR=17.9
Pod undocumented
2758 0 my ( $policy, $node ) = @_;
2759 0 my $instance = $policy->{lint};
2760 0 my $lineToPos = $instance->{lineToPos};
2761  
2762 0 my ( $bodyGap, $body, $tistisGap, $tistis ) = @{ $policy->gapSeq0($node) };
2763  
2764 0 my ( $runeLine, $runeColumn ) = $instance->nodeLC($node);
2765 0 my ( $bodyLine, $bodyColumn ) = $instance->nodeLC($body);
2766 0 my ( $tistisLine, $tistisColumn ) = $instance->nodeLC($tistis);
2767 0 my ( $anchorLine, $anchorColumn ) = ( $runeLine, $runeColumn );
2768  
2769 0 my $nodeIX = $node->{IX};
2770  
2771 # Joined FASCOM is always considered queenside.
2772  
2773 0 my @mistakes = ();
2774 0 my $runeName = $policy->runeName($node);
2775 0 my $tag = $runeName;
2776  
2777 # We deal with the elements list in its own node
2778  
2779 0 my $expectedColumn = $anchorColumn + 4;
2780 0 my $expectedLine = $runeLine + 1;
2781  
2782 0 ▶ if ( $bodyColumn != $expectedColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyColumn != $expectedColumn) 0 0 0
2783 0 my $msg = sprintf
2784 "joined %s %s; %s",
2785 $runeName,
2786 describeLC( $bodyLine, $bodyColumn ),
2787 describeMisindent2( $bodyColumn, $expectedColumn );
2788 0 push @mistakes,
2789 {
2790 desc => $msg,
2791 subpolicy => [ $runeName, 'body-indent' ],
2792 parentLine => $runeLine,
2793 parentColumn => $runeColumn,
2794 line => $bodyLine,
2795 column => $bodyColumn,
2796 reportLine => $bodyLine,
2797 reportColumn => $bodyColumn,
2798 topicLines => [ $runeLine, $expectedLine ],
2799 };
2800 }
2801  
2802 push @mistakes,
2803 @{
2804 0 $policy->checkOneLineGap(
2805 $tistisGap,
2806 {
2807 mainColumn => $anchorColumn,
2808 runeName => $tag,
2809 subpolicy => [ $runeName ],
2810 topicLines => [ $runeLine, $tistisLine ],
2811 }
2812 )
2813 };
2814  
2815 push @mistakes,
2816 @{
2817 0 $policy->checkTistis(
2818 $tistis,
2819 {
2820 tag => $tag,
2821 expectedColumn => $anchorColumn,
2822 }
2823 )
2824 };
2825  
2826 0 return \@mistakes;
2827 }
2828  
2829 0 ▶sub checkFascom {
Subroutine checkFascom: not called CC=4 SCAR=30.0
Pod undocumented
2830 0 my ( $policy, $node ) = @_;
2831 0 my $instance = $policy->{lint};
2832 # say STDERR join " ", __FILE__, __LINE__, $instance->literalNode($node);
2833 0 my ( undef, $elements ) = @{ $policy->gapSeq0($node) };
2834  
2835 0 my ($runeLine, $runeColumn) = $instance->nodeLC($node);
2836 0 my ($elementsLine) = $instance->nodeLC($elements);
2837  
2838 0 my $anchorLine = $runeLine;
2839 0 my ( $anchorColumn, $anchorData ) = $policy->reanchorInc(
2840 $node,
2841 {
2842 fordFascen => 1,
2843 }
2844 );
2845 0 my $anchorDetails = $policy->anchorDetails( $node, $anchorData );
2846  
2847 0 ▶ my $isJoined = $elementsLine == $runeLine ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$elementsLine == $runeLine ? : 0 0 0
2848 0 my $chessSide;
2849 # Joined FASCOM's are always considered queenside
2850 0 ▶ if ($isJoined) {
Branch: 1 branch
BranchTrueFalseTotal
if ($isJoined) { } 0 0 0
2851 0 $chessSide = 'queenside';
2852 } else {
2853 0 $chessSide = $policy->chessSideOfPairSequence($elements, $anchorColumn);
2854 }
2855  
2856 0 my $nodeIX = $node->{IX};
2857 0 $policy->{perNode}->{$nodeIX}->{isJoined} = $isJoined;
2858 0 $policy->{perNode}->{$nodeIX}->{chessSide} = $chessSide;
2859  
2860 0 ▶ return checkJoinedFascom( $policy, $node ) if $isJoined;
Branch: 1 branch
BranchTrueFalseTotal
if $isJoined 0 0 0
2861 0 return checkSplitFascom( $policy, $node );
2862 }
2863  
2864 0 ▶sub checkFascomElements {
Subroutine checkFascomElements: not called CC=7 SCAR=40.3
Pod undocumented
2865 0 my ( $policy, $node ) = @_;
2866 0 my $instance = $policy->{lint};
2867 0 my $children = $node->{children};
2868  
2869 # say STDERR join " ", __FILE__, __LINE__, 'elements', $instance->literalNode($node);
2870 0 my $rune = $instance->ancestorByBrickName( $node, 'fordFascom' );
2871 0 my $runeNodeIX = $rune->{IX};
2872 0 my $isJoined = $policy->{perNode}->{$runeNodeIX}->{isJoined};
2873 0 my $chessSide = $policy->{perNode}->{$runeNodeIX}->{chessSide};
2874 0 my $queenside = $chessSide eq 'queenside';
2875  
2876 0 my ( $runeLine, $runeColumn ) = $instance->nodeLC($rune);
2877 0 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
2878  
2879 0 my $anchorLine = $runeLine;
2880 0 my ( $anchorColumn, $anchorData ) = $policy->reanchorInc(
2881 $rune,
2882 {
2883 fordFascen => 1,
2884 }
2885 );
2886 0 my $anchorDetails = $policy->anchorDetails( $node, $anchorData );
2887  
2888 0 my @mistakes = ();
2889 0 my $tag = 'fascom-elements';
2890  
2891 0 my $childIX = 0;
2892 0 ▶ my $expectedColumn = $anchorColumn + ($queenside ? 4 : 2);
Branch: 1 branch
BranchTrueFalseTotal
$queenside ? : 0 0 0
2893 0 ▶ CHILD: while ( $childIX <= $#$children ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($childIX <= $children->$#*) 0 0 0
2894 0 my $element = $children->[$childIX];
2895 0 my ( $elementLine, $elementColumn ) = $instance->nodeLC($element);
2896 # say STDERR join " ", __FILE__, __LINE__, "element head #$childIX", $instance->literalNode($element);
2897 # say STDERR join " ", __FILE__, __LINE__, "element head #$childIX", 'actual v expected', $elementColumn, $expectedColumn ;
2898  
2899 CHECK_HEAD: {
2900 0 ▶ if ( $isJoined and $childIX == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($isJoined and $childIX == 0) 0 0 0
Condition0%0/3
$isJoined and $childIX == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$isJoined and $childIX == 0
$isJoined $childIX == 0
Truth table0%0/3
A and B
A= $isJoinedB= $childIX == 0
ABresult
0X0
100
111
2901 0 $expectedColumn = $elementColumn;
2902 0 last CHECK_HEAD;
2903 }
2904  
2905 0 ▶ if ( $elementColumn != $expectedColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($elementColumn != $expectedColumn) 0 0 0
2906 0 my $msg = sprintf
2907 "element %d %s; %s",
2908 ( $childIX / 2 ) + 1,
2909 describeLC( $elementLine, $elementColumn ),
2910 describeMisindent2( $elementColumn, $expectedColumn );
2911 push @mistakes,
2912 {
2913 desc => $msg,
2914 0 details => [ [ @{$anchorDetails} ] ],
2915 subpolicy => [ $tag, 'indent' ],
2916 parentLine => $parentLine,
2917 parentColumn => $parentColumn,
2918 line => $elementLine,
2919 column => $elementColumn,
2920 reportLine => $elementLine,
2921 reportColumn => $elementColumn,
2922 topicLines => [$runeLine],
2923 };
2924 }
2925 }
2926  
2927 0 $childIX++;
2928 0 ▶ last CHILD unless $childIX <= $#$children;
Branch: 1 branch
BranchTrueFalseTotal
unless $childIX <= $children->$#* 0 0 0
2929 0 my $elementGap = $children->[$childIX];
2930 0 my ( $elementGapLine, $elementGapColumn ) =
2931 $instance->nodeLC($elementGap);
2932  
2933 push @mistakes,
2934 @{
2935 0 $policy->checkOneLineGap(
2936 $elementGap,
2937 {
2938 mainColumn => $anchorColumn,
2939 preColumn => $expectedColumn,
2940 runeName => $tag,
2941 subpolicy => [ $tag ],
2942 topicLines => [$runeLine],
2943 0 details => [ [ @{$anchorDetails} ] ],
2944 }
2945 )
2946 };
2947  
2948 0 $childIX++;
2949 }
2950  
2951 0 return \@mistakes;
2952 }
2953  
2954 0 ▶sub checkFasdot {
Subroutine checkFasdot: not called CC=3 SCAR=24.8
Pod undocumented
2955 0 my ( $policy, $node ) = @_;
2956 0 my $instance = $policy->{lint};
2957  
2958 0 my ( $bodyGap, $body, $tistisGap, $tistis ) = @{ $policy->gapSeq0($node) };
2959  
2960 0 my ( $runeLine, $runeColumn ) = $instance->nodeLC($node);
2961 0 my ( $bodyLine, $bodyColumn ) = $instance->nodeLC($body);
2962 0 my ( $tistisLine, $tistisColumn ) = $instance->nodeLC($tistis);
2963  
2964 0 my @mistakes = ();
2965 0 my $runeName = $policy->runeName($node);
2966 0 my $tag = $runeName;
2967  
2968 # We deal with the elements list in its own node
2969  
2970 0 my $expectedColumn = $runeColumn + 4;
2971  
2972 CHECK_BODY: {
2973 0 ▶ if ( $bodyLine != $runeLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyLine != $runeLine) 0 0 0
2974 0 my $msg = sprintf
2975 "%s %s; body must be on rune line",
2976 $runeName, describeLC( $bodyLine, $bodyColumn );
2977 0 push @mistakes,
2978 {
2979 desc => $msg,
2980 subpolicy => [ $runeName, 'body-split' ],
2981 parentLine => $runeLine,
2982 parentColumn => $runeColumn,
2983 line => $bodyLine,
2984 column => $bodyColumn,
2985 reportLine => $bodyLine,
2986 reportColumn => $bodyColumn,
2987 topicLines => [$runeLine],
2988 };
2989 0 last CHECK_BODY;
2990 }
2991  
2992 0 ▶ if ( $bodyColumn != $expectedColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyColumn != $expectedColumn) 0 0 0
2993 0 my $msg = sprintf
2994 "joined %s %s; %s",
2995 $runeName,
2996 describeLC( $bodyLine, $bodyColumn ),
2997 describeMisindent2( $bodyColumn, $expectedColumn );
2998 0 push @mistakes,
2999 {
3000 desc => $msg,
3001 subpolicy => [ $runeName, 'body-indent' ],
3002 parentLine => $runeLine,
3003 parentColumn => $runeColumn,
3004 line => $bodyLine,
3005 column => $bodyColumn,
3006 reportLine => $bodyLine,
3007 reportColumn => $bodyColumn,
3008 topicLines => [$runeLine],
3009 };
3010 }
3011 }
3012  
3013 push @mistakes,
3014 @{
3015 0 $policy->checkOneLineGap(
3016 $tistisGap,
3017 {
3018 mainColumn => $runeColumn,
3019 runeName => $tag,
3020 subpolicy => [$runeName],
3021 topicLines => [ $runeLine, $tistisLine ],
3022 }
3023 )
3024 };
3025  
3026 push @mistakes,
3027 @{
3028 0 $policy->checkTistis(
3029 $tistis,
3030 {
3031 tag => $tag,
3032 expectedColumn => $runeColumn,
3033 }
3034 )
3035 };
3036  
3037 0 return \@mistakes;
3038 }
3039  
3040 6 ▶sub checkJogging {
Subroutine checkJogging: called CC=2 SCAR=6.9
Pod undocumented
3041 6 my ( $policy, $node ) = @_;
3042 6 my $instance = $policy->{lint};
3043 6 my $children = $node->{children};
3044 6 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
3045  
3046 6 my $joggingHoonData = $policy->getInheritedAttribute($node, 'joggingHoonData');
3047 6 my $jogBaseColumn = $joggingHoonData->{jogBaseColumn};
3048 6 my $chessSide = $joggingHoonData->{chessSide};
3049 6 my $joggingHoonNode = $joggingHoonData->{node};
3050 6 my ( $anchorLine, $anchorColumn ) = $instance->nodeLC($joggingHoonNode);
3051 6 my $runeName = $policy->runeName($joggingHoonNode);
3052  
3053 6 my @mistakes = ();
3054  
3055 6 my $expectedColumn = $parentColumn;
3056 6 ▶ CHILD: for ( my $childIX = 1; $childIX <= $#$children; $childIX+=2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($childIX <= $children->$#*) 9 6 15
3057 9 my $jogGap = $children->[$childIX];
3058 9 my ( $jogGapLine, $jogGapColumn ) =
3059 $instance->nodeLC($jogGap);
3060  
3061 push @mistakes,
3062 @{
3063 9 $policy->checkOneLineGap(
3064 $jogGap,
3065 {
3066 mainColumn => $anchorColumn,
3067 preColumn => $jogBaseColumn,
3068 runeName => $runeName,
3069 subpolicy => [ $runeName, 'jogging' ],
3070 topicLines => [$jogGapLine],
3071 }
3072 )
3073 };
3074  
3075 }
3076  
3077 6 return \@mistakes;
3078  
3079 }
3080  
3081 # Check "vanilla" sequence
3082 0 ▶sub checkSeq {
Subroutine checkSeq: not called CC=5 SCAR=34.0
Pod undocumented
3083 0 my ( $policy, $node, $elementDesc ) = @_;
3084 0 my $instance = $policy->{lint};
3085 0 my $children = $node->{children};
3086  
3087 0 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
3088  
3089 0 my $brick = $instance->brickNode($node);
3090 0 ▶ my $runeName = $brick ? $policy->runeName($brick) : 'fordfile';
Branch: 1 branch
BranchTrueFalseTotal
$brick ? : 0 0 0
3091  
3092 0 my @mistakes = ();
3093  
3094 0 my $childIX = 0;
3095 0 my $expectedColumn = $parentColumn;
3096 0 ▶ CHILD: while ( $childIX <= $#$children ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($childIX <= $children->$#*) 0 0 0
3097 0 my $element = $children->[$childIX];
3098 0 my ( $elementLine, $elementColumn ) = $instance->nodeLC($element);
3099  
3100 0 ▶ if ( $elementColumn != $expectedColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($elementColumn != $expectedColumn) 0 0 0
3101 0 my $msg = sprintf
3102 '%s %d %s; %s',
3103 $runeName,
3104 ( $childIX / 2 ) + 1,
3105 describeLC( $elementLine, $elementColumn ),
3106 describeMisindent2( $elementColumn, $expectedColumn );
3107 0 push @mistakes,
3108 {
3109 desc => $msg,
3110 subpolicy => [ $runeName, 'sequence-element-indent' ],
3111 parentLine => $parentLine,
3112 parentColumn => $parentColumn,
3113 line => $elementLine,
3114 column => $elementColumn,
3115 reportLine => $elementLine,
3116 reportColumn => $elementColumn,
3117 details => [ [ $elementDesc] ],
3118 };
3119 }
3120  
3121 0 $childIX++;
3122 0 ▶ last CHILD unless $childIX <= $#$children;
Branch: 1 branch
BranchTrueFalseTotal
unless $childIX <= $children->$#* 0 0 0
3123 0 my $elementGap = $children->[$childIX];
3124 0 my ( $elementGapLine, $elementGapColumn ) =
3125 $instance->nodeLC($elementGap);
3126  
3127 push @mistakes,
3128 @{
3129 0 $policy->checkOneLineGap(
3130 $elementGap,
3131 {
3132 mainColumn => $expectedColumn,
3133 runeName => $runeName,
3134 subpolicy => [ $runeName, 'sequence-vgap' ],
3135 details => [ [ $elementDesc] ],
3136 topicLines => [$elementGapLine],
3137 }
3138 )
3139 };
3140  
3141 0 $childIX++;
3142 }
3143  
3144 0 return \@mistakes;
3145  
3146 }
3147  
3148 # tallBarcab ::= (- BAR CAB GAP -) till5d (- GAP -) wasp5d wisp5d
3149 9 ▶sub checkBarcab {
Subroutine checkBarcab: called CC=6 SCAR=22.3
Pod undocumented
3150 9 my ( $policy, $node ) = @_;
3151 9 my $instance = $policy->{lint};
3152  
3153 # TODO: reanchoring logic, memoize anchorColumn for checkWisp5d()
3154  
3155 # BARCAB is special, so we need to find the components using low-level
3156 # techniques.
3157 # tallBarcab ::= (- BAR CAB GAP -) till5d (- GAP -) wasp5d wisp5d
3158 my ( undef, undef, $headGap, $head, $wispGap, undef, $wisp ) =
3159 9 @{ $node->{children} };
3160 9 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
3161 9 my $anchorNode = $node;
3162 9 my ( $anchorLine, $anchorColumn ) = $instance->nodeLC($anchorNode);
3163 9 my ( $headLine, $headColumn ) = $instance->nodeLC($head);
3164 9 my ( $wispLine, $wispColumn ) = $instance->nodeLC($wisp);
3165  
3166 9 $policy->setInheritedAttribute( $node, 'anchorColumn', $anchorColumn );
3167  
3168 9 my $cellBodyAlignmentData = $policy->wispCellBodyAlignment($wisp);
3169 9 $policy->setInheritedAttribute( $node, 'cellBodyAlignmentData',
3170 $cellBodyAlignmentData );
3171  
3172 9 my @mistakes = ();
3173 9 my $runeName = 'barcab';
3174  
3175 9 my $expectedColumn;
3176  
3177 HEAD_ISSUES: {
3178 9 ▶ if ( $parentLine != $headLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parentLine != $headLine) 0 9 9
3179 0 my $pseudojoinColumn = $policy->pseudojoinColumn($headGap);
3180 0 ▶ if ( $pseudojoinColumn <= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pseudojoinColumn <= 0) 0 0 0
3181 0 my $msg = sprintf 'Barcab head %s; must be on rune line',
3182 describeLC( $headLine, $headColumn );
3183 0 push @mistakes,
3184 {
3185 desc => $msg,
3186 subpolicy => [ $runeName, 'head-split' ],
3187 parentLine => $parentLine,
3188 parentColumn => $parentColumn,
3189 line => $headLine,
3190 column => $headColumn,
3191 reportLine => $headLine,
3192 reportColumn => $headColumn,
3193 };
3194 0 last HEAD_ISSUES;
3195 }
3196 0 my $expectedHeadColumn = $pseudojoinColumn;
3197 0 ▶ if ( $headColumn != $expectedHeadColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headColumn != $expectedHeadColumn) 0 0 0
3198 0 my $msg =
3199 sprintf
3200 'Pseudo-joined BARCEN head; head/comment mismatch; head is %s',
3201 describeLC( $headLine, $headColumn ),
3202 describeMisindent2( $headColumn, $expectedHeadColumn );
3203 0 push @mistakes,
3204 {
3205 desc => $msg,
3206 subpolicy => [ $runeName, 'head-pseudojoin-mismatch' ],
3207 parentLine => $parentLine,
3208 parentColumn => $parentColumn,
3209 reportLine => $headLine,
3210 reportColumn => $headColumn,
3211 };
3212 }
3213 0 last HEAD_ISSUES;
3214 }
3215  
3216 # If here, headLine == runeLine
3217 9 my $gapLiteral = $instance->literalNode($headGap);
3218 9 my $gapLength = $headGap->{length};
3219 9 ▶ last HEAD_ISSUES if $gapLength == 2;
Branch: 1 branch
BranchTrueFalseTotal
if $gapLength == 2 9 0 9
3220 0 my ( undef, $headGapColumn ) = $instance->nodeLC($headGap);
3221  
3222 0 my $msg = sprintf 'Barcab head %s; %s',
3223 describeLC( $headLine, $headColumn ),
3224 describeMisindent2( $gapLength, 2 );
3225 0 push @mistakes,
3226 {
3227 desc => $msg,
3228 subpolicy => [ $runeName, 'head-hgap' ],
3229 parentLine => $parentLine,
3230 parentColumn => $parentColumn,
3231 line => $headLine,
3232 column => $headColumn,
3233 reportLine => $headLine,
3234 reportColumn => $headColumn,
3235 };
3236  
3237 }
3238  
3239 9 $expectedColumn = $anchorColumn;
3240 push @mistakes,
3241 @{
3242 9 $policy->checkOneLineGap(
3243 $wispGap,
3244 {
3245 mainColumn => $anchorColumn,
3246 preColumn => $anchorColumn + 2,
3247 runeName => $runeName,
3248 subpolicy => [ $runeName, 'battery-vgap' ],
3249 topicLines => [$wispLine],
3250 }
3251 )
3252 };
3253  
3254 9 ▶ if ( $wispColumn != $expectedColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wispColumn != $expectedColumn) 0 9 9
3255 0 my $msg = sprintf 'Barcab battery %s; %s',
3256 describeLC( $wispLine, $wispColumn ),
3257 describeMisindent2( $wispColumn, $expectedColumn );
3258 0 push @mistakes,
3259 {
3260 desc => $msg,
3261 subpolicy => [ $runeName, 'battery-indent' ],
3262 parentLine => $parentLine,
3263 parentColumn => $parentColumn,
3264 line => $wispLine,
3265 column => $wispColumn,
3266 reportLine => $wispLine,
3267 reportColumn => $wispColumn,
3268 };
3269 0 return \@mistakes;
3270 }
3271  
3272 9 return \@mistakes;
3273 }
3274  
3275 # tallBarcen ::= (- BAR CEN GAP -) wisp5d
3276 12 ▶sub checkBarcen {
Subroutine checkBarcen: called CC=4 SCAR=15.1
Pod undocumented
3277 12 my ( $policy, $node ) = @_;
3278 12 my ( $rune, undef, $gap, $wisp ) = @{ $node->{children} };
3279 12 my $wispNodeIX = $wisp->{IX};
3280 12 my $instance = $policy->{lint};
3281 12 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
3282 12 my ( $anchorColumn, $anchorData ) = $policy->reanchorInc(
3283 $node,
3284 {
3285 # LustisCell => 1, # should NOT reanchor at Lustis
3286 # LushepCell => 1, # should NOT reanchor at Lushep
3287 # LuslusCell => 1, # should NOT reanchor at Luslus, per experiment
3288 # Reanchor at TISGAR would make sense in a lot of places in arvo corpus,
3289 # would not work in toe.hoon
3290 # tallTisgar => 1,
3291 tallKetbar => 1,
3292 tallKetwut => 1,
3293 }
3294 );
3295 12 $policy->setInheritedAttribute($node, 'anchorColumn', $anchorColumn);
3296 12 my $anchorDetails = $policy->anchorDetails( $node, $anchorData );
3297  
3298 12 my $cellBodyAlignmentData = $policy->wispCellBodyAlignment($wisp);
3299 12 $policy->setInheritedAttribute($node, 'cellBodyAlignmentData', $cellBodyAlignmentData);
3300  
3301 12 my ( $wispLine, $wispColumn ) = $instance->nodeLC($wisp);
3302  
3303 12 my @mistakes = ();
3304 12 my $runeName = 'barcen';
3305  
3306 12 my $gapLiteral = $instance->literalNode($gap);
3307 12 my $expectedColumn;
3308  
3309 12 ▶ if ( $parentLine == $wispLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parentLine == $wispLine) 0 12 12
3310 0 my $gapLength = $gap->{length};
3311 0 ▶ return [] if length $gapLiteral == 2;
Branch: 1 branch
BranchTrueFalseTotal
if length $gapLiteral == 2 0 0 0
3312  
3313 0 my $msg = sprintf 'joined Barcen battery %s; %s',
3314 describeLC( $wispLine, $wispColumn ),
3315 describeMisindent2( $gapLength, 2 );
3316 0 push @mistakes,
3317 {
3318 desc => $msg,
3319 subpolicy => [ $runeName, 'battery-hgap' ],
3320 parentLine => $parentLine,
3321 parentColumn => $parentColumn,
3322 line => $wispLine,
3323 column => $wispColumn,
3324 reportLine => $wispLine,
3325 reportColumn => $wispColumn,
3326 };
3327 0 return \@mistakes;
3328 }
3329  
3330 # If here head line != battery line
3331 12 $expectedColumn = $anchorColumn;
3332 push @mistakes,
3333 @{
3334 12 $policy->checkOneLineGap(
3335 $gap,
3336 {
3337 mainColumn => $expectedColumn,
3338 runeName => $runeName,
3339 subpolicy => [ $runeName ],
3340 details => [
3341 12 [ @{ $policy->anchorDetails( $node, $anchorData ) } ]
3342 ],
3343 }
3344 )
3345 };
3346  
3347 12 ▶ if ( $wispColumn != $expectedColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wispColumn != $expectedColumn) 0 12 12
3348 0 my $msg = sprintf 'split Barcen battery %s; %s',
3349 describeLC( $wispLine, $wispColumn ),
3350 describeMisindent2( $wispColumn, $expectedColumn );
3351 0 push @mistakes,
3352 {
3353 desc => $msg,
3354 subpolicy => [ $runeName, 'battery-indent' ],
3355 parentLine => $parentLine,
3356 parentColumn => $parentColumn,
3357 line => $wispLine,
3358 column => $wispColumn,
3359 reportLine => $wispLine,
3360 reportColumn => $wispColumn,
3361 anchorDetails => $policy->anchorDetails( $node, $anchorData ),
3362 };
3363 0 return \@mistakes;
3364 }
3365  
3366 12 return \@mistakes;
3367 }
3368  
3369 # tallBarket ::= (- BAR KET GAP -) tall5d (- GAP -) wisp5d
3370 0 ▶sub checkBarket {
Subroutine checkBarket: not called CC=6 SCAR=37.4
Pod undocumented
3371 0 my ( $policy, $node ) = @_;
3372 0 my $instance = $policy->{lint};
3373  
3374 # TODO: reanchoring logic, memoize anchorColumn for checkWisp5d()
3375  
3376 my ( $rune, undef, $headGap, $head, $wispGap, $wisp ) =
3377 0 @{ $node->{children} };
3378 0 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
3379 0 my $anchorNode = $node;
3380 0 my ( $anchorLine, $anchorColumn ) = $instance->nodeLC($anchorNode);
3381 0 my ( $headLine, $headColumn ) = $instance->nodeLC($head);
3382 0 my ( $wispLine, $wispColumn ) = $instance->nodeLC($wisp);
3383  
3384 0 $policy->setInheritedAttribute($node, 'anchorColumn', $anchorColumn);
3385  
3386 0 my $cellBodyAlignmentData = $policy->wispCellBodyAlignment($wisp);
3387 0 $policy->setInheritedAttribute($node, 'cellBodyAlignmentData', $cellBodyAlignmentData);
3388  
3389 0 my @mistakes = ();
3390 0 my $tag = 'barket';
3391 0 my $runeName = 'barket';
3392  
3393 0 my $expectedColumn;
3394  
3395 HEAD_ISSUES: {
3396 0 ▶ if ( $parentLine != $headLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parentLine != $headLine) 0 0 0
3397 0 my $pseudojoinColumn = $policy->pseudojoinColumn($headGap);
3398 0 ▶ if ( $pseudojoinColumn <= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pseudojoinColumn <= 0) 0 0 0
3399 0 my $msg = sprintf 'Barket head %s; must be on rune line',
3400 describeLC( $headLine, $headColumn );
3401 0 push @mistakes,
3402 {
3403 desc => $msg,
3404 subpolicy => [$runeName, 'head-split'],
3405 parentLine => $parentLine,
3406 parentColumn => $parentColumn,
3407 line => $headLine,
3408 column => $headColumn,
3409 reportLine => $headLine,
3410 reportColumn => $headColumn,
3411 };
3412 0 last HEAD_ISSUES;
3413 }
3414 0 my $expectedHeadColumn = $pseudojoinColumn;
3415 0 ▶ if ( $headColumn != $expectedHeadColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headColumn != $expectedHeadColumn) 0 0 0
3416 0 my $msg =
3417 sprintf
3418 'Pseudo-joined Barket head; head/comment mismatch; head is %s',
3419 describeLC( $headLine, $headColumn ),
3420 describeMisindent2( $headColumn, $expectedHeadColumn );
3421 0 push @mistakes,
3422 {
3423 desc => $msg,
3424 subpolicy => [$runeName, 'head-pseudojoin-match'],
3425 parentLine => $parentLine,
3426 parentColumn => $parentColumn,
3427 line => $headLine,
3428 column => $headColumn,
3429 reportLine => $headLine,
3430 reportColumn => $headColumn,
3431 };
3432 }
3433 0 last HEAD_ISSUES;
3434 }
3435  
3436 # If here, headLine == runeLine
3437 0 my $gapLiteral = $instance->literalNode($headGap);
3438 0 my $gapLength = $headGap->{length};
3439 0 ▶ last HEAD_ISSUES if $gapLength == 2;
Branch: 1 branch
BranchTrueFalseTotal
if $gapLength == 2 0 0 0
3440 0 my ( undef, $headGapColumn ) = $instance->nodeLC($headGap);
3441  
3442 0 my $msg = sprintf 'Barket head %s; %s',
3443 describeLC( $headLine, $headColumn ),
3444 describeMisindent2( $gapLength, 2 );
3445 0 push @mistakes,
3446 {
3447 desc => $msg,
3448 subpolicy => [$runeName, 'head-hgap'],
3449 parentLine => $parentLine,
3450 parentColumn => $parentColumn,
3451 line => $headLine,
3452 column => $headColumn,
3453 reportLine => $headLine,
3454 reportColumn => $headColumn,
3455 };
3456  
3457 }
3458  
3459 0 $expectedColumn = $anchorColumn;
3460 push @mistakes,
3461 @{
3462 0 $policy->checkOneLineGap(
3463 $wispGap,
3464 {
3465 mainColumn => $expectedColumn,
3466 preColumn => $expectedColumn + 2,
3467 runeName => $tag,
3468 subpolicy => [$runeName, 'battery-vgap'],
3469 topicLines => [$wispLine],
3470 }
3471 )
3472 };
3473  
3474 0 ▶ if ( $wispColumn != $expectedColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wispColumn != $expectedColumn) 0 0 0
3475 0 my $msg = sprintf 'Barket battery %s; %s',
3476 describeLC( $wispLine, $wispColumn ),
3477 describeMisindent2( $wispColumn, $expectedColumn );
3478 0 push @mistakes,
3479 {
3480 desc => $msg,
3481 subpolicy => [$runeName, 'battery-indent'],
3482 parentLine => $parentLine,
3483 parentColumn => $parentColumn,
3484 line => $wispLine,
3485 column => $wispColumn,
3486 reportLine => $wispLine,
3487 reportColumn => $wispColumn,
3488 };
3489 0 return \@mistakes;
3490 }
3491  
3492 0 return \@mistakes;
3493 }
3494  
3495 0 ▶sub checkFordHoofRune {
Subroutine checkFordHoofRune: not called CC=3 SCAR=24.8
Pod undocumented
3496 0 my ( $policy, $lhsName, $node ) = @_;
3497 0 my $instance = $policy->{lint};
3498  
3499 # FASWUT is very similar to these runes. Combine them?
3500  
3501 # Ford hoof runes is special, so we need to find the components using low-level
3502 # techniques.
3503 # optFordFashep ::= (- FAS HEP GAP -) fordHoofSeq (- GAP -)
3504 my ( undef, undef, $leaderGap, $body, $trailerGap ) =
3505 0 @{ $node->{children} };
3506  
3507 0 my $runeName = $policy->runeName($node);
3508  
3509 # TODO: Should we require that parent column be 0?
3510 0 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
3511 0 my ( $bodyLine, $bodyColumn ) = $instance->nodeLC($body);
3512 0 my ( $leaderGapLine, $leaderGapColumn ) = $instance->nodeLC($leaderGap);
3513 0 my ( $anchorLine, $anchorColumn ) = ( $parentLine, $parentColumn );
3514  
3515 0 my @mistakes = ();
3516 0 my $tag = $runeName;
3517  
3518 0 my $expectedColumn;
3519  
3520 BODY_ISSUES: {
3521 0 ▶ if ( $parentLine != $bodyLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parentLine != $bodyLine) 0 0 0
3522 0 my $msg = sprintf '%s body %s; must be on rune line',
3523 $runeName,
3524 describeLC( $bodyLine, $bodyColumn );
3525 0 push @mistakes,
3526 {
3527 desc => $msg,
3528 parentLine => $parentLine,
3529 parentColumn => $parentColumn,
3530 line => $bodyLine,
3531 column => $bodyColumn,
3532 reportLine => $bodyLine,
3533 reportColumn => $bodyColumn,
3534 subpolicy => [ $runeName, 'same-line' ],
3535 };
3536 0 last BODY_ISSUES;
3537 }
3538 0 my $expectedBodyColumn = $parentColumn + 4;
3539 0 ▶ if ( $bodyColumn != $expectedBodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyColumn != $expectedBodyColumn) 0 0 0
3540 0 my $msg =
3541 sprintf '%s body %s is %s',
3542 $runeName,
3543 describeLC( $bodyLine, $bodyColumn ),
3544 describeMisindent2( $bodyColumn, $expectedBodyColumn );
3545 0 push @mistakes,
3546 {
3547 desc => $msg,
3548 parentLine => $parentLine,
3549 parentColumn => $parentColumn,
3550 line => $bodyLine,
3551 column => $bodyColumn,
3552 reportLine => $bodyLine,
3553 reportColumn => $bodyColumn,
3554 subpolicy => [ $runeName, 'hgap' ],
3555 };
3556 }
3557 0 last BODY_ISSUES;
3558  
3559 }
3560  
3561 0 $expectedColumn = $anchorColumn;
3562 push @mistakes,
3563 @{
3564 0 $policy->checkOneLineGap(
3565 $trailerGap,
3566 {
3567 mainColumn => $anchorColumn,
3568 runeName => $tag,
3569 subpolicy => [ $runeName ],
3570 }
3571 )
3572 };
3573  
3574 0 return \@mistakes;
3575 }
3576  
3577 0 ▶sub checkFordHoop {
Subroutine checkFordHoop: not called CC=4 SCAR=30.0
Pod undocumented
3578 0 my ( $policy, $node ) = @_;
3579 0 my $instance = $policy->{lint};
3580  
3581 # TODO Split is implemented, but not split Ford-1 hoon
3582 # is represented in the corpus AFAICT
3583  
3584 0 my $tag = 'fasfas';
3585  
3586 # fordFassig ::= (- FAS SIG GAP -) tall5d
3587 0 my ( $gap, $body ) = @{ $policy->gapSeq0($node) };
3588  
3589 0 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
3590 0 my ( $bodyLine, $bodyColumn ) = $instance->nodeLC($body);
3591  
3592 0 my @mistakes = ();
3593  
3594 0 my $expectedBodyColumn;
3595  
3596 BODY_ISSUES: {
3597 0 ▶ if ( $parentLine == $bodyLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parentLine == $bodyLine) 0 0 0
3598 0 my $expectedBodyColumn = $parentColumn + 4;
3599 0 ▶ if ( $bodyColumn != $expectedBodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyColumn != $expectedBodyColumn) 0 0 0
3600 0 my $msg =
3601 sprintf 'joined %s body %s is %s',
3602 $tag,
3603 describeLC( $bodyLine, $bodyColumn ),
3604 describeMisindent2( $bodyColumn, $expectedBodyColumn );
3605 0 push @mistakes,
3606 {
3607 desc => $msg,
3608 subpolicy => [ $tag, 'hgap' ],
3609 parentLine => $parentLine,
3610 parentColumn => $parentColumn,
3611 line => $bodyLine,
3612 column => $bodyColumn,
3613 };
3614 }
3615 0 last BODY_ISSUES;
3616 }
3617  
3618 # If here parent line != body line
3619 0 $expectedBodyColumn = $parentColumn;
3620 push @mistakes,
3621 @{
3622 0 $policy->checkOneLineGap(
3623 $gap,
3624 {
3625 mainColumn => $expectedBodyColumn,
3626 runeName => $tag,
3627 subpolicy => [ $tag ],
3628 }
3629 )
3630 };
3631  
3632 0 ▶ if ( $bodyColumn != $expectedBodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyColumn != $expectedBodyColumn) 0 0 0
3633 0 my $msg =
3634 sprintf 'split %s body %s is %s',
3635 $tag,
3636 describeLC( $bodyLine, $bodyColumn ),
3637 describeMisindent2( $bodyColumn, $expectedBodyColumn );
3638 0 push @mistakes,
3639 {
3640 desc => $msg,
3641 subpolicy => [ $tag, 'body-indent' ],
3642 parentLine => $parentLine,
3643 parentColumn => $parentColumn,
3644 line => $bodyLine,
3645 column => $bodyColumn,
3646 };
3647 }
3648 }
3649  
3650 0 return \@mistakes;
3651 }
3652  
3653 0 ▶sub checkFord_1 {
Subroutine checkFord_1: not called CC=4 SCAR=30.0
Pod undocumented
3654 0 my ( $policy, $node ) = @_;
3655 0 my $instance = $policy->{lint};
3656  
3657 # TODO Split is implemented, but not split Ford-1 hoon
3658 # is represented in the corpus AFAICT
3659  
3660 0 my $runeName = $policy->runeName($node);
3661  
3662 # fordFassig ::= (- FAS SIG GAP -) tall5d
3663 0 my ( $gap, $body ) = @{ $policy->gapSeq0($node) };
3664  
3665 0 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
3666 0 my ( $bodyLine, $bodyColumn ) = $instance->nodeLC($body);
3667  
3668 0 my ( $anchorColumn, $anchorData ) = $policy->reanchorInc(
3669 $node,
3670 {
3671 fordFascen => 1,
3672 }
3673 );
3674 0 my $anchorDetails = $policy->anchorDetails( $node, $anchorData );
3675  
3676 0 my @mistakes = ();
3677  
3678 0 my $expectedBodyColumn;
3679  
3680 BODY_ISSUES: {
3681 0 ▶ if ( $parentLine == $bodyLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parentLine == $bodyLine) 0 0 0
3682 0 my $expectedBodyColumn = $anchorColumn + 4;
3683 0 ▶ if ( $bodyColumn != $expectedBodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyColumn != $expectedBodyColumn) 0 0 0
3684 0 my $msg =
3685 sprintf 'joined %s body %s is %s',
3686 $runeName,
3687 describeLC( $bodyLine, $bodyColumn ),
3688 describeMisindent2( $bodyColumn, $expectedBodyColumn );
3689 push @mistakes,
3690 {
3691 desc => $msg,
3692 subpolicy => [ $runeName, 'hgap' ],
3693 parentLine => $parentLine,
3694 parentColumn => $parentColumn,
3695 reportLine => $bodyLine,
3696 reportColumn => $bodyColumn,
3697 line => $bodyLine,
3698 column => $bodyColumn,
3699 0 details => [ [ @{$anchorDetails} ] ],
3700 };
3701 }
3702 0 last BODY_ISSUES;
3703 }
3704  
3705 # If here parent line != body line
3706 0 $expectedBodyColumn = $anchorColumn;
3707 push @mistakes,
3708 @{
3709 0 $policy->checkOneLineGap(
3710 $gap,
3711 {
3712 mainColumn => $expectedBodyColumn,
3713 runeName => $runeName,
3714 subpolicy => [$runeName],
3715 0 details => [ [ @{$anchorDetails}, ], ],
3716 }
3717 )
3718 };
3719  
3720 0 ▶ if ( $bodyColumn != $expectedBodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyColumn != $expectedBodyColumn) 0 0 0
3721 0 my $msg =
3722 sprintf 'split %s body %s is %s',
3723 $runeName,
3724 describeLC( $bodyLine, $bodyColumn ),
3725 describeMisindent2( $bodyColumn, $expectedBodyColumn );
3726 push @mistakes,
3727 {
3728 desc => $msg,
3729 subpolicy => [ $runeName, 'body-indent' ],
3730 0 details => [ [ @{$anchorDetails} ] ],
3731 parentLine => $parentLine,
3732 parentColumn => $parentColumn,
3733 line => $bodyLine,
3734 column => $bodyColumn,
3735 };
3736 }
3737 }
3738  
3739 0 return \@mistakes;
3740 }
3741  
3742 0 ▶sub checkFaswut {
Subroutine checkFaswut: not called CC=3 SCAR=24.8
Pod undocumented
3743 0 my ( $policy, $node ) = @_;
3744 0 my $instance = $policy->{lint};
3745  
3746 # FASWUT is special, so we need to find the components using low-level
3747 # techniques.
3748 # fordFaswut ::= (- FAS WUT GAP -) DIT4K_SEQ (- GAP -)
3749 my ( undef, undef, $leaderGap, $body, $trailerGap ) =
3750 0 @{ $node->{children} };
3751  
3752 # TODO: Should we require that parent column be 0?
3753 0 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
3754 0 my ( $bodyLine, $bodyColumn ) = $instance->nodeLC($body);
3755  
3756 0 my @mistakes = ();
3757 0 my $runeName = 'faswut';
3758 0 my $tag = 'faswut';
3759  
3760 0 my $expectedColumn;
3761  
3762 BODY_ISSUES: {
3763 0 ▶ if ( $parentLine != $bodyLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parentLine != $bodyLine) 0 0 0
3764 0 my $msg = sprintf 'Faswut body %s; must be on rune line',
3765 describeLC( $bodyLine, $bodyColumn );
3766 0 push @mistakes,
3767 {
3768 desc => $msg,
3769 parentLine => $parentLine,
3770 parentColumn => $parentColumn,
3771 line => $bodyLine,
3772 column => $bodyColumn,
3773 };
3774 0 last BODY_ISSUES;
3775 }
3776 0 my $expectedBodyColumn = $parentColumn + 4;
3777 0 ▶ if ( $bodyColumn != $expectedBodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyColumn != $expectedBodyColumn) 0 0 0
3778 0 my $msg =
3779 sprintf 'body %s is %s',
3780 describeLC( $bodyLine, $bodyColumn ),
3781 describeMisindent2( $bodyColumn, $expectedBodyColumn );
3782 0 push @mistakes,
3783 {
3784 desc => $msg,
3785 parentLine => $parentLine,
3786 parentColumn => $parentColumn,
3787 line => $bodyLine,
3788 column => $bodyColumn,
3789 subpolicy => $policy->nodeSubpolicy($node) . ':hgap',
3790 };
3791 }
3792 0 last BODY_ISSUES;
3793  
3794 }
3795  
3796 0 $expectedColumn = $parentColumn;
3797 push @mistakes,
3798 @{
3799 0 $policy->checkOneLineGap(
3800 $trailerGap,
3801 {
3802 mainColumn => $expectedColumn,
3803 runeName => $tag,
3804 subpolicy => [ $runeName ],
3805 }
3806 )
3807 };
3808  
3809 0 return \@mistakes;
3810 }
3811  
3812 # The only lutes in the arvo/ corpus are one-liners.
3813 # We treat one-line lutes as free-form -- never any errors.
3814 # We report "not yet implemented" for multi-line lutes.
3815 0 ▶sub checkLute {
Subroutine checkLute: not called CC=2 SCAR=17.9
Pod undocumented
3816 0 my ( $policy, $node ) = @_;
3817 0 my $instance = $policy->{lint};
3818  
3819 # lutes are special, so we need to find the components using low-level
3820 # techniques.
3821 # lute5d ::= (- SEL GAP -) tall5dSeq (- GAP SER -)
3822 0 my $children = $node->{children};
3823 0 my $sel = $children->[0];
3824 0 my $ser = $children->[-1];
3825 0 my ($selLine) = $instance->nodeLC($sel);
3826 0 my ($serLine) = $instance->nodeLC($ser);
3827  
3828 0 ▶ return $instance->checkNYI($node) if $selLine != $serLine;
Branch: 1 branch
BranchTrueFalseTotal
if $selLine != $serLine 0 0 0
3829 0 return [];
3830 }
3831  
3832 0 ▶sub checkSplit_0Running {
Subroutine checkSplit_0Running: not called CC=3 SCAR=24.8
Pod undocumented
3833 0 my ( $policy, $args ) = @_;
3834 0 my $instance = $policy->{lint};
3835 0 ▶ my $minimumRunsteps = $instance->{minSplit_0RunningSteps} // 0;
Condition0%0/2
$instance->{"minSplit_0RunningSteps"} // 0
l!l
00
MC/DC0%0/1
$instance->{"minSplit_0RunningSteps"} // 0
$instance->{"minSplit_0RunningSteps"}
Truth table0%0/2
A
A= $instance->{"minSplit_0RunningSteps"}
Aresult
11
00
3836  
3837 0 my $node = $args->{node};
3838 0 my $rune = $args->{rune};
3839 0 my $runningGap = $args->{runningGap};
3840 0 my $runningChildren = $args->{runningChildren};
3841 0 my $tistisGap = $args->{tistisGap};
3842 0 my $tistis = $args->{tistis};
3843 0 my $runningLine = $args->{runningLine};
3844 0 my $runningColumn = $args->{runningColumn};
3845 0 my $runeName = $args->{runeName};
3846 0 my $anchorLine = $args->{anchorLine};
3847 0 my $anchorColumn = $args->{anchorColumn};
3848 0 my $anchorDetails = $args->{anchorDetails};
3849  
3850 0 my ( $runeLine, $runeColumn ) = $instance->nodeLC($rune);
3851 0 my ( $tistisLine, $tistisColumn ) = $instance->nodeLC($tistis);
3852  
3853 0 my $expectedColumn = $anchorColumn + 2;
3854  
3855 0 my @mistakes = ();
3856  
3857 # We deal with the running list here, rather than
3858 # in its own node
3859  
3860 0 my $runStepCount = ( scalar @{$runningChildren} ) / 2;
3861 0 ▶ if ( $runStepCount < $minimumRunsteps ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($runStepCount < $minimumRunsteps) 0 0 0
3862  
3863 # Untested
3864  
3865 0 my $msg = sprintf '%s %s; too few runsteps; has %d, minimum is %d',
3866 $runeName,
3867 describeLC( $runningLine, $runningColumn ),
3868 $runStepCount, $minimumRunsteps;
3869 0 push @mistakes,
3870 {
3871 desc => $msg,
3872 subpolicy => [ $runeName, 'split-runstep-count' ],
3873 parentLine => $runeLine,
3874 parentColumn => $runeColumn,
3875 line => $runningLine,
3876 column => $runningColumn,
3877 reportLine => $runningLine,
3878 reportColumn => $runningColumn,
3879 };
3880 }
3881  
3882 push @mistakes,
3883 @{
3884 0 $policy->checkOneLineGap(
3885 $runningGap,
3886 {
3887 mainColumn => $anchorColumn,
3888 preColumn => $expectedColumn,
3889 runeName => $runeName,
3890 subpolicy => [ $runeName, 'running-vgap' ],
3891 }
3892 )
3893 };
3894  
3895 push @mistakes,
3896 @{
3897 0 $policy->checkRunning(
3898 {
3899 children => $runningChildren,
3900 subpolicy => [ $runeName ],
3901 anchorColumn => $anchorColumn,
3902 expectedColumn => $expectedColumn,
3903 anchorDetails => $anchorDetails,
3904 }
3905 )
3906 };
3907  
3908 push @mistakes,
3909 @{
3910 0 $policy->checkOneLineGap(
3911 $tistisGap,
3912 {
3913 mainColumn => $anchorColumn,
3914 preColumn => $expectedColumn,
3915 runeName => $runeName,
3916 subpolicy => [ $runeName, 'tistis-vgap' ],
3917 topicLines => [ $anchorLine, $tistisLine ],
3918 }
3919 )
3920 };
3921  
3922 push @mistakes,
3923 @{
3924 0 $policy->checkTistis(
3925 $tistis,
3926 {
3927 subpolicy => [ $runeName ],
3928 tag => $runeName,
3929 expectedColumn => $anchorColumn,
3930 }
3931 )
3932 };
3933 0 return \@mistakes;
3934 }
3935  
3936 12 ▶sub checkJoined_0Running {
Subroutine checkJoined_0Running: called CC=4 SCAR=14.0
Pod undocumented
3937 12 my ( $policy, $args, $joinColumn ) = @_;
3938 12 my $instance = $policy->{lint};
3939 12 my $maximumRunsteps = $instance->{maxJoined_0RunningSteps};
3940  
3941 12 my $node = $args->{node};
3942 12 my $rune = $args->{rune};
3943 12 my $runningGap = $args->{runningGap};
3944 12 my $runningChildren = $args->{runningChildren};
3945 12 my $tistisGap = $args->{tistisGap};
3946 12 my $tistis = $args->{tistis};
3947 12 my $runningLine = $args->{runningLine};
3948 12 my $runningColumn = $args->{runningColumn};
3949 12 my $runeName = $args->{runeName};
3950 12 my $anchorLine = $args->{anchorLine};
3951 12 my $anchorColumn = $args->{anchorColumn};
3952 12 my $anchorDetails = $args->{anchorDetails};
3953 12 my $pseudojoin = $args->{pseudojoin};
3954  
3955 12 my ( $runeLine, $runeColumn ) = $instance->nodeLC($rune);
3956 12 my ( $tistisLine, $tistisColumn ) = $instance->nodeLC($tistis);
3957  
3958 12 my @mistakes = ();
3959 12 ▶ my $expectedColumn = $joinColumn >= 0 ? $joinColumn : $runeColumn + 4;
Branch: 1 branch
BranchTrueFalseTotal
$joinColumn >= 0 ? : 0 12 12
3960  
3961 12 my $runStepCount = ( scalar @{$runningChildren} ) / 2;
3962 12 ▶ if ( defined $maximumRunsteps and $runStepCount > $maximumRunsteps ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $maximumRunsteps and $runStepCount > $maximumRunsteps) 0 12 12
Condition33%1/3
defined $maximumRunsteps and $runStepCount > $maximumRunsteps
!ll&&!rl&&r
1200
MC/DC0%0/2
defined $maximumRunsteps and $runStepCount > $maximumRunsteps
defined $maximumRunsteps $runStepCount > $maximumRunsteps
Truth table33%1/3
A and B
A= defined $maximumRunstepsB= $runStepCount > $maximumRunsteps
ABresult
0X0
100
111
3963  
3964 # Untested
3965 0 my $msg = sprintf
3966 '%s; too many runsteps; has %d, maximum is %d',
3967 describeLC( $runningLine, $runningColumn ),
3968 $runStepCount, $maximumRunsteps;
3969 0 push @mistakes,
3970 {
3971 desc => $msg,
3972 subpolicy => [ $runeName, 'joined-runstep-count' ],
3973 parentLine => $runeLine,
3974 parentColumn => $runeColumn,
3975 line => $runningLine,
3976 column => $runningColumn,
3977 reportLine => $runningLine,
3978 reportColumn => $runningColumn,
3979 };
3980 }
3981  
3982 push @mistakes,
3983 @{
3984 12 $policy->checkRunning(
3985 {
3986 children => $runningChildren,
3987 subpolicy => [ $runeName ],
3988 anchorColumn => $anchorColumn,
3989 expectedColumn => $expectedColumn,
3990 pseudojoin => $pseudojoin,
3991 }
3992 )
3993 };
3994  
3995 push @mistakes,
3996 @{
3997 12 $policy->checkOneLineGap(
3998 $tistisGap,
3999 {
4000 mainColumn => $runeColumn,
4001 preColumn => $expectedColumn,
4002 runeName => $runeName,
4003 subpolicy => [ $runeName, 'tistis-vgap' ],
4004 topicLines => [ $runeLine, $tistisLine ],
4005 }
4006 )
4007 };
4008  
4009 push @mistakes,
4010 @{
4011 12 $policy->checkTistis(
4012 $tistis,
4013 {
4014 subpolicy => [ $runeName ],
4015 tag => $runeName,
4016 expectedColumn => $runeColumn,
4017 }
4018 )
4019 };
4020 12 return \@mistakes;
4021 }
4022  
4023 0 ▶sub check_1Running {
Subroutine check_1Running: not called CC=5 SCAR=34.0
Pod undocumented
4024 0 my ( $policy, $node ) = @_;
4025 0 my $instance = $policy->{lint};
4026 0 my $lineToPos = $instance->{lineToPos};
4027  
4028 0 my $runeName = $policy->runeName($node);
4029  
4030 my ( $rune, $headGap, $head, $runningGap, $running, $tistisGap, $tistis ) =
4031 0 @{ $policy->gapSeq($node) };
4032  
4033 0 my ( $runeLine, $runeColumn ) = $instance->nodeLC($rune);
4034 0 my ( $anchorLine, $anchorColumn ) = ( $runeLine, $runeColumn );
4035 0 my ( $headLine, $headColumn ) = $instance->nodeLC($head);
4036 0 my ( $runningLine, $runningColumn ) = $instance->nodeLC($running);
4037 0 my ( $tistisLine, $tistisColumn ) = $instance->nodeLC($tistis);
4038  
4039 0 my @mistakes = ();
4040 0 ▶ if ( $headLine != $runeLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headLine != $runeLine) 0 0 0
4041 0 my $msg = sprintf
4042 "$runeName head %s; should be on rune line %d",
4043 describeLC( $headLine, $headColumn ),
4044 $runeLine;
4045 0 push @mistakes,
4046 {
4047 desc => $msg,
4048 subpolicy => [ $runeName, 'head-split' ],
4049 parentLine => $runeLine,
4050 parentColumn => $runeColumn,
4051 line => $headLine,
4052 column => $headColumn,
4053 reportLine => $headLine,
4054 reportColumn => $headColumn,
4055 expectedLine => $runeLine,
4056 };
4057 }
4058  
4059 0 my $expectedColumn = $runeColumn + 4;
4060 0 ▶ if ( $headColumn != $expectedColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headColumn != $expectedColumn) 0 0 0
4061 0 my $msg = sprintf
4062 "$runeName head %s; %s",
4063 describeLC( $headLine, $headColumn ),
4064 describeMisindent2( $headColumn, $expectedColumn );
4065 0 push @mistakes,
4066 {
4067 desc => $msg,
4068 subpolicy => [ $runeName, 'head-hgap' ],
4069 parentLine => $runeLine,
4070 parentColumn => $runeColumn,
4071 line => $headLine,
4072 column => $headColumn,
4073 reportLine => $headLine,
4074 reportColumn => $headColumn,
4075 };
4076 }
4077  
4078 0 $expectedColumn = $anchorColumn + 2;
4079  
4080 # Note: runnings are never pseudo-joined, at
4081 # least not in the corpus.
4082 0 ▶ if ( $headLine != $runningLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headLine != $runningLine) { } 0 0 0
4083 push @mistakes,
4084 @{
4085 0 $policy->checkOneLineGap(
4086 $runningGap,
4087 {
4088 mainColumn => $anchorColumn,
4089 preColumn => $runningColumn,
4090 runeName => $runeName,
4091 subpolicy => [ $runeName ],
4092 }
4093 )
4094 };
4095  
4096 0 my @runningChildren = ( $runningGap, @{ $running->{children} } );
4097  
4098 push @mistakes,
4099 @{
4100 0 $policy->checkRunning(
4101 {
4102 children => \@runningChildren,
4103 subpolicy => [ $runeName ],
4104 anchorColumn => $anchorColumn,
4105 expectedColumn => $expectedColumn,
4106 }
4107 )
4108 };
4109  
4110 }
4111 else {
4112 # joined, that is, $headLine == $runningLine
4113 0 my $gapLength = $runningGap->{length};
4114  
4115 0 ▶ if ( $gapLength != 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($gapLength != 2) 0 0 0
4116 0 my $msg = sprintf
4117 "1-jogging running 1 %s; %s",
4118 describeLC( $runningLine, $runningColumn ),
4119 describeMisindent2( $gapLength, 2 );
4120 0 push @mistakes,
4121 {
4122 desc => $msg,
4123 subpolicy => [ $runeName, 'running-hgap' ],
4124 parentLine => $runeLine,
4125 parentColumn => $runeColumn,
4126 line => $runningLine,
4127 column => $runningColumn,
4128 reportLine => $runningLine,
4129 reportColumn => $runningColumn,
4130 };
4131 }
4132  
4133 0 my @runningChildren = ( $runningGap, @{ $running->{children} } );
4134  
4135 push @mistakes,
4136 @{
4137 0 $policy->checkRunning(
4138 {
4139 skipFirst => 1,
4140 children => \@runningChildren,
4141 subpolicy => [ $runeName ],
4142 anchorColumn => $anchorColumn,
4143 expectedColumn => $expectedColumn
4144 }
4145 )
4146 };
4147  
4148 }
4149  
4150 # We deal with the running list here, rather that
4151 # in its own node
4152  
4153 push @mistakes,
4154 @{
4155 0 $policy->checkOneLineGap(
4156 $tistisGap,
4157 {
4158 mainColumn => $runeColumn,
4159 preColumn => $expectedColumn,
4160 runeName => $runeName,
4161 subpolicy => [ $runeName, 'tistis-gap' ],
4162 topicLines => [ $runeLine, $tistisLine ],
4163 }
4164 )
4165 };
4166  
4167 0 $expectedColumn = $runeColumn;
4168  
4169 push @mistakes,
4170 @{
4171 0 $policy->checkTistis(
4172 $tistis,
4173 {
4174 tag => $runeName,
4175 subpolicy => [$runeName],
4176 expectedColumn => $runeColumn,
4177 }
4178 )
4179 };
4180  
4181 0 return \@mistakes;
4182 }
4183  
4184 # Find the oversize alignment for this column of elements.
4185 # of a chain alignment
4186 # $nodes must a ref to an array of repeating
4187 # ( gap, body, backdentColumn ) elements
4188 60 ▶sub findChainAlignment {
Subroutine findChainAlignment: called CC=10 SCAR=31.5
Pod undocumented
4189 60 my ( $policy, $nodes ) = @_;
4190 60 my $instance = $policy->{lint};
4191 60 my %allAlignments = ();
4192  
4193 # local $Data::Dumper::Maxdepth = 1;
4194 # say STDERR join " ", __FILE__, __LINE__;
4195  
4196 # "wide", meaning an alignment following a gap of more than
4197 # one stop
4198 60 my %wideAlignments = ();
4199 60 CHILD: for ( my $bodyIX = 2 ; 1 ; $bodyIX += 3 ) {
4200 225 my $body = $nodes->[$bodyIX -1];
4201 # say STDERR join " ", __FILE__, __LINE__, $bodyIX, $#$nodes;
4202 # say STDERR join " ", __FILE__, __LINE__, $nodes->[$bodyIX];
4203 225 ▶ last CHILD if not defined $body;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $body 60 165 225
4204 165 my ( $bodyLine, $bodyColumn ) = $instance->nodeLC( $body );
4205 # say STDERR join " ", __FILE__, __LINE__, $bodyLine, $bodyColumn;
4206 165 my $backdentColumn = $nodes->[$bodyIX];
4207 165 ▶ next CHILD if $bodyColumn == $backdentColumn;
Branch: 1 branch
BranchTrueFalseTotal
if $bodyColumn == $backdentColumn 51 114 165
4208 114 ▶ $allAlignments{$bodyColumn} //= [];
Condition100%2/2
$allAlignments{$bodyColumn} //= []
l!l
4866
MC/DC100%1/1
$allAlignments{$bodyColumn} //= []
$allAlignments{$bodyColumn}
Truth table100%2/2
A
A= $allAlignments{$bodyColumn}
Aresult
11
00
4209 114 push @{ $allAlignments{$bodyColumn} }, $bodyLine;
4210 114 my $gap = $nodes->[ $bodyIX - 2 ];
4211 114 my $gapLength = $instance->gapLength($gap);
4212 114 ▶ next CHILD if $gapLength <= 2;
Branch: 1 branch
BranchTrueFalseTotal
if $gapLength <= 2 114 0 114
4213 0 ▶ $wideAlignments{$bodyColumn} //= [];
Condition0%0/2
$wideAlignments{$bodyColumn} //= []
l!l
00
MC/DC0%0/1
$wideAlignments{$bodyColumn} //= []
$wideAlignments{$bodyColumn}
Truth table0%0/2
A
A= $wideAlignments{$bodyColumn}
Aresult
11
00
4214 0 push @{ $wideAlignments{$bodyColumn} }, $bodyLine;
4215 }
4216  
4217 # say STDERR join " ", __FILE__, __LINE__, scalar @{$nodes};
4218  
4219 60 ▶ return [-1, {lines => []}] if not scalar %wideAlignments;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar %wideAlignments 60 0 60
4220  
4221 # wide alignments, in order first by descending count of wide instances;
4222 # then by descending count of all instances;
4223 # then by ascending first line
4224 my @sortedWideAlignments =
4225 sort {
4226 0 ( scalar @{ $wideAlignments{$b} } ) <=> ( scalar @{ $wideAlignments{$a} } )
4227 0 or ( scalar @{ $allAlignments{$b} } ) <=> ( scalar @{ $allAlignments{$a} } )
4228 0 ▶ or $wideAlignments{$a}[0] <=> $wideAlignments{$b}[0]
Condition0%0/6
scalar @{$wideAlignments{$b};} <=> scalar @{$wideAlignments{$a};} || scalar @{$allAlignments{$b};} <=> scalar @{$allAlignments{$a};} || $wideAlignments{$a}[0] <=> $wideAlignments{$b}[0]
l!l&&r!l&&!r
000
scalar @{$wideAlignments{$b};} <=> scalar @{$wideAlignments{$a};} or scalar @{$allAlignments{$b};} <=> scalar @{$allAlignments{$a};}
l!l&&r!l&&!r
000
MC/DC0%0/3
scalar @{$wideAlignments{$b};} <=> scalar @{$wideAlignments{$a};} || scalar @{$allAlignments{$b};} <=> scalar @{$allAlignments{$a};} || $wideAlignments{$a}[0] <=> $wideAlignments{$b}[0]
scalar @{$wideAlignments{$b};} <=> scalar @{$wideAlignments{$a};} scalar @{$allAlignments{$b};} <=> scalar @{$allAlignments{$a};} $wideAlignments{$a}[0] <=> $wideAlignments{$b}[0]
Truth table0%0/4
A or B || C
A= scalar @{$wideAlignments{$b};} <=> scalar @{$wideAlignments{$a};}B= scalar @{$allAlignments{$b};} <=> scalar @{$allAlignments{$a};}C= $wideAlignments{$a}[0] <=> $wideAlignments{$b}[0]
ABCresult
1XX1
01X1
0011
0000
4229 }
4230 keys %wideAlignments;
4231  
4232 0 my $topWideColumn = $sortedWideAlignments[0];
4233  
4234
4235 # say STDERR join " ", __FILE__, __LINE__, $topWideColumn;
4236  
4237 # Make sure this is actually an *alignment*, that is,
4238 # that there are at least 2 instances. Otherwise,
4239 # ignore it.
4240 0 ▶ return [-1, {lines => []}] if scalar @{ $allAlignments{$topWideColumn} } <= 1;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$allAlignments{$topWideColumn};} <= 1 0 0 0
4241  
4242 # say STDERR join " ", __FILE__, __LINE__, $topWideColumn;
4243  
4244 0 return [$topWideColumn, {lines => [splice(@{$allAlignments{$topWideColumn}}, 0, 5)]}];
4245  
4246 }
4247  
4248 153 ▶sub chainAlignmentData {
Subroutine chainAlignmentData: called CC=28 SCAR=34.7
Pod undocumented
4249 153 my ( $policy, $argNode ) = @_;
4250 153 my $instance = $policy->{lint};
4251 153 my $chainable = $policy->{chainable};
4252 153 my $grammar = $instance->{grammar};
4253  
4254 153 state $mortar = {
4255 tall5d => 1,
4256 norm5d => 1,
4257 };
4258  
4259 153 my $argNodeIX = $argNode->{IX};
4260 my $chainAlignmentData =
4261 153 $policy->{perNode}->{$argNodeIX}->{chainAlignmentData};
4262 153 ▶ return $chainAlignmentData if $chainAlignmentData;
Branch: 1 branch
BranchTrueFalseTotal
if $chainAlignmentData 114 39 153
4263  
4264 # Find the base column of the alignment
4265 39 my $alignmentBaseColumn;
4266 my $chainHead;
4267 39 my ( $argNodeLine, $argNodeColumn ) = $instance->nodeLC($argNode);
4268 39 my $thisNode = $argNode;
4269 # say STDERR join " ", __FILE__, __LINE__;
4270 39 ▶ LINK: while ($thisNode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($thisNode) 150 0 150
4271 # say STDERR join " ", __FILE__, __LINE__;
4272 150 ▶ last LINK if $thisNode->{NEXT}; # Must be rightmost
Branch: 1 branch
BranchTrueFalseTotal
if $thisNode->{"NEXT"} 6 144 150
4273 144 my $symbolName = $instance->symbol($thisNode);
4274 144 ▶ if ($mortar->{$symbolName}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mortar->{$symbolName}) 72 72 144
4275 72 $thisNode = $thisNode->{PARENT};
4276 72 next LINK;
4277 }
4278  
4279 # TODO -- replace this test by always ending the LINK
4280 # loop on non-recognized-mortar non-chainable.
4281 72 ▶ last LINK if $symbolName =~ m/^(rick5dJog|ruck5dJog|fordHoop)$/;
Branch: 1 branch
BranchTrueFalseTotal
if $symbolName =~ /^(rick5dJog|ruck5dJog|fordHoop)$/ 12 60 72
4282 # say STDERR join " ", __FILE__, __LINE__;
4283 60 ▶ if (not $policy->chainable($thisNode) and not $instance->brickName($thisNode)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($policy->chainable($thisNode) or $instance->brickName($thisNode)) 0 60 60
Condition66%2/3
$policy->chainable($thisNode) or $instance->brickName($thisNode)
l!l&&r!l&&!r
39210
MC/DC0%0/2
$policy->chainable($thisNode) or $instance->brickName($thisNode)
$policy->chainable($thisNode) $instance->brickName($thisNode)
Truth table66%2/3
A or B
A= $policy->chainable($thisNode)B= $instance->brickName($thisNode)
ABresult
1X1
011
000
4284 0 say STDERR join " ", __FILE__, __LINE__, $instance->symbol($thisNode);
4285 }
4286  
4287 60 ▶ last LINK if not $policy->chainable($thisNode); # Must be chainable
Branch: 1 branch
BranchTrueFalseTotal
unless $policy->chainable($thisNode) 21 39 60
4288 # say STDERR join " ", __FILE__, __LINE__;
4289 39 my ( $thisNodeLine, $thisNodeColumn ) = $instance->nodeLC($thisNode);
4290 39 ▶ last LINK if $thisNodeLine != $argNodeLine;
Branch: 1 branch
BranchTrueFalseTotal
if $thisNodeLine != $argNodeLine 0 39 39
4291 # say STDERR join " ", __FILE__, __LINE__;
4292 39 $alignmentBaseColumn = $thisNodeColumn;
4293 39 $chainHead = $thisNode;
4294 39 $thisNode = $thisNode->{PARENT};
4295 }
4296 # say STDERR join " ", __FILE__, __LINE__;
4297  
4298 39 ▶ return if not defined $alignmentBaseColumn; # TODO: delete after development
Branch: 1 branch
BranchTrueFalseTotal
unless defined $alignmentBaseColumn 0 39 39
4299  
4300 # Find the head (first link) of this alignment chain
4301 39 ▶ LINK: while ($thisNode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($thisNode) 39 0 39
4302 39 ▶ last LINK if $thisNode->{NEXT}; # Must be rightmost
Branch: 1 branch
BranchTrueFalseTotal
if $thisNode->{"NEXT"} 6 33 39
4303 33 my $symbolName = $instance->symbol($thisNode);
4304 33 ▶ if ($mortar->{$symbolName}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mortar->{$symbolName}) 0 33 33
4305 0 $thisNode = $thisNode->{PARENT};
4306 0 next LINK;
4307 }
4308 33 ▶ last LINK if not $policy->chainable($thisNode); # Must be chainable
Branch: 1 branch
BranchTrueFalseTotal
unless $policy->chainable($thisNode) 33 0 33
4309 0 my ( $thisNodeLine, $thisNodeColumn ) = $instance->nodeLC($thisNode);
4310 0 ▶ last LINK if $thisNodeColumn < $alignmentBaseColumn;
Branch: 1 branch
BranchTrueFalseTotal
if $thisNodeColumn < $alignmentBaseColumn 0 0 0
4311 0 ▶ $chainHead = $thisNode if $thisNodeColumn == $alignmentBaseColumn;
Branch: 1 branch
BranchTrueFalseTotal
if $thisNodeColumn == $alignmentBaseColumn 0 0 0
4312 0 $thisNode = $thisNode->{PARENT};
4313 }
4314  
4315 # Traverse the whole chain, from the head
4316 39 $thisNode = $chainHead;
4317 39 my $parentNodeLine = -1;
4318 39 my $parentElementCount = 0;
4319 39 my $currentChainOffset = 0;
4320 39 my $thisNodeIX;
4321  
4322 # Array, indexed by child index, of "silos"
4323 # of [ gap, body ], to align
4324 my @nodesToAlignByChildIX;
4325 39 ▶ LINK: while ($thisNode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($thisNode) 474 0 474
4326 # say STDERR sprintf q{Traversing %s}, $instance->literalNode($thisNode);
4327  
4328 # End of loop tests --
4329 # Is it chainable?
4330 # Is the line,column right for the current chain?
4331 # CURRENT say STDERR join q{ }, __FILE__, __LINE__;
4332 474 my $symbolName = $instance->symbol($thisNode);
4333 # Skip if it's one of the appropriate list of mortar symbols.
4334 474 ▶ if ($mortar->{$symbolName}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mortar->{$symbolName}) 282 192 474
4335 282 my $children = $thisNode->{children};
4336 282 $thisNode = $children->[$#$children];
4337 282 next LINK;
4338 }
4339 192 ▶ last LINK if not $policy->chainable($thisNode);
Branch: 1 branch
BranchTrueFalseTotal
unless $policy->chainable($thisNode) 39 153 192
4340 153 my ( $thisNodeLine, $thisNodeColumn ) = $instance->nodeLC($thisNode);
4341 153 ▶ if ( $thisNodeColumn == $alignmentBaseColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($thisNodeColumn == $alignmentBaseColumn) { } 138 15 153
4342 138 $currentChainOffset = 0;
4343 }
4344 else {
4345 15 ▶ last LINK if $thisNodeLine != $parentNodeLine;
Branch: 1 branch
BranchTrueFalseTotal
if $thisNodeLine != $parentNodeLine 0 15 15
4346 15 $currentChainOffset += $parentElementCount;
4347 }
4348  
4349 # Tracks "last" node IX, so do not set $thisNodeIX before "end
4350 # of loop" tests.
4351 153 $thisNodeIX = $thisNode->{IX};
4352 # CURRENT say STDERR join q{ }, __FILE__, __LINE__;
4353  
4354 153 my @thisGapSeq = @{ $policy->gapSeq0($thisNode) };
4355 153 my $elementCount = ( scalar @thisGapSeq ) / 2;
4356  
4357 ELEMENT:
4358 153 ▶ for (
Branch: 1 branch
BranchTrueFalseTotal
if ($elementNumber <= $elementCount) 342 153 495
4359 my $elementNumber = 1 ;
4360 $elementNumber <= $elementCount ;
4361 $elementNumber++
4362 )
4363 {
4364 342 my $gap = $thisGapSeq[ $elementNumber * 2 - 2 ];
4365 342 my $element = $thisGapSeq[ $elementNumber * 2 - 1 ];
4366 342 my ($gapLine) = $instance->nodeLC($gap);
4367 342 my ($elementLine) = $instance->nodeLC($element);
4368  
4369 # Not in aligment if not on rune line
4370 342 ▶ next ELEMENT if $elementLine != $thisNodeLine;
Branch: 1 branch
BranchTrueFalseTotal
if $elementLine != $thisNodeLine 177 165 342
4371  
4372 165 my $backdentColumn =
4373 $thisNodeColumn + ( $elementCount - $elementNumber ) * 2;
4374 165 push @{ $nodesToAlignByChildIX[$currentChainOffset + $elementNumber-1] }, $gap, $element, $backdentColumn;
4375 }
4376  
4377 $policy->{perNode}->{$thisNodeIX}->{chainAlignmentData} =
4378 153 { offset => $currentChainOffset };
4379  
4380 # Set "parent" data for next pass
4381 153 $parentNodeLine = $thisNodeLine;
4382 153 $parentElementCount = $elementCount;
4383  
4384 # descend to rightmost child
4385 153 my $children = $thisNode->{children};
4386 153 $thisNode = $children->[$#$children];
4387 }
4388  
4389 39 my $lastNodeIX = $thisNodeIX;
4390  
4391 39 my @chainAlignments = ();
4392 ELEMENT:
4393 39 ▶ for (
Branch: 1 branch
BranchTrueFalseTotal
if ($childIX <= $#nodesToAlignByChildIX) 60 39 99
4394 my $childIX = 0 ;
4395 $childIX <= $#nodesToAlignByChildIX;
4396 $childIX++
4397 )
4398 {
4399 60 my $nodesToAlign = $nodesToAlignByChildIX[$childIX];
4400 60 ▶ if (not $nodesToAlign) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($nodesToAlign) 0 60 60
4401 0 $chainAlignments[ $childIX ] = [ -1, [] ];
4402 0 next ELEMENT;
4403 }
4404 60 $chainAlignments[ $childIX ] = $policy->findChainAlignment( $nodesToAlign);
4405 }
4406  
4407 39 $thisNode = $chainHead;
4408 39 ▶ LINK: while ($thisNode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($thisNode) 381 0 381
4409 381 my $thisNodeIX = $thisNode->{IX};
4410 $policy->{perNode}->{$thisNodeIX}->{chainAlignmentData}->{alignments} =
4411 381 \@chainAlignments;
4412 381 ▶ last LINK if $thisNodeIX == $lastNodeIX;
Branch: 1 branch
BranchTrueFalseTotal
if $thisNodeIX == $lastNodeIX 39 342 381
4413  
4414 # descend to rightmost child
4415 342 my $children = $thisNode->{children};
4416 342 $thisNode = $children->[$#$children];
4417 }
4418  
4419 39 $chainAlignmentData = $policy->{perNode}->{$argNodeIX}->{chainAlignmentData};
4420 39 return $chainAlignmentData;
4421 }
4422  
4423 6 ▶sub joggingHoonData {
Subroutine joggingHoonData: called CC=8 SCAR=21.6
Pod undocumented
4424 6 my ( $policy, $options, $node ) = @_;
4425 6 my $runeName = $policy->runeName($node);
4426 6 my %result = ( node => $node, runeName => $runeName );
4427 6 my $instance = $policy->{lint};
4428 6 my $children = $node->{children};
4429 6 my $anchorColumn = $options->{anchorColumn};
4430 6 ▶ if ( not defined $anchorColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $anchorColumn) 0 6 6
4431 0 ( undef, $anchorColumn ) = $instance->nodeLC($node);
4432 }
4433 6 $result{anchorColumn} = $anchorColumn;
4434 6 ▶ my $firstOKJogLine = $options->{firstOKJogLine} // 0;
Condition50%1/2
$options->{"firstOKJogLine"} // 0
l!l
60
MC/DC0%0/1
$options->{"firstOKJogLine"} // 0
$options->{"firstOKJogLine"}
Truth table50%1/2
A
A= $options->{"firstOKJogLine"}
Aresult
11
00
4435 6 $result{firstOKJogLine} = $firstOKJogLine;
4436  
4437 6 my $previousChild;
4438 6 CHILD: for my $childIX ( 0 .. $#$children ) {
4439 36 my $child = $children->[$childIX];
4440 36 my $symbol = $instance->symbol($child);
4441 36 ▶ if ( $symbol ne 'rick5d' and $symbol ne 'ruck5d' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($symbol ne "rick5d" and $symbol ne "ruck5d") 30 6 36
Condition100%3/3
$symbol ne "rick5d" and $symbol ne "ruck5d"
!ll&&!rl&&r
3330
MC/DC100%2/2
$symbol ne "rick5d" and $symbol ne "ruck5d"
$symbol ne "rick5d" $symbol ne "ruck5d"
Truth table100%3/3
A and B
A= $symbol ne "rick5d"B= $symbol ne "ruck5d"
ABresult
0X0
100
111
4442 30 $previousChild = $child;
4443 30 next CHILD;
4444 }
4445 6 my ($previousChildLine) = $instance->nodeLC($previousChild);
4446 6 ▶ if ($runeName eq 'tiscol') {
Branch: 1 branch
BranchTrueFalseTotal
if ($runeName eq 'tiscol') { } 0 6 6
4447 0 my $chessSide = 'kingside';
4448 0 $result{chessSide} = $chessSide;
4449 0 my $baseColumn = $anchorColumn + 4;
4450 0 $result{jogBaseColumn} = $baseColumn;
4451 } else {
4452 6 my $chessSide =
4453 $policy->chessSideOfJogging( $child, $anchorColumn,
4454 $previousChildLine + 1 );
4455 6 $result{chessSide} = $chessSide;
4456 6 ▶ my $baseColumn = $anchorColumn + ( $chessSide eq 'queenside' ? 4 : 2 );
Branch: 1 branch
BranchTrueFalseTotal
$chessSide eq 'queenside' ? : 0 6 6
4457 6 $result{jogBaseColumn} = $baseColumn;
4458 }
4459 6 my $jogBodyData = $policy->joggingBodyAlignment($child);
4460 6 ( $result{bodyAlignment}, $result{alignments} ) = @{$jogBodyData};
4461 6 return \%result;
4462 }
4463 0 die "No jogging found for ", $instance->symbol($node);
4464 }
4465  
4466 0 ▶sub chessSideOfPairSequence {
Subroutine chessSideOfPairSequence: not called CC=7 SCAR=40.3
Pod undocumented
4467 0 my ( $policy, $node, $runeColumn ) = @_;
4468 0 my $instance = $policy->{lint};
4469  
4470 0 my $symbolReverseDB = $instance->{symbolReverseDB};
4471 0 my $children = $node->{children};
4472 0 my %sideCount = ();
4473 0 my %bodyColumnCount = ();
4474 0 my $kingsideCount = 0;
4475 0 my $queensideCount = 0;
4476 0 my $lastLine = -1;
4477 0 CHILD: for my $childIX ( 0 .. $#$children ) {
4478 0 my $jog = $children->[$childIX];
4479 0 my $symbol = $jog->{symbol};
4480 0 ▶ next CHILD if defined $symbol and $symbolReverseDB->{$symbol}->{gap};
Branch: 1 branch
BranchTrueFalseTotal
if defined $symbol and $symbolReverseDB->{$symbol}{"gap"} 0 0 0
Condition0%0/3
defined $symbol and $symbolReverseDB->{$symbol}{"gap"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $symbol and $symbolReverseDB->{$symbol}{"gap"}
defined $symbol $symbolReverseDB->{$symbol}{"gap"}
Truth table0%0/3
A and B
A= defined $symbolB= $symbolReverseDB->{$symbol}{"gap"}
ABresult
0X0
100
111
4481 0 my $head = $jog->{children}->[0];
4482 0 my ( $line1, $column1 ) = $instance->line_column( $head->{start} );
4483 0 ▶ next CHILD if $line1 == $lastLine;
Branch: 1 branch
BranchTrueFalseTotal
if $line1 == $lastLine 0 0 0
4484 0 $lastLine = $line1;
4485 # say STDERR " $column1 - $runeColumn >= 4 ";
4486 0 ▶ if ( $column1 - $runeColumn >= 4 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($column1 - $runeColumn >= 4) 0 0 0
4487 0 $queensideCount++;
4488 0 next CHILD;
4489 }
4490 0 $kingsideCount++;
4491 }
4492 0 ▶ return $kingsideCount > $queensideCount
Branch: 1 branch
BranchTrueFalseTotal
$kingsideCount > $queensideCount ? : 0 0 0
4493 ? 'kingside'
4494 : 'queenside';
4495 }
4496  
4497 6 ▶sub chessSideOfJogging {
Subroutine chessSideOfJogging: called CC=8 SCAR=21.4
Pod undocumented
4498 6 my ( $policy, $node, $runeColumn, $firstLine ) = @_;
4499 6 my $instance = $policy->{lint};
4500  
4501 6 my $symbolReverseDB = $instance->{symbolReverseDB};
4502 6 my $children = $node->{children};
4503 6 my %sideCount = ();
4504 6 my %bodyColumnCount = ();
4505 6 my $kingsideCount = 0;
4506 6 my $queensideCount = 0;
4507 6 my $lastLine = -1;
4508 6 CHILD: for my $childIX ( 0 .. $#$children ) {
4509 24 my $jog = $children->[$childIX];
4510 24 my $symbol = $jog->{symbol};
4511 24 ▶ next CHILD if defined $symbol and $symbolReverseDB->{$symbol}->{gap};
Branch: 1 branch
BranchTrueFalseTotal
if defined $symbol and $symbolReverseDB->{$symbol}{"gap"} 9 15 24
Condition66%2/3
defined $symbol and $symbolReverseDB->{$symbol}{"gap"}
!ll&&!rl&&r
1509
MC/DC50%1/2
defined $symbol and $symbolReverseDB->{$symbol}{"gap"}
defined $symbol $symbolReverseDB->{$symbol}{"gap"}
Truth table66%2/3
A and B
A= defined $symbolB= $symbolReverseDB->{$symbol}{"gap"}
ABresult
0X0
100
111
4512 15 my $head = $jog->{children}->[0];
4513 15 my ( $line1, $column1 ) = $instance->line_column( $head->{start} );
4514 # Enforce a "first line" to disallow first line of joggings
4515 # which are not preceded by a vertical gap.
4516 15 ▶ next CHILD if $line1 < $firstLine;
Branch: 1 branch
BranchTrueFalseTotal
if $line1 < $firstLine 0 15 15
4517 15 ▶ next CHILD if $line1 == $lastLine;
Branch: 1 branch
BranchTrueFalseTotal
if $line1 == $lastLine 0 15 15
4518 15 $lastLine = $line1;
4519 # say STDERR " $column1 - $runeColumn >= 4 ";
4520 15 ▶ if ( $column1 - $runeColumn >= 4 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($column1 - $runeColumn >= 4) 0 15 15
4521 0 $queensideCount++;
4522 0 next CHILD;
4523 }
4524 15 $kingsideCount++;
4525 }
4526 6 ▶ return $kingsideCount > $queensideCount
Branch: 1 branch
BranchTrueFalseTotal
$kingsideCount > $queensideCount ? : 6 0 6
4527 ? 'kingside'
4528 : 'queenside';
4529 }
4530  
4531 # Find the oversize alignment for this column of elements.
4532 # $nodes must a ref to an array of alternating gap, body,
4533 # nodes.
4534 27 ▶sub findAlignment {
Subroutine findAlignment: called CC=9 SCAR=31.2
Pod undocumented
4535 27 my ( $policy, $nodes ) = @_;
4536 27 my $instance = $policy->{lint};
4537 27 my %allAlignments = ();
4538  
4539 # local $Data::Dumper::Maxdepth = 1;
4540 # say STDERR join " ", __FILE__, __LINE__;
4541  
4542 # "wide", meaning an alignment following a gap of more than
4543 # one stop
4544 27 my %wideAlignments = ();
4545 27 CHILD: for ( my $bodyIX = 1 ; 1 ; $bodyIX += 2 ) {
4546 84 my $body = $nodes->[$bodyIX];
4547 # say STDERR join " ", __FILE__, __LINE__, $bodyIX, $#$nodes;
4548 # say STDERR join " ", __FILE__, __LINE__, $nodes->[$bodyIX];
4549 84 ▶ last CHILD if not defined $body;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $body 27 57 84
4550 # say STDERR join " ", __FILE__, __LINE__, $nodes->[$bodyIX];
4551 57 my ( $bodyLine, $bodyColumn ) = $instance->nodeLC( $body );
4552 57 ▶ $allAlignments{$bodyColumn} //= [];
Condition100%2/2
$allAlignments{$bodyColumn} //= []
l!l
3621
MC/DC100%1/1
$allAlignments{$bodyColumn} //= []
$allAlignments{$bodyColumn}
Truth table100%2/2
A
A= $allAlignments{$bodyColumn}
Aresult
11
00
4553 57 push @{ $allAlignments{$bodyColumn} }, $bodyLine;
4554 57 my $gap = $nodes->[ $bodyIX - 1 ];
4555 57 my $gapLength = $instance->gapLength($gap);
4556 57 ▶ next CHILD if $gapLength <= 2;
Branch: 1 branch
BranchTrueFalseTotal
if $gapLength <= 2 57 0 57
4557 0 ▶ $wideAlignments{$bodyColumn} //= [];
Condition0%0/2
$wideAlignments{$bodyColumn} //= []
l!l
00
MC/DC0%0/1
$wideAlignments{$bodyColumn} //= []
$wideAlignments{$bodyColumn}
Truth table0%0/2
A
A= $wideAlignments{$bodyColumn}
Aresult
11
00
4558 0 push @{ $wideAlignments{$bodyColumn} }, $bodyLine;
4559 }
4560  
4561 # say STDERR join " ", __FILE__, __LINE__, scalar @{$nodes};
4562  
4563 27 ▶ return [-1, []] if not scalar %wideAlignments;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar %wideAlignments 27 0 27
4564  
4565 # wide alignments, in order first by descending count of wide instances;
4566 # then by descending count of all instances;
4567 # then by ascending first line
4568 my @sortedWideAlignments =
4569 sort {
4570 0 ( scalar @{ $wideAlignments{$b} } ) <=> ( scalar @{ $wideAlignments{$a} } )
4571 0 or ( scalar @{ $allAlignments{$b} } ) <=> ( scalar @{ $allAlignments{$a} } )
4572 0 ▶ or $wideAlignments{$a}[0] <=> $wideAlignments{$b}[0]
Condition0%0/6
scalar @{$wideAlignments{$b};} <=> scalar @{$wideAlignments{$a};} || scalar @{$allAlignments{$b};} <=> scalar @{$allAlignments{$a};} || $wideAlignments{$a}[0] <=> $wideAlignments{$b}[0]
l!l&&r!l&&!r
000
scalar @{$wideAlignments{$b};} <=> scalar @{$wideAlignments{$a};} or scalar @{$allAlignments{$b};} <=> scalar @{$allAlignments{$a};}
l!l&&r!l&&!r
000
MC/DC0%0/3
scalar @{$wideAlignments{$b};} <=> scalar @{$wideAlignments{$a};} || scalar @{$allAlignments{$b};} <=> scalar @{$allAlignments{$a};} || $wideAlignments{$a}[0] <=> $wideAlignments{$b}[0]
scalar @{$wideAlignments{$b};} <=> scalar @{$wideAlignments{$a};} scalar @{$allAlignments{$b};} <=> scalar @{$allAlignments{$a};} $wideAlignments{$a}[0] <=> $wideAlignments{$b}[0]
Truth table0%0/4
A or B || C
A= scalar @{$wideAlignments{$b};} <=> scalar @{$wideAlignments{$a};}B= scalar @{$allAlignments{$b};} <=> scalar @{$allAlignments{$a};}C= $wideAlignments{$a}[0] <=> $wideAlignments{$b}[0]
ABCresult
1XX1
01X1
0011
0000
4573 }
4574 keys %wideAlignments;
4575  
4576 0 my $topWideColumn = $sortedWideAlignments[0];
4577  
4578 # say STDERR join " ", __FILE__, __LINE__, $topWideColumn;
4579  
4580 # Make sure this is actually an *alignment*, that is,
4581 # that there are at least 2 instances. Otherwise,
4582 # ignore it.
4583 0 ▶ return [-1, []] if scalar @{ $allAlignments{$topWideColumn} } <= 1;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$allAlignments{$topWideColumn};} <= 1 0 0 0
4584  
4585 # say STDERR join " ", __FILE__, __LINE__, $topWideColumn;
4586  
4587 0 return [$topWideColumn, [splice(@{$allAlignments{$topWideColumn}}, 0, 5)]];
4588  
4589 }
4590  
4591 6 ▶sub joggingBodyAlignment {
Subroutine joggingBodyAlignment: called CC=3 SCAR=11.0
Pod undocumented
4592 6 my ( $policy, $jogging ) = @_;
4593 6 my $instance = $policy->{lint};
4594 6 my $children = $jogging->{children};
4595  
4596 # Traverse first to last to make it easy to record
4597 # first line of occurrence of each body column
4598 6 my @nodesToAlign = ();
4599 CHILD:
4600 6 ▶ for ( my $childIX = 0; $childIX <= $#$children ; $childIX+=2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($childIX <= $children->$#*) 15 6 21
4601 15 my $jog = $children->[$childIX];
4602 15 my $jogChildren = $jog->{children};
4603 15 my $jogChild1 = $jogChildren->[1];
4604 15 my $jogChild2 = $jogChildren->[2];
4605 15 my ( $line1 ) = $instance->nodeLC($jogChild1);
4606 15 my ( $line2 ) = $instance->nodeLC($jogChild2);
4607 15 ▶ next CHILD if $line1 ne $line2;
Branch: 1 branch
BranchTrueFalseTotal
if $line1 ne $line2 0 15 15
4608 15 push @nodesToAlign, $jogChild1, $jogChild2;
4609 }
4610 6 return $policy->findAlignment( \@nodesToAlign );
4611 }
4612  
4613 6 ▶sub check_1Jogging {
Subroutine check_1Jogging: called CC=5 SCAR=17.1
Pod undocumented
4614 6 my ( $policy, $node ) = @_;
4615 6 my $instance = $policy->{lint};
4616 6 my $lineToPos = $instance->{lineToPos};
4617  
4618 my ( $rune, $headGap, $head, $joggingGap, $jogging, $tistisGap, $tistis ) =
4619 6 @{ $policy->gapSeq($node) };
4620  
4621 6 my ( $runeLine, $runeColumn ) = $instance->nodeLC($rune);
4622 6 my ( $headLine, $headColumn ) = $instance->nodeLC($head);
4623 6 my ( $joggingLine, $joggingColumn ) = $instance->nodeLC($jogging);
4624 6 my ( $tistisLine, $tistisColumn ) = $instance->nodeLC($tistis);
4625  
4626 6 my $anchorLine = $runeLine;
4627 6 my ( $anchorColumn, $anchorData ) = $policy->reanchorInc(
4628 $node,
4629 {
4630 tallKetlus => 1,
4631 }
4632 );
4633 6 my $anchorDetails = $policy->anchorDetails( $node, $anchorData );
4634  
4635 6 my $joggingHoonData = $policy->joggingHoonData(
4636 { anchorColumn => $anchorColumn, firstOKJogLine => $headLine + 1 },
4637 $node );
4638 6 $policy->setInheritedAttribute( $node, 'joggingHoonData',
4639 $joggingHoonData );
4640 6 my $jogBaseColumn = $joggingHoonData->{jogBaseColumn};
4641 6 my $chessSide = $joggingHoonData->{chessSide};
4642  
4643 6 my $joggingRules = $instance->{joggingRule};
4644  
4645 6 my @mistakes = ();
4646 6 my $runeName = $policy->runeName($node);
4647  
4648 CHECK_HEAD: {
4649 6 ▶ if ( $headLine != $runeLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headLine != $runeLine) 0 6 6
4650 0 my $msg = sprintf
4651 "%s %s head %s; should be on rune line %d",
4652 $chessSide,
4653 $runeName,
4654 describeLC( $headLine, $headColumn ),
4655 $runeLine;
4656 push @mistakes,
4657 {
4658 desc => $msg,
4659 subpolicy => [ $runeName, 'split' ],
4660 parentLine => $runeLine,
4661 parentColumn => $runeColumn,
4662 line => $headLine,
4663 column => $headColumn,
4664 reportLine => $headLine,
4665 reportColumn => $headColumn,
4666 expectedLine => $runeLine,
4667 0 details => [ [ @{$anchorDetails} ]],
4668 };
4669 0 last CHECK_HEAD;
4670 }
4671  
4672 6 my $gapLength = $headGap->{length};
4673 6 ▶ my $expectedLength = ( $chessSide eq 'kingside' ? 2 : 4 );
Branch: 1 branch
BranchTrueFalseTotal
$chessSide eq 'kingside' ? : 6 0 6
4674 6 ▶ if ( $gapLength != $expectedLength ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($gapLength != $expectedLength) 0 6 6
4675 0 my $msg = sprintf
4676 "%s %s head %s; %s",
4677 $chessSide,
4678 $runeName,
4679 describeLC( $headLine, $headColumn ),
4680 describeMisindent2( $gapLength, $expectedLength );
4681 push @mistakes,
4682 {
4683 desc => $msg,
4684 subpolicy => [ $runeName, 'head-hgap' ],
4685 parentLine => $runeLine,
4686 parentColumn => $runeColumn,
4687 line => $headLine,
4688 column => $headColumn,
4689 reportLine => $headLine,
4690 reportColumn => $headColumn,
4691 0 details => [ [ @{$anchorDetails} ]],
4692 };
4693 }
4694 }
4695  
4696 CHECK_JOGGING_GAP: {
4697 6 ▶ if ( $headLine == $joggingLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headLine == $joggingLine) 0 6 6
4698 0 my $msg = sprintf
4699 "%s %s jogging %s should not be joined",
4700 $chessSide,
4701 $runeName,
4702 describeLC( $joggingLine, $joggingColumn );
4703 push @mistakes,
4704 {
4705 desc => $msg,
4706 subpolicy => [ $runeName, 'jogging-joined' ],
4707 parentLine => $runeLine,
4708 parentColumn => $runeColumn,
4709 line => $joggingLine,
4710 column => $joggingColumn,
4711 reportLine => $joggingLine,
4712 reportColumn => $joggingColumn,
4713 0 details => [ [ @{$anchorDetails} ]],
4714 };
4715 0 last CHECK_JOGGING_GAP;
4716 }
4717 push @mistakes,
4718 @{
4719 6 $policy->checkOneLineGap(
4720 $joggingGap,
4721 {
4722 mainColumn => $anchorColumn,
4723 preColumn => $jogBaseColumn,
4724 runeName => $runeName,
4725 subpolicy => [ $runeName, 'jogging-gap' ],
4726 parent => $rune,
4727 topicLines => [$joggingLine],
4728 6 details => [ [ @{$anchorDetails} ]],
4729 }
4730 )
4731 };
4732 }
4733  
4734 push @mistakes,
4735 @{
4736 6 $policy->checkOneLineGap(
4737 $tistisGap,
4738 {
4739 mainColumn => $anchorColumn,
4740 preColumn => $jogBaseColumn,
4741 runeName => $runeName,
4742 subpolicy => [ $runeName, 'tistis-gap' ],
4743 topicLines => [$tistisLine],
4744 6 details => [ [ @{$anchorDetails} ]],
4745 }
4746 )
4747 };
4748  
4749 push @mistakes,
4750 @{
4751 6 $policy->checkTistis(
4752 $tistis,
4753 {
4754 tag => $runeName,
4755 subpolicy => [$runeName],
4756 expectedColumn => $anchorColumn,
4757 6 details => [ [ @{$anchorDetails} ]],
4758 }
4759 )
4760 };
4761  
4762 6 return \@mistakes;
4763 }
4764  
4765 0 ▶sub check_2Jogging {
Subroutine check_2Jogging: not called CC=9 SCAR=45.0
Pod undocumented
4766 0 my ( $policy, $node ) = @_;
4767 0 my $instance = $policy->{lint};
4768 0 my $lineToPos = $instance->{lineToPos};
4769  
4770 0 my $runeName = $policy->runeName($node);
4771 my (
4772 $rune, $headGap, $head, $subheadGap, $subhead,
4773 $joggingGap, $jogging, $tistisGap, $tistis
4774 0 ) = @{ $policy->gapSeq($node) };
4775  
4776 0 my ( $runeLine, $runeColumn ) = $instance->nodeLC($rune);
4777 0 my ( $anchorLine, $anchorColumn ) = ( $runeLine, $runeColumn );
4778 0 my ( $headLine, $headColumn ) = $instance->nodeLC($head);
4779 0 my ( $subheadLine, $subheadColumn ) = $instance->nodeLC($subhead);
4780 0 my ( $joggingLine, $joggingColumn ) = $instance->nodeLC($jogging);
4781 0 my ( $tistisLine, $tistisColumn ) = $instance->nodeLC($tistis);
4782  
4783 0 my $joggingHoonData = $policy->joggingHoonData({}, $node );
4784 0 $policy->setInheritedAttribute($node, 'joggingHoonData', $joggingHoonData);
4785 0 my $jogBaseColumn = $joggingHoonData->{jogBaseColumn};
4786 0 my $chessSide = $joggingHoonData->{chessSide};
4787 0 my $isKingside = $chessSide eq 'kingside';
4788  
4789 0 my $joggingRules = $instance->{joggingRule};
4790  
4791 0 my @mistakes = ();
4792  
4793 0 my $isJoined = $headLine == $subheadLine;
4794 0 ▶ my @subpolicy =
Branch: 1 branch
BranchTrueFalseTotal
$isJoined ? : 0 0 0
4795 ( $runeName, $chessSide, ( $isJoined ? 'joined' : 'split' ) );
4796  
4797 0 ▶ if ( $headLine != $runeLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headLine != $runeLine) 0 0 0
4798 0 my $msg = sprintf
4799 "%s %s head %s; should be on rune line %d",
4800 $chessSide,
4801 $runeName,
4802 describeLC( $headLine, $headColumn ),
4803 $runeLine;
4804 0 push @mistakes,
4805 {
4806 desc => $msg,
4807 subpolicy => [ @subpolicy, 'head-split' ],
4808 parentLine => $runeLine,
4809 parentColumn => $runeColumn,
4810 reportLine => $headLine,
4811 reportColumn => $headColumn,
4812 line => $headLine,
4813 column => $headColumn,
4814 };
4815 }
4816  
4817 0 ▶ my $expectedHeadColumn = $anchorColumn + ( $isKingside ? 4 : 6 );
Branch: 1 branch
BranchTrueFalseTotal
$isKingside ? : 0 0 0
4818 0 ▶ if ( $headColumn != $expectedHeadColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headColumn != $expectedHeadColumn) 0 0 0
4819 0 my $msg = sprintf
4820 "%s %s head %s; %s",
4821 $chessSide,
4822 $runeName,
4823 describeLC( $headLine, $headColumn ),
4824 describeMisindent2( $headColumn, $expectedHeadColumn );
4825 0 push @mistakes,
4826 {
4827 desc => $msg,
4828 subpolicy => [ @subpolicy, 'head-hgap' ],
4829 parentLine => $runeLine,
4830 parentColumn => $runeColumn,
4831 reportLine => $headLine,
4832 reportColumn => $headColumn,
4833 line => $headLine,
4834 column => $headColumn,
4835 };
4836 }
4837  
4838 0 ▶ if ($isJoined) {
Branch: 1 branch
BranchTrueFalseTotal
if ($isJoined) 0 0 0
4839 0 my $subheadLength = $subheadGap->{length};
4840 0 ▶ if ($subheadLength != 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subheadLength != 2) 0 0 0
4841 0 my ( undef, $subheadGapColumn ) = $instance->nodeLC($subheadGap);
4842 0 my $expectedSubheadColumn = $subheadGapColumn + 2;
4843 0 my $msg = sprintf
4844 "%s %s subhead %s; %s",
4845 $chessSide,
4846 $runeName,
4847 describeLC( $subheadLine, $subheadColumn ),
4848 describeMisindent2( $subheadLength, 2 );
4849 0 push @mistakes,
4850 {
4851 desc => $msg,
4852 subpolicy => [ @subpolicy, 'subhead-hgap' ],
4853 parentLine => $runeLine,
4854 parentColumn => $runeColumn,
4855 reportLine => $subheadLine,
4856 reportColumn => $subheadColumn,
4857 line => $subheadLine,
4858 column => $subheadColumn,
4859 };
4860 }
4861 }
4862  
4863 0 ▶ if ( not $isJoined ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($isJoined) 0 0 0
4864  
4865 # If here, we have "split heads", which should follow the "pseudo-jog"
4866 # format
4867  
4868 push @mistakes,
4869 @{
4870 0 $policy->checkOneLineGap(
4871 $subheadGap,
4872 {
4873 mainColumn => $anchorColumn,
4874 runeName => $runeName,
4875 subpolicy => [ @subpolicy, 'subhead-vgap' ],
4876 topicLines => [$subheadLine],
4877 }
4878 )
4879 };
4880  
4881 0 my $expectedSubheadColumn = $headColumn - 2;
4882 0 ▶ if ( $subheadColumn != $expectedSubheadColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subheadColumn != $expectedSubheadColumn) 0 0 0
4883 0 my $msg = sprintf
4884 "%s %s subhead %s; %s",
4885 $chessSide,
4886 $runeName,
4887 describeLC( $subheadLine, $subheadColumn ),
4888 describeMisindent2( $subheadColumn, $expectedSubheadColumn );
4889 0 push @mistakes,
4890 {
4891 desc => $msg,
4892 subpolicy => [ @subpolicy, 'subhead-indent' ],
4893 parentLine => $runeLine,
4894 parentColumn => $runeColumn,
4895 reportLine => $subheadLine,
4896 reportColumn => $subheadColumn,
4897 line => $subheadLine,
4898 column => $subheadColumn,
4899 };
4900 }
4901 }
4902  
4903 push @mistakes,
4904 @{
4905 0 $policy->checkOneLineGap(
4906 $joggingGap,
4907 {
4908 mainColumn => $anchorColumn,
4909 preColumn => $jogBaseColumn,
4910 runeName => $runeName,
4911 subpolicy => [@subpolicy, 'jogging-vgap'],
4912 topicLines => [$joggingLine],
4913 }
4914 )
4915 };
4916  
4917 push @mistakes,
4918 @{
4919 0 $policy->checkOneLineGap(
4920 $tistisGap,
4921 {
4922 mainColumn => $anchorColumn,
4923 preColumn => $jogBaseColumn,
4924 runeName => $runeName,
4925 subpolicy => [@subpolicy, 'tistis-vgap'],
4926 topicLines => [$tistisLine],
4927 }
4928 )
4929 };
4930  
4931 push @mistakes,
4932 @{
4933 0 $policy->checkTistis(
4934 $tistis,
4935 {
4936 tag => $runeName,
4937 subpolicy => [@subpolicy],
4938 expectedColumn => $anchorColumn,
4939 }
4940 )
4941 };
4942  
4943 0 return \@mistakes;
4944 }
4945  
4946 0 ▶sub check_Jogging1 {
Subroutine check_Jogging1: not called CC=4 SCAR=30.0
Pod undocumented
4947 0 my ( $policy, $node ) = @_;
4948 0 my $instance = $policy->{lint};
4949 0 my $lineToPos = $instance->{lineToPos};
4950  
4951 0 my $runeName = $policy->runeName($node);
4952 my ( $rune, $joggingGap, $jogging, $tistisGap, $tistis, $tailGap, $tail ) =
4953 0 @{ $policy->gapSeq($node) };
4954  
4955 0 my ( $runeLine, $runeColumn ) = $instance->nodeLC($rune);
4956 0 my ( $joggingLine, $joggingColumn ) = $instance->nodeLC($jogging);
4957 0 my ( $tistisLine, $tistisColumn ) = $instance->nodeLC($tistis);
4958 0 my ( $tailLine, $tailColumn ) = $instance->nodeLC($tail);
4959 0 my ( $anchorLine, $anchorColumn ) = ( $runeLine, $runeColumn );
4960  
4961 0 my $joggingHoonData = $policy->joggingHoonData({}, $node );
4962 0 $policy->setInheritedAttribute($node, 'joggingHoonData', $joggingHoonData);
4963 0 my $jogBaseColumn = $joggingHoonData->{jogBaseColumn};
4964 0 my $chessSide = $joggingHoonData->{chessSide};
4965  
4966 0 my @mistakes = ();
4967  
4968 0 ▶ if ( $joggingLine != $runeLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($joggingLine != $runeLine) 0 0 0
4969 0 my $msg = sprintf
4970 "jogging %s; should be on rune line %d",
4971 describeLC( $joggingLine, $joggingColumn ),
4972 $runeLine;
4973 0 push @mistakes, {
4974 desc => $msg,
4975 subpolicy => [ $runeName, 'jogging', 'split' ],
4976 parentLine => $runeLine,
4977 parentColumn => $runeColumn,
4978 line => $joggingLine,
4979 column => $joggingColumn,
4980 reportLine => $joggingLine,
4981 reportColumn => $joggingColumn,
4982 expectedLine => $runeLine,
4983 };
4984 }
4985  
4986 0 ▶ if ( $joggingColumn != $jogBaseColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($joggingColumn != $jogBaseColumn) 0 0 0
4987 0 my $msg = sprintf
4988 "jogging %s; %s",
4989 describeLC( $joggingLine, $joggingColumn ),
4990 describeMisindent2( $joggingColumn, $jogBaseColumn );
4991 0 push @mistakes, {
4992 desc => $msg,
4993 subpolicy => [ $runeName, 'jogging-indent' ],
4994 parentLine => $runeLine,
4995 parentColumn => $runeColumn,
4996 line => $joggingLine,
4997 column => $joggingColumn,
4998 reportLine => $joggingLine,
4999 reportColumn => $joggingColumn,
5000 };
5001 }
5002  
5003 push @mistakes,
5004 @{
5005 0 $policy->checkOneLineGap(
5006 $tistisGap,
5007 {
5008 mainColumn => $anchorColumn,
5009 preColumn => $jogBaseColumn,
5010 runeName => $runeName,
5011 subpolicy => [$runeName, 'tistis-gap'],
5012 topicLines => [$tistisLine],
5013 }
5014 )
5015 };
5016  
5017 push @mistakes,
5018 @{
5019 0 $policy->checkTistis(
5020 $tistis,
5021 {
5022 tag => $runeName,
5023 subpolicy => [ $runeName ],
5024 expectedColumn => $anchorColumn + 2,
5025 }
5026 )
5027 };
5028  
5029 push @mistakes,
5030 @{
5031 0 $policy->checkOneLineGap(
5032 $tailGap,
5033 {
5034 mainColumn => $anchorColumn,
5035 runeName => $runeName,
5036 subpolicy => [$runeName, 'tail-vgap'],
5037 topicLines => [$tailLine],
5038 }
5039 )
5040 };
5041  
5042 0 my $expectedTailColumn = $anchorColumn;
5043 0 ▶ if ( $tailColumn != $expectedTailColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tailColumn != $expectedTailColumn) 0 0 0
5044 0 my $msg = sprintf
5045 "1-jogging tail %s; %s",
5046 describeLC( $tailLine, $tailColumn ),
5047 describeMisindent2( $tailColumn, $expectedTailColumn );
5048 0 push @mistakes,
5049 {
5050 desc => $msg,
5051 subpolicy => [ $runeName, 'tail-indent' ],
5052 parentLine => $runeLine,
5053 parentColumn => $runeColumn,
5054 line => $tailLine,
5055 column => $tailColumn,
5056 reportLine => $tailLine,
5057 reportColumn => $tailColumn,
5058 };
5059 }
5060  
5061 0 return \@mistakes;
5062 }
5063  
5064 0 ▶sub fascomBodyAlignment {
Subroutine fascomBodyAlignment: not called CC=3 SCAR=24.8
Pod undocumented
5065 0 my ( $policy, $node ) = @_;
5066 0 my $instance = $policy->{lint};
5067 0 my $children = $node->{children};
5068 0 my $firstBodyColumn;
5069 0 my %firstLine = ();
5070 0 my %bodyColumnCount = ();
5071 0 my @nodesToAlign = ();
5072  
5073 CHILD:
5074 0 ▶ for ( my $childIX = 0 ; $childIX <= $#$children ; $childIX++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($childIX <= $children->$#*) 0 0 0
5075 0 my $jog = $children->[$childIX];
5076 0 my ( $gap, $body ) = @{ $policy->gapSeq0($jog) };
5077 0 my ( $headLine, $headColumn ) = $instance->nodeLC($jog);
5078 0 my ( $bodyLine, $bodyColumn ) = $instance->nodeLC($body);
5079 0 ▶ next CHILD unless $headLine == $bodyLine;
Branch: 1 branch
BranchTrueFalseTotal
unless $headLine == $bodyLine 0 0 0
5080 0 push @nodesToAlign, $gap, $body;
5081 }
5082 0 return $policy->findAlignment( \@nodesToAlign );
5083 }
5084  
5085 # Find the body column, based on alignment within
5086 # a parent hoon.
5087 0 ▶sub fascomBodyColumn {
Subroutine fascomBodyColumn: not called CC=8 SCAR=42.8
Pod undocumented
5088 0 my ( $policy, $node ) = @_;
5089 0 my $nodeIX = $node->{IX};
5090 0 my $fascomBodyColumn = $policy->{perNode}->{$nodeIX}->{fascomBodyColumn};
5091 0 ▶ return $fascomBodyColumn if defined $fascomBodyColumn;
Branch: 1 branch
BranchTrueFalseTotal
if defined $fascomBodyColumn 0 0 0
5092  
5093 0 my $instance = $policy->{lint};
5094 0 my $nodeName = $instance->brickName($node);
5095 0 ▶ if ( not $nodeName or not $nodeName eq 'fordFascom' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($nodeName and $nodeName eq "fordFascom") 0 0 0
Condition0%0/3
$nodeName and $nodeName eq "fordFascom"
!ll&&!rl&&r
000
MC/DC0%0/2
$nodeName and $nodeName eq "fordFascom"
$nodeName $nodeName eq "fordFascom"
Truth table0%0/3
A and B
A= $nodeNameB= $nodeName eq "fordFascom"
ABresult
0X0
100
111
5096  
5097 0 my $fascomBodyColumn = $policy->fascomBodyColumn( $node->{PARENT} );
5098 0 $policy->{perNode}->{$nodeIX}->{fascomBodyColumn} = $fascomBodyColumn;
5099 0 return $fascomBodyColumn;
5100 }
5101  
5102 0 my $children = $node->{children};
5103 0 CHILD: for my $childIX ( 0 .. $#$children ) {
5104 0 my $child = $children->[$childIX];
5105 0 my $symbol = $instance->symbol($child);
5106 0 ▶ next CHILD if $symbol ne 'fordFascomBody';
Branch: 1 branch
BranchTrueFalseTotal
if $symbol ne "fordFascomBody" 0 0 0
5107 0 my $children2 = $child->{children};
5108 0 CHILD2: for my $childIX2 ( 0 .. $#$children2 ) {
5109 0 my $child2 = $children2->[$childIX2];
5110 0 my $symbol2 = $instance->symbol($child2);
5111 0 ▶ next CHILD2 if $symbol2 ne 'fordFascomElements';
Branch: 1 branch
BranchTrueFalseTotal
if $symbol2 ne "fordFascomElements" 0 0 0
5112 0 my $fascomBodyData = $policy->fascomBodyAlignment($child2);
5113 $policy->{perNode}->{$nodeIX}->{fascomBodyData} =
5114 0 $fascomBodyData;
5115 0 return $fascomBodyData;
5116 }
5117 }
5118 0 die "No jogging found for ", $instance->symbol($node);
5119 }
5120  
5121 # TODO: Add a check (optional?) for queenside joggings with no
5122 # split jogs.
5123 0 ▶sub checkFascomElement {
Subroutine checkFascomElement: not called CC=11 SCAR=48.8
Pod undocumented
5124 0 my ( $policy, $node ) = @_;
5125 0 my $instance = $policy->{lint};
5126  
5127 0 my $runeNode = $instance->ancestorByBrickName( $node, 'fordFascom' );
5128 0 my $runeNodeIX = $runeNode->{IX};
5129 0 my $isJoined = $policy->{perNode}->{$runeNodeIX}->{isJoined};
5130 0 my $chessSide = $policy->{perNode}->{$runeNodeIX}->{chessSide};
5131 0 my $queenside = $chessSide eq 'queenside';
5132  
5133 0 my ( $runeLine, $runeColumn ) = $instance->nodeLC($runeNode);
5134 0 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
5135 0 my ( $headLine, $headColumn ) = ( $parentLine, $parentColumn );
5136  
5137 0 my ( $gap, $body ) = @{ $policy->gapSeq0($node) };
5138 0 my ( $bodyLine, $bodyColumn ) = $instance->nodeLC($body);
5139  
5140 0 my $anchorLine = $runeLine;
5141 0 my ( $anchorColumn, $anchorData ) = $policy->reanchorInc(
5142 $runeNode,
5143 {
5144 fordFascen => 1,
5145 }
5146 );
5147 0 my $anchorDetails = $policy->anchorDetails( $node, $anchorData );
5148  
5149 my ( $fascomBodyColumn, $fascomBodyColumnDetails ) =
5150 0 @{ $policy->fascomBodyColumn( $node, { fordFascom => 1 } ) };
5151  
5152 0 my @mistakes = ();
5153 0 my $tag = 'fascom-element';
5154  
5155 0 ▶ my $baseColumn = $anchorColumn + ($isJoined ? 4 : 2) + ($queenside ? 2 : 0);
Branch: 2 branches
BranchTrueFalseTotal
$isJoined ? : 0 0 0
$queenside ? : 0 0 0
5156  
5157 0 ▶ if ( $headLine == $bodyLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headLine == $bodyLine) 0 0 0
5158 0 my $gapLength = $gap->{length};
5159  
5160 0 ▶ if ( $gapLength != 2 and $bodyColumn != $fascomBodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($gapLength != 2 and $bodyColumn != $fascomBodyColumn) 0 0 0
Condition0%0/3
$gapLength != 2 and $bodyColumn != $fascomBodyColumn
!ll&&!rl&&r
000
MC/DC0%0/2
$gapLength != 2 and $bodyColumn != $fascomBodyColumn
$gapLength != 2 $bodyColumn != $fascomBodyColumn
Truth table0%0/3
A and B
A= $gapLength != 2B= $bodyColumn != $fascomBodyColumn
ABresult
0X0
100
111
5161 0 my $msg = sprintf 'Fascom element body %s; %s',
5162 describeLC( $bodyLine, $bodyColumn ),
5163 describeMisindent2( $bodyColumn, $fascomBodyColumn );
5164 push @mistakes,
5165 {
5166 desc => $msg,
5167 subpolicy => [ $tag, 'body-hgap' ],
5168 0 details => [ [ @{$anchorDetails} ] ],
5169 parentLine => $parentLine,
5170 parentColumn => $parentColumn,
5171 line => $bodyLine,
5172 column => $bodyColumn,
5173 reportLine => $bodyLine,
5174 reportColumn => $bodyColumn,
5175 topicLines => [$runeLine],
5176 };
5177 }
5178 0 return \@mistakes;
5179 }
5180  
5181 # If here head line != body line
5182 0 my $pseudojoinColumn = $policy->pseudojoinColumn($gap);
5183 0 ▶ if ( $pseudojoinColumn >= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pseudojoinColumn >= 0) 0 0 0
5184 0 my $expectedBodyColumn = $pseudojoinColumn;
5185 0 ▶ if ( $bodyColumn != $expectedBodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyColumn != $expectedBodyColumn) 0 0 0
5186 0 my $msg =
5187 sprintf
5188 'Pseudo-joined Fascom element %s; body/comment mismatch; body is %s',
5189 describeLC( $parentLine, $parentColumn ),
5190 describeMisindent2( $bodyColumn, $expectedBodyColumn );
5191 push @mistakes,
5192 {
5193 desc => $msg,
5194 subpolicy => [ $tag, 'pseudo-comment-indent' ],
5195 0 details => [ [ @{$anchorDetails} ] ],
5196 parentLine => $parentLine,
5197 parentColumn => $parentColumn,
5198 line => $bodyLine,
5199 column => $bodyColumn,
5200 reportLine => $bodyLine,
5201 reportColumn => $bodyColumn,
5202 topicLines => [$runeLine],
5203 };
5204 }
5205  
5206 # Treat the fascom body alignment as the "expected one"
5207 0 my $expectedColumn = $fascomBodyColumn;
5208 0 ▶ if ( $bodyColumn != $expectedColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyColumn != $expectedColumn) 0 0 0
5209 0 my $msg = sprintf 'Pseudo-joined Fascom element %s; body %s',
5210 describeLC( $parentLine, $parentColumn ),
5211 describeMisindent2( $bodyColumn, $expectedBodyColumn );
5212 push @mistakes,
5213 {
5214 desc => $msg,
5215 subpolicy => [ $tag, 'pseudo-hgap' ],
5216 0 details => [ [ @{$anchorDetails} ] ],
5217 parentLine => $parentLine,
5218 parentColumn => $parentColumn,
5219 line => $bodyLine,
5220 column => $bodyColumn,
5221 reportLine => $bodyLine,
5222 reportColumn => $bodyColumn,
5223 topicLines => [$runeLine],
5224 };
5225 }
5226 0 return \@mistakes;
5227 }
5228  
5229 # If here, this is (or should be) a split jog
5230 0 ▶ my $expectedBodyColumn = $headColumn + ($queenside ? -2 : 2);
Branch: 1 branch
BranchTrueFalseTotal
$queenside ? : 0 0 0
5231  
5232 0 ▶ if ( $bodyColumn != $expectedBodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyColumn != $expectedBodyColumn) 0 0 0
5233 0 my $msg = sprintf 'Fascom element body %s; %s',
5234 describeLC( $bodyLine, $bodyColumn ),
5235 describeMisindent2( $bodyColumn, $expectedBodyColumn );
5236 push @mistakes,
5237 {
5238 desc => $msg,
5239 subpolicy => [ $tag, 'body-indent' ],
5240 0 details => [ [ @{$anchorDetails} ] ],
5241 parentLine => $parentLine,
5242 parentColumn => $parentColumn,
5243 line => $bodyLine,
5244 column => $bodyColumn,
5245 reportLine => $bodyLine,
5246 reportColumn => $bodyColumn,
5247 topicLines => [$runeLine],
5248 };
5249 0 return \@mistakes;
5250 }
5251  
5252 push @mistakes,
5253 @{
5254 0 $policy->checkOneLineGap(
5255 $gap,
5256 {
5257 mainColumn => $expectedBodyColumn,
5258 runeName => $tag,
5259 subpolicy => [ $tag ],
5260 0 details => [ [ @{$anchorDetails} ] ],
5261 topicLines => [$runeLine],
5262 }
5263 )
5264 };
5265  
5266 0 return \@mistakes;
5267 }
5268  
5269 0 ▶sub checkFastis {
Subroutine checkFastis: not called CC=6 SCAR=37.4
Pod undocumented
5270 0 my ( $policy, $node ) = @_;
5271 0 my $instance = $policy->{lint};
5272  
5273 # fordFastis ::= (- FASTISGAP -) SYM4K (- GAP -) horn
5274 0 my ( $headGap, $symbol, $hornGap, $horn ) = @{ $policy->gapSeq0($node) };
5275 0 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
5276 0 my ( $symbolLine, $symbolColumn ) = $instance->nodeLC($symbol);
5277 0 my ( $hornLine, $hornColumn ) = $instance->nodeLC($horn);
5278  
5279 0 my @mistakes = ();
5280 0 my $runeName = 'fastis';
5281 0 my $tag = 'fastis';
5282  
5283 CHECK_SYMBOL: {
5284 0 ▶ if ( $symbolLine != $parentLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($symbolLine != $parentLine) 0 0 0
5285 0 my $msg = sprintf 'fastis symbol %s; symbol must be on rune line',
5286 describeLC( $symbolLine, $symbolColumn );
5287 0 push @mistakes,
5288 {
5289 desc => $msg,
5290 subpolicy => [ $runeName, 'same-line' ],
5291 parentLine => $parentLine,
5292 parentColumn => $parentColumn,
5293 line => $symbolLine,
5294 column => $symbolColumn,
5295 reportLine => $symbolLine,
5296 reportColumn => $symbolColumn,
5297 };
5298 0 last CHECK_SYMBOL;
5299 }
5300  
5301 0 my $expectedSymbolColumn = $parentColumn + 4;
5302 0 ▶ if ( $symbolColumn != $expectedSymbolColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($symbolColumn != $expectedSymbolColumn) 0 0 0
5303 0 my $msg = sprintf 'fastis symbol %s; %s',
5304 describeLC( $symbolLine, $symbolColumn ),
5305 describeMisindent2( $symbolColumn, $expectedSymbolColumn );
5306 0 push @mistakes,
5307 {
5308 desc => $msg,
5309 subpolicy => [ $runeName, 'head-hgap' ],
5310 parentLine => $parentLine,
5311 parentColumn => $parentColumn,
5312 line => $symbolLine,
5313 column => $symbolColumn,
5314 reportLine => $symbolLine,
5315 reportColumn => $symbolColumn,
5316 };
5317 }
5318 }
5319  
5320 CHECK_HORN: {
5321 0 ▶ if ( $hornLine == $symbolLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hornLine == $symbolLine) 0 0 0
5322 0 my $symbolLength = $symbol->{length};
5323 0 my $expectedHornColumn = $symbolColumn + $symbolLength + 2;
5324 0 ▶ if ( $hornColumn != $expectedHornColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hornColumn != $expectedHornColumn) 0 0 0
5325 0 my $msg = sprintf 'fastis horn %s; %s',
5326 describeLC( $hornLine, $hornColumn ),
5327 describeMisindent2( $hornColumn, $expectedHornColumn );
5328 0 push @mistakes,
5329 {
5330 desc => $msg,
5331 subpolicy => [ $runeName, 'body-hgap' ],
5332 parentLine => $parentLine,
5333 parentColumn => $parentColumn,
5334 line => $hornLine,
5335 column => $hornColumn,
5336 reportLine => $hornLine,
5337 reportColumn => $hornColumn,
5338 };
5339 }
5340 0 last CHECK_HORN;
5341 }
5342  
5343 # if here, horn Line != symbol line
5344 0 my $expectedHornColumn = $parentColumn + 2;
5345  
5346 push @mistakes,
5347 @{
5348 0 $policy->checkOneLineGap(
5349 $hornGap,
5350 {
5351 mainColumn => $expectedHornColumn,
5352 runeName => $tag,
5353 subpolicy => [ $runeName ],
5354 }
5355 )
5356 };
5357  
5358 0 ▶ if ( $hornColumn != $expectedHornColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hornColumn != $expectedHornColumn) 0 0 0
5359 0 my $msg = sprintf 'fastis split horn %s; %s',
5360 describeLC( $hornLine, $hornColumn ),
5361 describeMisindent2( $hornColumn, $expectedHornColumn );
5362 0 push @mistakes,
5363 {
5364 desc => $msg,
5365 subpolicy => [ $runeName, 'body-indent' ],
5366 parentLine => $parentLine,
5367 parentColumn => $parentColumn,
5368 line => $hornLine,
5369 column => $hornColumn,
5370 reportLine => $hornLine,
5371 reportColumn => $hornColumn,
5372 };
5373 }
5374  
5375 }
5376  
5377 0 return \@mistakes;
5378 }
5379  
5380 15 ▶sub checkKingsideJog {
Subroutine checkKingsideJog: called CC=12 SCAR=38.9
Pod undocumented
5381 15 my ( $policy, $node, $expectedHeadColumn ) = @_;
5382 15 my $instance = $policy->{lint};
5383 15 my $fileName = $instance->{fileName};
5384 15 my $grammar = $instance->{grammar};
5385 15 my $ruleID = $node->{ruleID};
5386 my ( $parentLine, $parentColumn ) =
5387 15 $instance->line_column( $node->{start} );
5388  
5389 15 my $joggingHoonData = $policy->getInheritedAttribute($node, 'joggingHoonData');
5390 15 my $jogBodyColumn = $joggingHoonData->{bodyAlignment};
5391 15 ▶ $jogBodyColumn //= -1;
Condition50%1/2
$jogBodyColumn //= -1
l!l
150
MC/DC0%0/1
$jogBodyColumn //= -1
$jogBodyColumn
Truth table50%1/2
A
A= $jogBodyColumn
Aresult
11
00
5392 15 my $jogBodyColumnLines = $joggingHoonData->{alignments};
5393 15 my $runeName = $joggingHoonData->{runeName};
5394 15 my $brickNode = $joggingHoonData->{node};
5395 15 my ( $brickLine, $brickColumn ) = $instance->nodeLC($brickNode);
5396 15 my $baseColumn = $joggingHoonData->{jogBaseColumn};
5397  
5398 15 my @mistakes = ();
5399  
5400 15 my $children = $node->{children};
5401 15 my $head = $children->[0];
5402 15 my $gap = $children->[1];
5403 15 my $body = $children->[2];
5404 my ( $headLine, $headColumn ) =
5405 15 $instance->line_column( $head->{start} );
5406 my ( $bodyLine, $bodyColumn ) =
5407 15 $instance->line_column( $body->{start} );
5408 15 my $sideDesc = 'kingside';
5409  
5410 15 ▶ if ( $headColumn != $expectedHeadColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headColumn != $expectedHeadColumn) 0 15 15
5411 0 my $msg = sprintf 'Jog %s head %s; %s',
5412 $sideDesc,
5413 describeLC( $headLine, $headColumn ),
5414 describeMisindent2( $headColumn, $expectedHeadColumn );
5415 0 push @mistakes,
5416 {
5417 desc => $msg,
5418 subpolicy => [ $runeName, 'jog-head-indent' ],
5419 parentLine => $parentLine,
5420 parentColumn => $parentColumn,
5421 line => $headLine,
5422 column => $headColumn,
5423 reportLine => $headLine,
5424 reportColumn => $headColumn,
5425 topicLines => [$brickLine],
5426 };
5427 }
5428  
5429 15 ▶ if ( $headLine == $bodyLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headLine == $bodyLine) 15 0 15
5430 15 my $gapLength = $gap->{length};
5431  
5432 15 ▶ if ( $gapLength != 2 and $bodyColumn != $jogBodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($gapLength != 2 and $bodyColumn != $jogBodyColumn) 0 15 15
Condition33%1/3
$gapLength != 2 and $bodyColumn != $jogBodyColumn
!ll&&!rl&&r
1500
MC/DC0%0/2
$gapLength != 2 and $bodyColumn != $jogBodyColumn
$gapLength != 2 $bodyColumn != $jogBodyColumn
Truth table33%1/3
A and B
A= $gapLength != 2B= $bodyColumn != $jogBodyColumn
ABresult
0X0
100
111
5433 0 my $misindent;
5434 my $details;
5435 0 my @topicLines = ($brickLine);
5436 0 ▶ if ( $jogBodyColumn < 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($jogBodyColumn < 0) { } 0 0 0
5437 0 $misindent = describeMisindent2( $gapLength, 2 );
5438 0 $details = [ [ "no inter-line alignment detected" ] ];
5439 }
5440 else {
5441 0 $misindent = describeMisindent2( $bodyColumn, $jogBodyColumn );
5442 0 my $oneBasedColumn = $jogBodyColumn + 1;
5443 0 push @topicLines, @{$jogBodyColumnLines};
5444 $details = [
5445 [
5446 sprintf 'inter-line alignment is %d, see %s',
5447 $oneBasedColumn,
5448 (
5449 join q{ },
5450 0 map { $_ . ':' . $oneBasedColumn }
5451 0 @{$jogBodyColumnLines}
5452 )
5453 ]
5454 ];
5455 }
5456 0 my $msg = sprintf 'Jog %s body %s; %s',
5457 $sideDesc,
5458 describeLC( $bodyLine, $bodyColumn ),
5459 $misindent;
5460 0 push @mistakes,
5461 {
5462 desc => $msg,
5463 subpolicy => [ $runeName, 'jog-body-indent' ],
5464 parentLine => $parentLine,
5465 parentColumn => $parentColumn,
5466 line => $bodyLine,
5467 column => $bodyColumn,
5468 reportLine => $bodyLine,
5469 reportColumn => $bodyColumn,
5470 topicLines => \@topicLines,
5471 details => $details,
5472 };
5473 }
5474 15 return \@mistakes;
5475 }
5476  
5477 # If here head line != body line
5478 0 my $pseudojoinColumn = $policy->pseudojoinColumn($gap);
5479 0 ▶ if ( $pseudojoinColumn >= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pseudojoinColumn >= 0) 0 0 0
5480 0 my $expectedBodyColumn = $pseudojoinColumn;
5481 0 ▶ if ( $bodyColumn != $expectedBodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyColumn != $expectedBodyColumn) 0 0 0
5482 0 my $msg =
5483 sprintf
5484 'Pseudo-joined %s Jog %s; body/comment mismatch; body is %s',
5485 $sideDesc,
5486 describeLC( $parentLine, $parentColumn ),
5487 describeMisindent2( $bodyColumn, $expectedBodyColumn );
5488 0 push @mistakes,
5489 {
5490 desc => $msg,
5491 subpolicy => [ $runeName, 'jog-pseudojoin-mismatch' ],
5492 parentLine => $parentLine,
5493 parentColumn => $parentColumn,
5494 line => $bodyLine,
5495 column => $bodyColumn,
5496 reportLine => $bodyLine,
5497 reportColumn => $bodyColumn,
5498 topicLines => [$brickLine],
5499 };
5500 }
5501 0 my $headLength = $head->{length};
5502  
5503 # Treat the jogging body alignment as the "expected one"
5504 0 my $expectedColumn = $jogBodyColumn;
5505 0 my $raggedColumn = $headColumn + $headLength + 2;
5506 0 ▶ if ( $bodyColumn != $raggedColumn and $bodyColumn != $expectedColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyColumn != $raggedColumn and $bodyColumn != $expectedColumn) 0 0 0
Condition0%0/3
$bodyColumn != $raggedColumn and $bodyColumn != $expectedColumn
!ll&&!rl&&r
000
MC/DC0%0/2
$bodyColumn != $raggedColumn and $bodyColumn != $expectedColumn
$bodyColumn != $raggedColumn $bodyColumn != $expectedColumn
Truth table0%0/3
A and B
A= $bodyColumn != $raggedColumnB= $bodyColumn != $expectedColumn
ABresult
0X0
100
111
5507 0 my $msg = sprintf 'Pseudo-joined %s Jog %s; body %s',
5508 $sideDesc, describeLC( $parentLine, $parentColumn ),
5509 describeMisindent2( $bodyColumn, $expectedBodyColumn );
5510 0 push @mistakes,
5511 {
5512 desc => $msg,
5513 subpolicy => [ $runeName, 'jog-pseudojoin-indent' ],
5514 parentLine => $parentLine,
5515 parentColumn => $parentColumn,
5516 line => $bodyLine,
5517 column => $bodyColumn,
5518 reportLine => $bodyLine,
5519 reportColumn => $bodyColumn,
5520 topicLines => [$brickLine],
5521 };
5522 }
5523 0 return \@mistakes;
5524 }
5525  
5526 # If here, this is (or should be) a split jog
5527 0 my $expectedBodyColumn = $baseColumn + 2;
5528  
5529 0 ▶ if ( $bodyColumn != $expectedBodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyColumn != $expectedBodyColumn) 0 0 0
5530 0 my $msg = sprintf 'Jog %s body %s; %s',
5531 $sideDesc,
5532 describeLC( $bodyLine, $bodyColumn ),
5533 describeMisindent2( $bodyColumn, $expectedBodyColumn );
5534 0 push @mistakes,
5535 {
5536 desc => $msg,
5537 subpolicy => [ $runeName, 'jog-body-indent' ],
5538 parentLine => $parentLine,
5539 parentColumn => $parentColumn,
5540 line => $bodyLine,
5541 column => $bodyColumn,
5542 reportLine => $bodyLine,
5543 reportColumn => $bodyColumn,
5544 topicLines => [$brickLine],
5545 details => [
5546 [
5547 sprintf qq{lexeme "%s" %s},
5548 $instance->lexeme( $brickLine, $brickColumn ),
5549 describeLC( $brickLine, $brickColumn )
5550 ]
5551 ],
5552 };
5553 0 return \@mistakes;
5554 }
5555  
5556 push @mistakes,
5557 @{
5558 0 $policy->checkOneLineGap(
5559 $gap,
5560 {
5561 mainColumn => $expectedBodyColumn,
5562 runeName => $runeName,
5563 subpolicy => [ $runeName ],
5564 topicLines => [ $bodyLine, $brickLine ],
5565 }
5566 )
5567 };
5568  
5569 0 return \@mistakes;
5570 }
5571  
5572 0 ▶sub checkQueensideJog {
Subroutine checkQueensideJog: not called CC=8 SCAR=42.8
Pod undocumented
5573 0 my ( $policy, $node, $expectedHeadColumn ) = @_;
5574 0 my $instance = $policy->{lint};
5575 my ( $parentLine, $parentColumn ) =
5576 0 $instance->line_column( $node->{start} );
5577 0 my $ruleID = $node->{ruleID};
5578 0 my $fileName = $instance->{fileName};
5579 0 my $grammar = $instance->{grammar};
5580  
5581 0 my @mistakes = ();
5582  
5583 0 my $joggingRules = $instance->{joggingRule};
5584 0 my $joggingHoonData = $policy->getInheritedAttribute($node, 'joggingHoonData');
5585 0 my $jogBodyColumn = $joggingHoonData->{bodyAlignment};
5586 0 ▶ $jogBodyColumn //= -1;
Condition0%0/2
$jogBodyColumn //= -1
l!l
00
MC/DC0%0/1
$jogBodyColumn //= -1
$jogBodyColumn
Truth table0%0/2
A
A= $jogBodyColumn
Aresult
11
00
5587 0 my $jogBodyColumnLines = $joggingHoonData->{alignments};
5588 0 my $runeName = $joggingHoonData->{runeName};
5589 0 my $brickNode = $joggingHoonData->{node};
5590 0 my ( $brickLine, $brickColumn ) = $instance->nodeLC($brickNode);
5591 0 my $baseColumn = $joggingHoonData->{jogBaseColumn};
5592  
5593 0 my $children = $node->{children};
5594 0 my $head = $children->[0];
5595 0 my $gap = $children->[1];
5596 0 my $body = $children->[2];
5597 my ( $headLine, $headColumn ) =
5598 0 $instance->line_column( $head->{start} );
5599 my ( $bodyLine, $bodyColumn ) =
5600 0 $instance->line_column( $body->{start} );
5601 0 my $sideDesc = 'queenside';
5602  
5603 0 ▶ if ( $headColumn != $expectedHeadColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headColumn != $expectedHeadColumn) 0 0 0
5604 0 my $msg = sprintf 'Jog %s head %s; %s',
5605 $sideDesc,
5606 describeLC( $headLine, $headColumn ),
5607 describeMisindent2( $headColumn, $expectedHeadColumn );
5608 0 push @mistakes,
5609 {
5610 desc => $msg,
5611 subpolicy => [ $runeName, 'jog-head-indent' ],
5612 parentLine => $parentLine,
5613 parentColumn => $parentColumn,
5614 line => $headLine,
5615 column => $headColumn,
5616 reportLine => $headLine,
5617 reportColumn => $headColumn,
5618 topicLines => [$brickLine],
5619 };
5620 }
5621  
5622 # Check for flat queenside misalignments
5623 0 my $expectedBodyColumn = $jogBodyColumn;
5624 0 ▶ if ( $headLine == $bodyLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headLine == $bodyLine) 0 0 0
5625 0 my $gapLength = $gap->{length};
5626 0 ▶ if ( $gapLength != 2 and $bodyColumn != $jogBodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($gapLength != 2 and $bodyColumn != $jogBodyColumn) 0 0 0
Condition0%0/3
$gapLength != 2 and $bodyColumn != $jogBodyColumn
!ll&&!rl&&r
000
MC/DC0%0/2
$gapLength != 2 and $bodyColumn != $jogBodyColumn
$gapLength != 2 $bodyColumn != $jogBodyColumn
Truth table0%0/3
A and B
A= $gapLength != 2B= $bodyColumn != $jogBodyColumn
ABresult
0X0
100
111
5627 0 my $misindent;
5628 my $details;
5629 0 my @topicLines = ($brickLine);
5630 0 ▶ if ($jogBodyColumn < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($jogBodyColumn < 0) { } 0 0 0
5631 0 $misindent = describeMisindent2( $gapLength, 2 );
5632 0 $details = [
5633 [
5634 "no inter-line alignment detected"
5635 ]
5636 ];
5637 } else {
5638 0 $misindent = describeMisindent2( $bodyColumn, $jogBodyColumn );
5639 0 my $oneBasedColumn = $jogBodyColumn+1;
5640 0 push @topicLines, @{$jogBodyColumnLines};
5641 $details = [
5642 [
5643 sprintf 'inter-line alignment is %d, see %s', $oneBasedColumn,
5644 0 (join q{ }, map { $_ . ':' . $oneBasedColumn } @{$jogBodyColumnLines})
5645 ]
5646 ];
5647 }
5648 0 my $msg = sprintf 'Jog %s body %s; %s',
5649 $sideDesc,
5650 describeLC( $bodyLine, $bodyColumn ),
5651 $misindent;
5652 0 push @mistakes,
5653 {
5654 desc => $msg,
5655 subpolicy => [ $runeName, 'jog-body-indent' ],
5656 parentLine => $parentLine,
5657 parentColumn => $parentColumn,
5658 line => $bodyLine,
5659 column => $bodyColumn,
5660 reportLine => $bodyLine,
5661 reportColumn => $bodyColumn,
5662 topicLines => \@topicLines,
5663 details => $details,
5664 };
5665 }
5666 0 return \@mistakes;
5667 }
5668  
5669 # If here, this is a split jog
5670 0 $expectedBodyColumn = $brickColumn + 2;
5671 0 ▶ if ( $bodyColumn != $expectedBodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyColumn != $expectedBodyColumn) 0 0 0
5672  
5673 0 my $msg = sprintf 'Jog %s body %s; %s',
5674 $sideDesc,
5675 describeLC( $bodyLine, $bodyColumn ),
5676 describeMisindent2( $bodyColumn, $expectedBodyColumn );
5677 0 push @mistakes,
5678 {
5679 desc => $msg,
5680 subpolicy => [ $runeName, 'jog-body-indent' ],
5681 parentLine => $parentLine,
5682 parentColumn => $parentColumn,
5683 line => $bodyLine,
5684 column => $bodyColumn,
5685 reportLine => $bodyLine,
5686 reportColumn => $bodyColumn,
5687 topicLines => [$brickLine],
5688 details => [
5689 [
5690 sprintf qq{lexeme "%s" %s},
5691 $instance->lexeme( $brickLine, $brickColumn ),
5692 describeLC( $brickLine, $brickColumn )
5693 ]
5694 ],
5695 };
5696 0 return \@mistakes;
5697 }
5698  
5699 push @mistakes,
5700 @{
5701 0 $policy->checkOneLineGap(
5702 $gap,
5703 {
5704 mainColumn => $expectedBodyColumn,
5705 runeName => $runeName,
5706 subpolicy => [ $runeName ],
5707 topicLines => [ $bodyLine, $brickLine ],
5708 }
5709 )
5710 };
5711  
5712 0 return \@mistakes;
5713 }
5714  
5715 # TODO: Add a check (optional?) for queenside joggings with no
5716 # split jogs.
5717 15 ▶sub checkJog {
Subroutine checkJog: called CC=3 SCAR=11.1
Pod undocumented
5718 15 my ( $policy, $node ) = @_;
5719 15 my $instance = $policy->{lint};
5720  
5721 15 my $joggingHoonData = $policy->getInheritedAttribute($node, 'joggingHoonData');
5722 15 my $jogBaseColumn = $joggingHoonData->{jogBaseColumn};
5723  
5724 # This is to suppress detailed complaints about the first jog
5725 # of a "joined" jogging. A complaint will be made at the jogging
5726 # hoon level, and the detailed ones for the jog are redundant
5727 # and confusing.
5728 15 my $firstOKJogLine = $joggingHoonData->{firstOKJogLine};
5729 15 my ($jogLine) = $instance->nodeLC($node);
5730 15 ▶ return [] if $jogLine < $firstOKJogLine;
Branch: 1 branch
BranchTrueFalseTotal
if $jogLine < $firstOKJogLine 0 15 15
5731  
5732 15 my $chessSide = $joggingHoonData->{chessSide};
5733 15 ▶ return $policy->checkQueensideJog($node, $jogBaseColumn)
Branch: 1 branch
BranchTrueFalseTotal
if $chessSide eq "queenside" 0 15 15
5734 if $chessSide eq 'queenside';
5735 15 return $policy->checkKingsideJog($node, $jogBaseColumn);
5736 }
5737  
5738 # not yet implemented
5739 0 ▶sub checkNYI {
Subroutine checkNYI: not called CC=1 SCAR=6.9
Pod undocumented
5740 0 my ( $policy, $node ) = @_;
5741 0 my $instance = $policy->{lint};
5742 0 my $grammar = $instance->{grammar};
5743 my ( $parentLine, $parentColumn ) =
5744 0 $instance->line_column( $node->{start} );
5745 0 my $ruleID = $node->{ruleID};
5746 0 my @mistakes = ();
5747  
5748 my $msg = join q{ }, 'NYI', '[' . $instance->symbol($node) . ']',
5749 $instance->describeNodeRange($node),
5750 0 ( map { $grammar->symbol_display_form($_) }
5751 $grammar->rule_expand($ruleID) );
5752 0 push @mistakes,
5753 {
5754 desc => $msg,
5755 parentLine => $parentLine,
5756 parentColumn => $parentColumn,
5757 line => $parentLine,
5758 column => $parentColumn,
5759 };
5760 0 return \@mistakes;
5761 }
5762  
5763 153 ▶sub checkBackdented {
Subroutine checkBackdented: called CC=37 SCAR=57.9
Pod undocumented
5764 153 my ( $policy, $node ) = @_;
5765 153 my $nodeIX = $node->{IX};
5766 153 my @gapSeq = @{ $policy->gapSeq0($node) };
5767 153 my $elementCount = ( scalar @gapSeq ) / 2;
5768 153 my $instance = $policy->{lint};
5769 153 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
5770 153 my @mistakes = ();
5771 153 my $runeName = $policy->runeName($node);
5772  
5773 153 my $chainOffset = 0;
5774 153 my $chainAlignments;
5775 153 my $chainAlignmentData = $policy->chainAlignmentData($node);
5776 153 ▶ if ($chainAlignmentData) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chainAlignmentData) 153 0 153
5777 153 $chainOffset = $chainAlignmentData->{offset};
5778 153 $chainAlignments = $chainAlignmentData->{alignments};
5779 }
5780  
5781 my $runningAlignments =
5782 153 $policy->{perNode}->{$nodeIX}->{runningAlignments};
5783 # say STDERR join " ", __FILE__, __LINE__, "nodeIX:", $nodeIX;
5784  
5785 153 my $reanchorOffset; # for re-anchoring logic
5786  
5787 ENFORCE_ELEMENT1_JOINEDNESS: {
5788  
5789 # TODO: Is this right?
5790 153 my $firstGap = $gapSeq[0];
5791 153 my ($gapLine) = $instance->nodeLC($firstGap);
5792 153 ▶ last ENFORCE_ELEMENT1_JOINEDNESS if $gapLine == $parentLine;
Branch: 1 branch
BranchTrueFalseTotal
if $gapLine == $parentLine 153 0 153
5793 0 my $gapLiteral = $instance->literalNode($firstGap);
5794 0 ▶ $gapLiteral = substr( $gapLiteral, 2 )
Branch: 1 branch
BranchTrueFalseTotal
if $instance->runeGapNode($firstGap) 0 0 0
5795 if $instance->runeGapNode($firstGap);
5796  
5797 # Only enforce if 1st line is spaces --
5798 # comments, etc., are caught by the logic to follow
5799 0 ▶ last ENFORCE_ELEMENT1_JOINEDNESS unless $gapLiteral =~ /^[ ]*\n/;
Branch: 1 branch
BranchTrueFalseTotal
unless $gapLiteral =~ /^[ ]*\n/ 0 0 0
5800 0 my $element = $gapSeq[1];
5801 0 my ( $elementLine, $elementColumn ) = $instance->nodeLC($element);
5802 0 my $msg = sprintf
5803 '%d-element backdent must be joined %s',
5804 $elementCount,
5805 describeLC( $elementLine, $elementColumn );
5806 0 push @mistakes,
5807 {
5808 desc => $msg,
5809 subpolicy => [ $runeName, 'element-1-split' ],
5810 parentLine => $parentLine,
5811 parentColumn => $parentColumn,
5812 line => $elementLine,
5813 column => $elementColumn,
5814 reportLine => $elementLine,
5815 reportColumn => $elementColumn,
5816 };
5817 }
5818  
5819 # my $anchorNode = $instance->anchorNode($node);
5820 # my ( $anchorLine, $anchorColumn ) = $instance->nodeLC($anchorNode);
5821 153 my ( $anchorLine, $anchorColumn ) = ( $parentLine, $parentColumn );
5822 153 my $anchorData;
5823 153 ▶ if ( my $sources = $reanchorings{$runeName} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $sources = $reanchorings{$runeName}) 123 30 153
5824 123 ( $anchorColumn, $anchorData ) =
5825 $policy->reanchorInc( $node, $sources );
5826 }
5827  
5828 153 my $anchorDetails = [];
5829 153 ▶ $anchorDetails = $policy->anchorDetails( $node, $anchorData )
Branch: 1 branch
BranchTrueFalseTotal
if $anchorData 123 30 153
5830 if $anchorData;
5831  
5832 153 my ( $elementLine, $elementColumn );
5833 ELEMENT:
5834 153 ▶ for (
Branch: 1 branch
BranchTrueFalseTotal
if ($elementNumber <= $elementCount) 342 153 495
5835 my $elementNumber = 1 ;
5836 $elementNumber <= $elementCount ;
5837 $elementNumber++
5838 )
5839 {
5840  
5841 342 my $element = $gapSeq[ $elementNumber * 2 - 1 ];
5842 342 ▶ my $previousElementLine = $elementLine // -1;
Condition100%2/2
$elementLine // -1
l!l
189153
MC/DC100%1/1
$elementLine // -1
$elementLine
Truth table100%2/2
A
A= $elementLine
Aresult
11
00
5843 342 ( $elementLine, $elementColumn ) = $instance->nodeLC($element);
5844 342 my $gap = $gapSeq[ $elementNumber * 2 - 2 ];
5845 342 my ( $gapLine, $gapColumn ) = $instance->nodeLC($gap);
5846 342 my $backdentColumn =
5847 $anchorColumn + ( $elementCount - $elementNumber ) * 2;
5848  
5849 342 ▶ if ( $elementLine == $parentLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($elementLine == $parentLine) 165 177 342
5850  
5851 # OK if at proper alignment for backdent
5852 165 ▶ next ELEMENT if $backdentColumn == $elementColumn;
Branch: 1 branch
BranchTrueFalseTotal
if $backdentColumn == $elementColumn 51 114 165
5853  
5854 114 my $gapLength = $instance->gapLength($gap);
5855 114 ▶ next ELEMENT if $gapLength == 2;
Branch: 1 branch
BranchTrueFalseTotal
if $gapLength == 2 114 0 114
5856  
5857 0 my $thisAlignment;
5858 0 my ( $chainAlignmentColumn, $chainAlignmentDetails );
5859 0 my $chainAlignmentLines = [];
5860 0 ▶ if ($chainAlignments) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chainAlignments) 0 0 0
5861 0 $thisAlignment =
5862 $chainAlignments->[ $chainOffset + $elementNumber - 1 ];
5863 # say STDERR "$thisAlignment = chainAlignments->[ $chainOffset + $elementNumber - 1 ]";
5864 ( $chainAlignmentColumn, $chainAlignmentDetails ) =
5865 0 @{$thisAlignment};
5866  
5867 }
5868  
5869 # say STDERR join " ", __FILE__, __LINE__, $elementNumber;
5870 0 my ( $runningAlignmentColumn, $runningAlignmentDetails );
5871 0 ▶ if ($runningAlignments) {
Branch: 1 branch
BranchTrueFalseTotal
if ($runningAlignments) 0 0 0
5872 0 $thisAlignment = $runningAlignments->[ $elementNumber - 1];
5873 ( $runningAlignmentColumn, $runningAlignmentDetails ) =
5874 0 @{$thisAlignment};
5875 }
5876  
5877 0 ▶ if ( defined $chainAlignmentColumn
Branch: 1 branch
BranchTrueFalseTotal
if (defined $chainAlignmentColumn and $chainAlignmentColumn >= 0 and defined $runningAlignmentColumn and $runningAlignmentColumn >= 0 and $chainAlignmentColumn != $runningAlignmentColumn) 0 0 0
Condition0%0/12
defined $chainAlignmentColumn and $chainAlignmentColumn >= 0 and defined $runningAlignmentColumn and $runningAlignmentColumn >= 0 and $chainAlignmentColumn != $runningAlignmentColumn
!ll&&!rl&&r
000
defined $chainAlignmentColumn and $chainAlignmentColumn >= 0 and defined $runningAlignmentColumn and $runningAlignmentColumn >= 0
!ll&&!rl&&r
000
defined $chainAlignmentColumn and $chainAlignmentColumn >= 0 and defined $runningAlignmentColumn
!ll&&!rl&&r
000
defined $chainAlignmentColumn and $chainAlignmentColumn >= 0
!ll&&!rl&&r
000
MC/DC0%0/5
defined $chainAlignmentColumn and $chainAlignmentColumn >= 0 and defined $runningAlignmentColumn and $runningAlignmentColumn >= 0 and $chainAlignmentColumn != $runningAlignmentColumn
defined $chainAlignmentColumn $chainAlignmentColumn >= 0 defined $runningAlignmentColumn $runningAlignmentColumn >= 0 $chainAlignmentColumn != $runningAlignmentColumn
Truth table0%0/6
A and B and C and D and E
A= defined $chainAlignmentColumnB= $chainAlignmentColumn >= 0C= defined $runningAlignmentColumnD= $runningAlignmentColumn >= 0E= $chainAlignmentColumn != $runningAlignmentColumn
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
5878 and $chainAlignmentColumn >= 0
5879 and defined $runningAlignmentColumn
5880 and $runningAlignmentColumn >= 0
5881 and $chainAlignmentColumn != $runningAlignmentColumn )
5882 {
5883 0 my $msg = sprintf
5884 'inter-line alignment conflict; element #%d of %s at %s; running is %d but chain is %d',
5885 $elementNumber,
5886 describeLC( $parentLine, $parentColumn ),
5887 describeLC( $elementLine, $elementColumn ),
5888 describeLC( $elementLine, $runningAlignmentColumn ),
5889 describeLC( $elementLine, $chainAlignmentColumn );
5890 0 push @mistakes,
5891 {
5892 desc => $msg,
5893 subpolicy => [ $runeName, 'interline-mismatch' ],
5894 parentLine => $parentLine,
5895 parentColumn => $parentColumn,
5896 line => $elementLine,
5897 column => $elementColumn,
5898 reportLine => $elementLine,
5899 reportColumn => $elementColumn,
5900 };
5901 }
5902  
5903 0 my $interlineAlignmentType;
5904 my $interlineAlignmentColumn;
5905 SET_INTERLINE_ALIGNMENT: {
5906 0 ▶ if ( defined $chainAlignmentColumn
Branch: 1 branch
BranchTrueFalseTotal
if (defined $chainAlignmentColumn and $chainAlignmentColumn >= 0) 0 0 0
Condition0%0/3
defined $chainAlignmentColumn and $chainAlignmentColumn >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $chainAlignmentColumn and $chainAlignmentColumn >= 0
defined $chainAlignmentColumn $chainAlignmentColumn >= 0
Truth table0%0/3
A and B
A= defined $chainAlignmentColumnB= $chainAlignmentColumn >= 0
ABresult
0X0
100
111
5907 and $chainAlignmentColumn >= 0 )
5908 {
5909 0 $interlineAlignmentType = 'chain';
5910 0 $interlineAlignmentColumn = $chainAlignmentColumn;
5911 0 last SET_INTERLINE_ALIGNMENT;
5912 }
5913 0 ▶ if ( defined $runningAlignmentColumn)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $runningAlignmentColumn) 0 0 0
5914 {
5915 0 $interlineAlignmentType = 'running';
5916 0 $interlineAlignmentColumn = $runningAlignmentColumn;
5917 }
5918 }
5919  
5920 # say STDERR join " ", __FILE__, __LINE__, $interlineAlignmentColumn;
5921 next ELEMENT
5922 0 ▶ if defined $interlineAlignmentColumn
Branch: 1 branch
BranchTrueFalseTotal
if defined $interlineAlignmentColumn and $interlineAlignmentColumn >= 0 and $interlineAlignmentColumn == $elementColumn 0 0 0
Condition0%0/6
defined $interlineAlignmentColumn and $interlineAlignmentColumn >= 0 and $interlineAlignmentColumn == $elementColumn
!ll&&!rl&&r
000
defined $interlineAlignmentColumn and $interlineAlignmentColumn >= 0
!ll&&!rl&&r
000
MC/DC0%0/3
defined $interlineAlignmentColumn and $interlineAlignmentColumn >= 0 and $interlineAlignmentColumn == $elementColumn
defined $interlineAlignmentColumn $interlineAlignmentColumn >= 0 $interlineAlignmentColumn == $elementColumn
Truth table0%0/4
A and B and C
A= defined $interlineAlignmentColumnB= $interlineAlignmentColumn >= 0C= $interlineAlignmentColumn == $elementColumn
ABCresult
0XX0
10X0
1100
1111
5923 and $interlineAlignmentColumn >= 0
5924 and $interlineAlignmentColumn == $elementColumn;
5925  
5926 0 my @topicLines = ();
5927 0 my $tightColumn = $gapColumn + 2;
5928 0 my @allowedColumns =([ $tightColumn => 'tight' ]);
5929 0 ▶ if ($backdentColumn > $tightColumn) {
Branch: 1 branch
BranchTrueFalseTotal
if ($backdentColumn > $tightColumn) 0 0 0
5930 0 push @allowedColumns, [ $backdentColumn => 'backdent' ];
5931 }
5932 0 my $details;
5933 0 ▶ if ($interlineAlignmentColumn and $interlineAlignmentColumn >= $tightColumn) {
Branch: 1 branch
BranchTrueFalseTotal
if ($interlineAlignmentColumn and $interlineAlignmentColumn >= $tightColumn) { } 0 0 0
Condition0%0/3
$interlineAlignmentColumn and $interlineAlignmentColumn >= $tightColumn
!ll&&!rl&&r
000
MC/DC0%0/2
$interlineAlignmentColumn and $interlineAlignmentColumn >= $tightColumn
$interlineAlignmentColumn $interlineAlignmentColumn >= $tightColumn
Truth table0%0/3
A and B
A= $interlineAlignmentColumnB= $interlineAlignmentColumn >= $tightColumn
ABresult
0X0
100
111
5934 0 push @allowedColumns, [ $interlineAlignmentColumn => $interlineAlignmentType ];
5935 0 my $oneBasedColumn = $interlineAlignmentColumn + 1;
5936 my $alignmentLines =
5937 $interlineAlignmentType eq 'running'
5938 ? $runningAlignmentDetails
5939 0 ▶ : $chainAlignmentDetails->{lines};
Branch: 1 branch
BranchTrueFalseTotal
$interlineAlignmentType eq 'running' ? : 0 0 0
5940 0 push @topicLines, @{$alignmentLines};
5941 $details = [
5942 [
5943 sprintf '%s alignment is %d, see %s',
5944 $interlineAlignmentType,
5945 $oneBasedColumn,
5946 (
5947 join q{ },
5948 0 map { $_ . ':' . $oneBasedColumn } @{$alignmentLines}
5949 )
5950 ]
5951 ];
5952 }
5953 else {
5954 0 $details = [ [ "no chain alignment detected" ] ];
5955 }
5956 0 my @sortedColumns = sort { $a->[0] <=> $b->[0] } @allowedColumns;
5957 my $allowedDesc = join "; ",
5958 0 map { sprintf '@%d:%d (%s)', $elementLine, $_->[0]+1, $_->[1] } @sortedColumns;
5959 0 ▶ if (scalar @sortedColumns >= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @sortedColumns >= 2) 0 0 0
5960 0 $allowedDesc = 'one of ' . $allowedDesc;
5961 }
5962  
5963 0 my $msg = sprintf
5964 'joined backdent element #%d of %s is at %s; should be %s',
5965 $elementNumber,
5966 describeLC( $parentLine, $parentColumn ),
5967 describeLC( $elementLine, $elementColumn ),
5968 $allowedDesc;
5969 0 push @mistakes,
5970 {
5971 desc => $msg,
5972 subpolicy => [ $runeName, 'hgap' ],
5973 parentLine => $parentLine,
5974 parentColumn => $parentColumn,
5975 line => $elementLine,
5976 column => $elementColumn,
5977 reportLine => $elementLine,
5978 reportColumn => $elementColumn,
5979 subpolicy => [ $runeName, 'hgap'],
5980 topicLines => \@topicLines,
5981 details => $details,
5982 };
5983 0 next ELEMENT;
5984 }
5985  
5986 CHECK_FOR_PSEUDOJOIN: {
5987 177 ▶ last CHECK_FOR_PSEUDOJOIN if $gapLine != $parentLine;
Branch: 1 branch
BranchTrueFalseTotal
if $gapLine != $parentLine 45 132 177
5988 132 ▶ last CHECK_FOR_PSEUDOJOIN if $backdentColumn == $elementColumn;
Branch: 1 branch
BranchTrueFalseTotal
if $backdentColumn == $elementColumn 126 6 132
5989 6 my $msg =
5990 sprintf
5991 'Pseudo-joined backdented element %d; element/comment mismatch',
5992 $elementNumber;
5993 6 my $pseudojoinMistakes = $policy->checkPseudojoin(
5994 $gap,
5995 {
5996 desc => $msg,
5997 subpolicy => [ $runeName, 'pseudojoin-mismatch' ],
5998 expected => [
5999 [ 'tight', $parentColumn + 4 ],
6000 ]
6001 }
6002 );
6003 6 ▶ if ($pseudojoinMistakes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pseudojoinMistakes) 0 6 6
6004 0 push @mistakes, @{$pseudojoinMistakes};
6005 0 next ELEMENT;
6006 }
6007 }
6008  
6009 # For the use of re-anchoring logic, determine the additional offset
6010 # reguired for the next line after the rune line
6011 177 ▶ if ( not defined $reanchorOffset ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $reanchorOffset) 138 39 177
6012 138 $reanchorOffset = 2 + ( $elementCount - $elementNumber ) * 2;
6013 138 $policy->{perNode}->{$nodeIX}->{reanchorOffset} = $reanchorOffset;
6014 }
6015  
6016 177 ▶ if ( $elementLine == $previousElementLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($elementLine == $previousElementLine) 0 177 177
6017 0 my $gapLength = $gap->{length};
6018 0 ▶ next ELEMENT if $gapLength == 2;
Branch: 1 branch
BranchTrueFalseTotal
if $gapLength == 2 0 0 0
6019 0 my $msg = sprintf
6020 'backdented element #%d %s; %s',
6021 $elementNumber,
6022 describeLC( $elementLine, $elementColumn ),
6023 describeMisindent2( $gapLength, 2 );
6024 push @mistakes,
6025 {
6026 desc => $msg,
6027 subpolicy => [ $runeName, 'hgap' ],
6028 parentLine => $parentLine,
6029 parentColumn => $parentColumn,
6030 line => $elementLine,
6031 column => $elementColumn,
6032 reportLine => $elementLine,
6033 reportColumn => $elementColumn,
6034 0 details => [ [ @{$anchorDetails}, ] ],
6035 };
6036 0 next ELEMENT;
6037 }
6038  
6039 push @mistakes, @{
6040 177 $policy->checkOneLineGap(
6041 $gap,
6042 {
6043 mainColumn => $anchorColumn,
6044 elementNumber => $elementNumber,
6045 preColumn => $elementColumn,
6046 runeName => $runeName,
6047 subpolicy => [ $runeName ],
6048 topicLines => [ $anchorLine, $elementLine ],
6049 details => [
6050 [
6051 177 @{$anchorDetails},
6052 (sprintf 'inter-comment indent should be %d; see line %d',
6053 ( $anchorColumn + 1 ), $anchorLine),
6054 (sprintf 'pre-comment indent should be %d; see line %d',
6055 ( $elementColumn + 1 ), $elementLine)
6056 ]
6057 ],
6058 }
6059 )
6060 };
6061  
6062 177 ▶ if ( $backdentColumn != $elementColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($backdentColumn != $elementColumn) 6 171 177
6063 6 my $msg = sprintf
6064 'backdented element #%d %s; %s',
6065 $elementNumber,
6066 describeLC( $elementLine, $elementColumn ),
6067 describeMisindent2( $elementColumn, $backdentColumn );
6068 push @mistakes,
6069 {
6070 desc => $msg,
6071 subpolicy => [ $runeName, 'indent' ],
6072 line => $elementLine,
6073 column => $elementColumn,
6074 reportLine => $elementLine,
6075 reportColumn => $elementColumn,
6076 topicLines => [ $anchorLine ],
6077 6 details => [ [ @{$anchorDetails}, ] ],
6078 };
6079 }
6080 }
6081 153 return \@mistakes;
6082 }
6083  
6084 # Ketdot is slightly different form other backdented hoons
6085 0 ▶sub checkKetdot {
Subroutine checkKetdot: not called CC=7 SCAR=40.3
Pod undocumented
6086 0 my ( $policy, $node ) = @_;
6087 0 my @gapSeq = @{ $policy->gapSeq0($node) };
6088 0 my $instance = $policy->{lint};
6089 0 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
6090 0 my @mistakes = ();
6091 0 my $runeName = 'ketdot';
6092 0 my $tag = 'ketdot';
6093  
6094 0 my $anchorNode =
6095 $instance->firstBrickOfLineInc( $node, { tallKetdot => 1 } );
6096 0 my ( $anchorLine, $anchorColumn ) = $instance->nodeLC($anchorNode);
6097  
6098 0 my $gap1 = $gapSeq[0];
6099 0 my $element1 = $gapSeq[1];
6100 0 my ( $element1Line, $element1Column ) = $instance->nodeLC($element1);
6101  
6102 ELEMENT: { # Element 1
6103  
6104 0 my $expectedColumn = $parentColumn + 4;
6105  
6106 0 ▶ if ( $element1Line != $parentLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($element1Line != $parentLine) 0 0 0
6107 0 my $msg = sprintf
6108 "Ketdot element 1 %s; element 1 expected to be on rune line",
6109 describeLC( $element1Line, $element1Column );
6110 0 push @mistakes,
6111 {
6112 desc => $msg,
6113 parentLine => $parentLine,
6114 parentColumn => $parentColumn,
6115 line => $element1Line,
6116 column => $element1Column,
6117 };
6118 0 last ELEMENT;
6119 }
6120  
6121 0 ▶ if ( $expectedColumn != $element1Column ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expectedColumn != $element1Column) 0 0 0
6122 0 my $msg = sprintf
6123 'Ketdot element 1 %s; %s',
6124 describeLC( $element1Line, $element1Column ),
6125 describeMisindent2( $element1Column, $expectedColumn );
6126 0 push @mistakes,
6127 {
6128 desc => $msg,
6129 parentLine => $parentLine,
6130 parentColumn => $parentColumn,
6131 line => $element1Line,
6132 column => $element1Column,
6133 };
6134 }
6135 }
6136  
6137 0 my $gap2 = $gapSeq[2];
6138 0 my $element2 = $gapSeq[3];
6139 0 my ( $element2Line, $element2Column ) = $instance->nodeLC($element2);
6140  
6141 ELEMENT2: {
6142 0 ▶ if ( $element1Line != $element2Line ) { # Element 2 split
Branch: 1 branch
BranchTrueFalseTotal
if ($element1Line != $element2Line) 0 0 0
6143  
6144 0 my $expectedColumn = $anchorColumn;
6145  
6146 push @mistakes,
6147 @{
6148 0 $policy->checkOneLineGap(
6149 $gap2,
6150 {
6151 mainColumn => $anchorColumn,
6152 runeName => $runeName,
6153 subpolicy => [ $runeName ],
6154 }
6155 )
6156 };
6157  
6158 0 ▶ if ( $expectedColumn != $element2Column ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expectedColumn != $element2Column) 0 0 0
6159 0 my $msg = sprintf
6160 'Ketdot element 2 %s; %s',
6161 describeLC( $element2Line, $element2Column ),
6162 describeMisindent2( $element2Column, $expectedColumn );
6163 0 push @mistakes,
6164 {
6165 desc => $msg,
6166 parentLine => $parentLine,
6167 parentColumn => $parentColumn,
6168 line => $element2Line,
6169 column => $element2Column,
6170 };
6171 }
6172 0 last ELEMENT2;
6173 }
6174  
6175 # If here, joined element 2
6176  
6177 0 my $gapLiteral = $instance->literalNode($gap2);
6178 0 my $gapLength = $gap2->{length};
6179 0 ▶ last ELEMENT2 if $gapLength == 2;
Branch: 1 branch
BranchTrueFalseTotal
if $gapLength == 2 0 0 0
6180 0 my ( undef, $gap2Column ) = $instance->nodeLC($gap2);
6181  
6182 # expected length is the length if the spaces at the end
6183 # of the gap-equivalent were exactly one stop.
6184 0 my $expectedLength = $gapLength + ( 2 - length $gapLiteral );
6185 0 my $expectedColumn = $gap2Column + $expectedLength;
6186  
6187 0 ▶ if ( $expectedColumn != $element2Column ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expectedColumn != $element2Column) 0 0 0
6188 0 my $msg = sprintf
6189 'Ketdot element 2 %s; %s',
6190 describeLC( $element2Line, $element2Column ),
6191 describeMisindent2( $element2Column, $expectedColumn );
6192 0 push @mistakes,
6193 {
6194 desc => $msg,
6195 parentLine => $parentLine,
6196 parentColumn => $parentColumn,
6197 line => $element2Line,
6198 column => $element2Column,
6199 };
6200 }
6201 }
6202  
6203 0 return \@mistakes;
6204 }
6205  
6206 69 ▶sub checkLuslus {
Subroutine checkLuslus: called CC=15 SCAR=35.9
Pod undocumented
6207 69 my ( $policy, $node, $cellLHS ) = @_;
6208 69 my $nodeIX = $node->{IX};
6209 69 my $instance = $policy->{lint};
6210 69 my $runeName = $policy->runeName($node);
6211 69 my ( $parentLine, $parentColumn ) = $instance->nodeLC($node);
6212  
6213 69 my $battery = $instance->ancestorByLHS( $node, { whap5d => 1 } );
6214 69 ▶ die "battery not found" if not defined $battery;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $battery 0 69 69
6215 69 my ( $batteryLine, $batteryColumn ) = $instance->nodeLC($battery);
6216 my ( $cellBodyColumn, $cellBodyColumnLines ) =
6217 69 @{ $policy->getInheritedAttribute($node, 'cellBodyAlignmentData') };
6218  
6219 69 my $batteryHoon = $instance->brickNode($battery);
6220 69 my ( $batteryHoonLine, $batteryHoonColumn ) =
6221 $instance->nodeLC($batteryHoon);
6222 69 my $batteryRuneName = $policy->runeName($batteryHoon);
6223 69 my $armDesc = join ':', $batteryRuneName, $runeName, 'arm';
6224  
6225 69 my $anchorData;
6226 69 my ( $anchorColumn, $anchorLine ) = ( $parentColumn, $parentLine );
6227 69 ▶ if ( $parentLine == $batteryHoonLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parentLine == $batteryHoonLine) 0 69 69
6228 0 ( $anchorColumn, $anchorData ) = $policy->reanchorInc(
6229 $node,
6230 {
6231 'tallBarcen' => 1,
6232 }
6233 );
6234 }
6235  
6236 69 my $anchorDetails;
6237 69 ▶ $anchorDetails = $policy->anchorDetails( $node, $anchorData )
Branch: 1 branch
BranchTrueFalseTotal
if $anchorData 0 69 69
6238 if $anchorData;
6239  
6240 69 $policy->{perNode}->{$nodeIX}->{reanchorOffset} = 2;
6241  
6242 69 my @mistakes = ();
6243  
6244 # LuslusCell ::= (- LUS LUS GAP -) SYM4K (- GAP -) tall5d
6245 69 my ( $headGap, $head, $bodyGap, $body ) = @{ $policy->gapSeq0($node) };
6246 69 my ( $headLine, $headColumn ) = $instance->nodeLC($head);
6247 69 my ( $bodyLine, $bodyColumn ) = $instance->nodeLC($body);
6248  
6249 69 my $headGapLength = $headGap->{length};
6250 69 ▶ if ( $headGapLength != 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headGapLength != 2) 0 69 69
6251 0 my $msg = sprintf 'Cell head %s; %s',
6252 describeLC( $bodyLine, $bodyColumn ),
6253 describeMisindent2( $headGapLength, 2 );
6254 0 push @mistakes,
6255 {
6256 desc => $msg,
6257 subpolicy => [ $runeName, 'hgap' ],
6258 parentLine => $parentLine,
6259 parentColumn => $parentColumn,
6260 line => $headLine,
6261 column => $headColumn,
6262 reportLine => $headLine,
6263 reportColumn => $headColumn,
6264 topicLines => [ $batteryLine, $batteryHoonLine ],
6265 details => [
6266 [
6267 $armDesc,
6268 (
6269 sprintf 'starts at %s',
6270 describeLC( $batteryHoonLine, $batteryHoonColumn )
6271 ),
6272 ]
6273 ],
6274 };
6275 }
6276  
6277 69 ▶ if ( $headLine == $bodyLine ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headLine == $bodyLine) 42 27 69
6278 42 my $bodyGapLength = $bodyGap->{length};
6279  
6280 42 ▶ if ( $bodyGapLength != 2 and $bodyColumn != $cellBodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyGapLength != 2 and $bodyColumn != $cellBodyColumn) 0 42 42
Condition33%1/3
$bodyGapLength != 2 and $bodyColumn != $cellBodyColumn
!ll&&!rl&&r
4200
MC/DC0%0/2
$bodyGapLength != 2 and $bodyColumn != $cellBodyColumn
$bodyGapLength != 2 $bodyColumn != $cellBodyColumn
Truth table33%1/3
A and B
A= $bodyGapLength != 2B= $bodyColumn != $cellBodyColumn
ABresult
0X0
100
111
6281 0 my @topicLines = ( $batteryLine, $batteryHoonLine );
6282 0 my @subpolicy = ($runeName);
6283 0 my $misindent;
6284 0 my @details = (
6285 $armDesc,
6286 (
6287 sprintf 'starts at %s',
6288 describeLC( $batteryHoonLine, $batteryHoonColumn )
6289 ),
6290 );
6291 0 ▶ if ( $cellBodyColumn < 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cellBodyColumn < 0) { } 0 0 0
6292 0 push @subpolicy, 'bad-tight-indent';
6293 0 $misindent = describeMisindent2( $bodyGapLength, 2 );
6294 0 push @details, "no inter-line alignment detected";
6295 }
6296 else {
6297 0 push @subpolicy, 'bad-interline-indent';
6298 0 $misindent = describeMisindent2( $bodyColumn, $cellBodyColumn );
6299 0 my $oneBasedColumn = $cellBodyColumn + 1;
6300 0 push @topicLines, @{$cellBodyColumnLines};
6301 push @details,
6302 (
6303 sprintf 'inter-line alignment is %d, see %s',
6304 $oneBasedColumn,
6305 (
6306 join q{ },
6307 0 map { $_ . ':' . $oneBasedColumn }
6308 0 @{$cellBodyColumnLines}
6309 )
6310 );
6311 }
6312 0 my $msg = sprintf 'Cell body %s; %s',
6313 describeLC( $bodyLine, $bodyColumn ), $misindent;
6314 0 push @mistakes,
6315 {
6316 desc => $msg,
6317 subpolicy => \@subpolicy,
6318 parentLine => $parentLine,
6319 parentColumn => $parentColumn,
6320 line => $bodyLine,
6321 column => $bodyColumn,
6322 reportLine => $bodyLine,
6323 reportColumn => $bodyColumn,
6324 topicLines => \@topicLines,
6325 details => [ [@details] ],
6326 };
6327 }
6328 42 return \@mistakes;
6329 }
6330  
6331 # If here, this is (or should be) a split cell
6332 27 my $expectedBodyColumn = $anchorColumn + 2;
6333  
6334 # If here head line != body line
6335 CHECK_FOR_PSEUDOJOIN: {
6336 27 my $pseudojoinColumn = $policy->pseudojoinColumn($bodyGap);
6337 27 ▶ last CHECK_FOR_PSEUDOJOIN if $pseudojoinColumn < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $pseudojoinColumn < 0 6 21 27
6338 21 my $headLength = $head->{length};
6339 21 my $raggedColumn = $headColumn + $headLength + 2;
6340 last CHECK_FOR_PSEUDOJOIN
6341 21 ▶ if $pseudojoinColumn != $raggedColumn
Branch: 1 branch
BranchTrueFalseTotal
if $pseudojoinColumn != $raggedColumn and $pseudojoinColumn != $cellBodyColumn 21 0 21
Condition33%1/3
$pseudojoinColumn != $raggedColumn and $pseudojoinColumn != $cellBodyColumn
!ll&&!rl&&r
0021
MC/DC0%0/2
$pseudojoinColumn != $raggedColumn and $pseudojoinColumn != $cellBodyColumn
$pseudojoinColumn != $raggedColumn $pseudojoinColumn != $cellBodyColumn
Truth table33%1/3
A and B
A= $pseudojoinColumn != $raggedColumnB= $pseudojoinColumn != $cellBodyColumn
ABresult
0X0
100
111
6342 and $pseudojoinColumn != $cellBodyColumn;
6343 0 ▶ if ( $pseudojoinColumn != $bodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pseudojoinColumn != $bodyColumn) 0 0 0
6344  
6345 # Works as a regular split arm, so not a
6346 # pseudojoing after all.
6347 0 ▶ last CHECK_FOR_PSEUDOJOIN if $bodyColumn == $expectedBodyColumn;
Branch: 1 branch
BranchTrueFalseTotal
if $bodyColumn == $expectedBodyColumn 0 0 0
6348  
6349 0 my $msg =
6350 sprintf
6351 'Pseudo-joined cell %s; body/comment mismatch; body is %s',
6352 describeLC( $parentLine, $parentColumn ),
6353 describeMisindent2( $bodyColumn, $pseudojoinColumn );
6354 0 push @mistakes,
6355 {
6356 desc => $msg,
6357 subpolicy => [ $runeName, 'pseudo-comment-indent' ],
6358 parentLine => $parentLine,
6359 parentColumn => $parentColumn,
6360 line => $bodyLine,
6361 column => $bodyColumn,
6362 reportLine => $bodyLine,
6363 reportColumn => $bodyColumn,
6364 topicLines => [ $batteryLine, $batteryHoonLine ],
6365 details => [
6366 [
6367 $armDesc,
6368 (
6369 sprintf 'starts at %s',
6370 describeLC( $batteryHoonLine, $batteryHoonColumn )
6371 ),
6372 ]
6373 ],
6374 };
6375 }
6376 0 return \@mistakes;
6377 }
6378  
6379 27 ▶ if ( $bodyColumn != $expectedBodyColumn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bodyColumn != $expectedBodyColumn) 0 27 27
6380 0 my $msg = sprintf 'cell body %s; %s',
6381 describeLC( $bodyLine, $bodyColumn ),
6382 describeMisindent2( $bodyColumn, $expectedBodyColumn );
6383 0 push @mistakes,
6384 {
6385 desc => $msg,
6386 subpolicy => [ $runeName, 'arm-body-indent' ],
6387 parentLine => $parentLine,
6388 parentColumn => $parentColumn,
6389 line => $bodyLine,
6390 column => $bodyColumn,
6391 reportLine => $bodyLine,
6392 reportColumn => $bodyColumn,
6393 topicLines => [ $batteryLine, $batteryHoonLine ],
6394 details => [
6395 [
6396 $armDesc,
6397 (
6398 sprintf 'starts at %s',
6399 describeLC( $batteryHoonLine, $batteryHoonColumn )
6400 ),
6401 ]
6402 ],
6403 };
6404 0 return \@mistakes;
6405 }
6406  
6407 push @mistakes,
6408 @{
6409 27 $policy->checkOneLineGap(
6410 $bodyGap,
6411 {
6412 mainColumn => $expectedBodyColumn,
6413 runeName => $runeName,
6414 subpolicy => [$runeName],
6415 topicLines => [ $bodyLine, $batteryLine, $batteryHoonLine ],
6416 details => [
6417 [
6418 $armDesc,
6419 (
6420 sprintf 'starts at %s',
6421 describeLC( $batteryHoonLine, $batteryHoonColumn )
6422 ),
6423 ]
6424 ],
6425 }
6426 )
6427 };
6428  
6429 27 return \@mistakes;
6430 }
6431  
6432 11433 ▶sub validate {
Subroutine validate: called CC=3 SCAR=11.0
Pod undocumented
6433 11433 my ( $policy, $node ) = @_;
6434 11433 my $instance = $policy->{lint};
6435  
6436 11433 $policy->validate_node($node);
6437 11433 ▶ return if $node->{type} ne 'node';
Branch: 1 branch
BranchTrueFalseTotal
if $node->{"type"} ne "node" 4134 7299 11433
6438 7299 my $children = $node->{children};
6439 7299 CHILD: for my $childIX ( 0 .. $#$children ) {
6440 11421 my $child = $children->[$childIX];
6441 11421 $policy->validate($child);
6442 }
6443 7299 return;
6444 }
6445  
6446 6 ▶sub reportMistakes {
Subroutine reportMistakes: called CC=5 SCAR=16.7
Pod undocumented
6447 6 my ( $policy, $mistakes ) = @_;
6448 6 my $instance = $policy->{lint};
6449 6 my $fileName = $instance->{fileName};
6450  
6451 6 my @pieces = ();
6452 6 MISTAKE: for my $mistake ( @{$mistakes} ) {
6453  
6454 6 my $parentLine = $mistake->{parentLine};
6455 6 my $parentColumn = $mistake->{parentColumn};
6456 6 my $desc = $mistake->{desc};
6457 6 my $mistakeLine = $mistake->{line};
6458  
6459 # The default report location should be line, column
6460 # instead of parentLine, parentColumn
6461 6 ▶ $mistake->{reportLine} //= $parentLine;
Condition33%1/3
$mistake->{"reportLine"} //= $parentLine
l!l&&r!l&&!r
600
MC/DC0%0/2
$mistake->{"reportLine"} //= $parentLine
$mistake->{"reportLine"} $parentLine
Truth table33%1/3
A //= B
A= $mistake->{"reportLine"}B= $parentLine
ABresult
1X1
011
000
6462 6 ▶ $mistake->{reportColumn} //= $parentColumn;
Condition33%1/3
$mistake->{"reportColumn"} //= $parentColumn
l!l&&r!l&&!r
600
MC/DC0%0/2
$mistake->{"reportColumn"} //= $parentColumn
$mistake->{"reportColumn"} $parentColumn
Truth table33%1/3
A //= B
A= $mistake->{"reportColumn"}B= $parentColumn
ABresult
1X1
011
000
6463  
6464 $instance->reportItem( $mistake, $desc,
6465 6 ▶ ( $mistake->{topicLines} // [] ), $mistakeLine, );
Condition50%1/2
$mistake->{"topicLines"} // []
l!l
60
MC/DC0%0/1
$mistake->{"topicLines"} // []
$mistake->{"topicLines"}
Truth table50%1/2
A
A= $mistake->{"topicLines"}
Aresult
11
00
6466 }
6467 6 return;
6468 }
6469  
6470 11433 ▶sub validate_node {
Subroutine validate_node: called CC=60 SCAR=52.3
Pod undocumented
6471 11433 my ( $policy, $node ) = @_;
6472  
6473 11433 my $policyShortName = $policy->{shortName};
6474 11433 my $instance = $policy->{lint};
6475 11433 my $fileName = $instance->{fileName};
6476 11433 my $grammar = $instance->{grammar};
6477 11433 my $recce = $instance->{recce};
6478  
6479 11433 my $NYI_Rule = $instance->{NYI_Rule};
6480 11433 my $backdentedRule = $instance->{backdentedRule};
6481 11433 my $tallRuneRule = $instance->{tallRuneRule};
6482 11433 my $tallJogRule = $instance->{tallJogRule};
6483 11433 my $tallNoteRule = $instance->{tallNoteRule};
6484 11433 my $tallLuslusRule = $instance->{tallLuslusRule};
6485 11433 my $tall_0RunningRule = $instance->{tall_0RunningRule};
6486 11433 my $tall_1RunningRule = $instance->{tall_1RunningRule};
6487 11433 my $tall_1JoggingRule = $instance->{tall_1JoggingRule};
6488 11433 my $tall_2JoggingRule = $instance->{tall_2JoggingRule};
6489 11433 my $tall_Jogging1Rule = $instance->{tallJogging1_Rule};
6490  
6491 11433 my $ruleDB = $instance->{ruleDB};
6492 11433 my $lineToPos = $instance->{lineToPos};
6493 11433 my $symbolReverseDB = $instance->{symbolReverseDB};
6494  
6495 11433 my $parentSymbol = $node->{symbol};
6496 11433 my $parentStart = $node->{start};
6497 11433 my $parentLength = $node->{length};
6498 11433 my $parentRuleID = $node->{ruleID};
6499  
6500 # $Data::Dumper::Maxdepth = 3;
6501 # say Data::Dumper::Dumper($node);
6502  
6503 11433 my ( $parentLine, $parentColumn ) = $instance->line_column($parentStart);
6504 11433 my $parentLC = join ':', $parentLine, $parentColumn + 1;
6505  
6506 11433 my $children = $node->{children};
6507  
6508 11433 my $nodeType = $node->{type};
6509 11433 ▶ return if $nodeType ne 'node';
Branch: 1 branch
BranchTrueFalseTotal
if $nodeType ne "node" 4134 7299 11433
6510  
6511 7299 my $ruleID = $node->{ruleID};
6512 7299 my ( $lhs, @rhs ) = $grammar->rule_expand( $node->{ruleID} );
6513 7299 my $lhsName = $grammar->symbol_name($lhs);
6514  
6515 # tall node
6516  
6517 7299 my $mistakes = [];
6518 7299 my $start = $node->{start};
6519  
6520 GATHER_MISTAKES: {
6521  
6522 7299 state $fnHash = {
6523 tallKidsOfTop => \&checkTopKids,
6524 tallKidsOfElem => \&checkElemKids,
6525 tallTailOfElem => \&checkTailOfElem,
6526 tallTailOfTop => \&checkTailOfTop,
6527 tallTopSail => \&checkTopSail,
6528 bonz5d => \&checkBonz5d,
6529 };
6530 7299 my $fn = $fnHash->{$lhsName};
6531 7299 ▶ if ($fn) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fn) 0 7299 7299
6532 0 $mistakes = $fn->($policy, $node);
6533 0 last GATHER_MISTAKES;
6534 }
6535  
6536 7299 ▶ if ( $lhsName eq 'optGay4i' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "optGay4i") 12 7287 7299
6537 12 my $gapLength = $node->{length};
6538 12 ▶ return if $gapLength <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $gapLength <= 0 0 12 12
6539 12 my $start = $node->{start};
6540  
6541 # Special case for final newline
6542 HANDLE_SINGLE_LINE_TRAILER: {
6543 12 ▶ last HANDLE_SINGLE_LINE_TRAILER if $start + $gapLength != $lineToPos->[-1];
Branch: 1 branch
BranchTrueFalseTotal
if $start + $gapLength != $lineToPos->[-1] 0 12 12
6544 12 my $literal = $instance->literalNode($node);
6545 # say STDERR join " ", __FILE__, __LINE__, $lhsName, '[' . $literal. ']';
6546 12 ▶ return if $literal =~ m/\A [^\n]* \n \z/xms;
Branch: 1 branch
BranchTrueFalseTotal
if $literal =~ /\A [^\n]* \n \z/msx 12 0 12
6547 # say STDERR join " ", __FILE__, __LINE__, $lhsName, '[' . $literal. ']';
6548 }
6549  
6550 # say STDERR join " ", __FILE__, __LINE__, $lhsName, '[' . $instance->literalNode($node) . ']';
6551 0 my $runeName = 'fordfile';
6552 0 $mistakes =
6553 $policy->checkOneLineGap(
6554 $node,
6555 {
6556 mainColumn => 0,
6557 runeName => $runeName,
6558 subpolicy => [ $runeName, 'vgap' ],
6559 }
6560 );
6561 # say STDERR join " ", __FILE__, __LINE__, Data::Dumper::Dumper($mistakes);
6562 0 last GATHER_MISTAKES;
6563 }
6564  
6565 7287 my $childCount = scalar @{$children};
6566 7287 ▶ if ( $childCount <= 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($childCount <= 1) 5526 1761 7287
6567 5526 return;
6568 }
6569  
6570 1761 my $firstChildIndent = $instance->column( $children->[0]->{start} ) - 1;
6571  
6572 1761 ▶ my $gapiness = $ruleDB->[$ruleID]->{gapiness} // 0;
Condition100%2/2
$ruleDB->[$ruleID]{"gapiness"} // 0
l!l
3361425
MC/DC100%1/1
$ruleDB->[$ruleID]{"gapiness"} // 0
$ruleDB->[$ruleID]{"gapiness"}
Truth table100%2/2
A
A= $ruleDB->[$ruleID]{"gapiness"}
Aresult
11
00
6573  
6574 1761 ▶ my $reportType = $gapiness < 0 ? 'sequence' : 'indent';
Branch: 1 branch
BranchTrueFalseTotal
$gapiness < 0 ? : 39 1722 1761
6575  
6576 # TODO: In another policy, warn on tall children of wide nodes
6577 1761 ▶ if ( $gapiness == 0 ) { # wide node
Branch: 1 branch
BranchTrueFalseTotal
if ($gapiness == 0) 1425 336 1761
6578 1425 return;
6579 }
6580  
6581 336 ▶ if ( $gapiness < 0 ) { # sequence
Branch: 1 branch
BranchTrueFalseTotal
if ($gapiness < 0) 39 297 336
6582 39 my $previousLine = $parentLine;
6583 TYPE_INDENT: {
6584  
6585 39 ▶ if ( $lhsName eq 'rick5d' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "rick5d") 3 36 39
6586 3 $mistakes = $policy->checkJogging($node);
6587 3 last TYPE_INDENT;
6588 }
6589 36 ▶ if ( $lhsName eq 'ruck5d' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "ruck5d") 3 33 36
6590 3 $mistakes = $policy->checkJogging($node);
6591 3 last TYPE_INDENT;
6592 }
6593  
6594 33 ▶ if ( $lhsName eq 'fordFascomElements' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "fordFascomElements") 0 33 33
6595 0 $mistakes = $policy->checkFascomElements($node);
6596 0 last TYPE_INDENT;
6597 }
6598  
6599 33 ▶ if ( $lhsName eq 'fordHoopSeq' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "fordHoopSeq") 0 33 33
6600 0 $mistakes = $policy->checkSeq( $node, 'hoop' );
6601 0 last TYPE_INDENT;
6602 }
6603  
6604 33 ▶ if ( $lhsName eq 'hornSeq' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "hornSeq") 0 33 33
6605 0 $mistakes = $policy->checkSeq( $node, 'horn' );
6606 0 last TYPE_INDENT;
6607 }
6608  
6609 33 ▶ if ( $lhsName eq 'optBonzElements' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "optBonzElements") 0 33 33
6610 0 $mistakes = $policy->checkBonzElements( $node );
6611 0 last TYPE_INDENT;
6612 }
6613  
6614 33 my $grandParent = $instance->ancestor( $node, 1 );
6615 33 my $grandParentName = $instance->brickName($grandParent);
6616 33 ▶ if ( $lhsName eq 'tall5dSeq' or $lhsName eq 'till5dSeq' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "tall5dSeq" or $lhsName eq "till5dSeq") 12 21 33
Condition100%3/3
$lhsName eq "tall5dSeq" or $lhsName eq "till5dSeq"
l!l&&r!l&&!r
3921
MC/DC100%2/2
$lhsName eq "tall5dSeq" or $lhsName eq "till5dSeq"
$lhsName eq "tall5dSeq" $lhsName eq "till5dSeq"
Truth table100%3/3
A or B
A= $lhsName eq "tall5dSeq"B= $lhsName eq "till5dSeq"
ABresult
1X1
011
000
6617 12 ▶ if ( $grandParentName eq 'lute5d' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($grandParentName eq "lute5d") 0 12 12
6618 0 last TYPE_INDENT;
6619 }
6620 12 ▶ if ( $tall_1RunningRule->{$grandParentName} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tall_1RunningRule->{$grandParentName}) 0 12 12
6621 0 last TYPE_INDENT;
6622 }
6623 12 ▶ if ( $tall_0RunningRule->{$grandParentName} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tall_0RunningRule->{$grandParentName}) 12 0 12
6624 12 last TYPE_INDENT;
6625 }
6626 }
6627  
6628 21 ▶ if ( $lhsName eq 'whap5d' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "whap5d") 21 0 21
6629 21 my $greatGrandParent =
6630 $instance->ancestor( $grandParent, 1 );
6631 21 my $greatGrandParentName =
6632 $instance->brickName($greatGrandParent);
6633  
6634 # TODO: remove after development?
6635 21 ▶ die
Branch: 1 branch
BranchTrueFalseTotal
unless $greatGrandParentName eq "tallBarcab" or $greatGrandParentName eq "tallBarcen" or $greatGrandParentName eq "tallBarket" 0 21 21
Condition50%3/6
$greatGrandParentName eq "tallBarcab" or $greatGrandParentName eq "tallBarcen" or $greatGrandParentName eq "tallBarket"
l!l&&r!l&&!r
2100
$greatGrandParentName eq "tallBarcab" or $greatGrandParentName eq "tallBarcen"
l!l&&r!l&&!r
9120
MC/DC0%0/3
$greatGrandParentName eq "tallBarcab" or $greatGrandParentName eq "tallBarcen" or $greatGrandParentName eq "tallBarket"
$greatGrandParentName eq "tallBarcab" $greatGrandParentName eq "tallBarcen" $greatGrandParentName eq "tallBarket"
Truth table50%2/4
A or B or C
A= $greatGrandParentName eq "tallBarcab"B= $greatGrandParentName eq "tallBarcen"C= $greatGrandParentName eq "tallBarket"
ABCresult
1XX1
01X1
0011
0000
6636 unless $greatGrandParentName eq 'tallBarcab'
6637 or $greatGrandParentName eq 'tallBarcen'
6638 or $greatGrandParentName eq 'tallBarket';
6639 21 $mistakes = $policy->checkWhap5d($node);
6640 21 last TYPE_INDENT;
6641 }
6642  
6643 # By default, treat as not yet implemented
6644 0 $mistakes = $policy->checkNYI($node);
6645 0 ▶ last TYPE_INDENT if @{$mistakes};
Branch: 1 branch
BranchTrueFalseTotal
if @{$mistakes;} 0 0 0
6646  
6647 # should never reach here
6648 0 die "NYI";
6649 }
6650  
6651 39 last GATHER_MISTAKES;
6652 }
6653  
6654 # if here, gapiness > 0
6655  
6656 TYPE_INDENT: {
6657  
6658 # This would be faster as a hash
6659  
6660 297 ▶ if ( $lhsName eq "bont5d" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "bont5d") 0 297 297
6661 0 $mistakes = $policy->checkBont($node);
6662 0 last TYPE_INDENT;
6663 }
6664  
6665 297 ▶ if ( $lhsName eq "bonzElement" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "bonzElement") 0 297 297
6666 0 $mistakes = $policy->checkBonzElement($node);
6667 0 last TYPE_INDENT;
6668 }
6669  
6670 297 ▶ if ( $lhsName eq 'fordFascom' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "fordFascom") 0 297 297
6671 0 $mistakes = $policy->checkFascom($node);
6672 0 last TYPE_INDENT;
6673 }
6674  
6675 297 ▶ if ( $lhsName =~ '^fordFas(bar|dot)' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName =~ /^fordFas(bar|dot)/) 0 297 297
6676 # say STDERR join " ", __FILE__, __LINE__, $lhsName, $instance->literalNode($node);
6677 0 $mistakes = $policy->checkFasdot($node);
6678 0 last TYPE_INDENT;
6679 }
6680  
6681 297 ▶ if ( $lhsName =~ m/^fordFas(buc|cab|cen|hax|sig)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName =~ /^fordFas(buc|cab|cen|hax|sig)$/) 0 297 297
6682 0 $mistakes = $policy->checkFord_1( $node );
6683 0 last TYPE_INDENT;
6684 }
6685  
6686 297 ▶ if ( $lhsName eq "fordHoop" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "fordHoop") 0 297 297
6687 0 $mistakes = $policy->checkFordHoop( $node );
6688 0 last TYPE_INDENT;
6689 }
6690  
6691 297 ▶ if ( $lhsName eq "fordFastis" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "fordFastis") 0 297 297
6692 0 $mistakes = $policy->checkFastis($node);
6693 0 last TYPE_INDENT;
6694 }
6695  
6696 297 ▶ if ( $lhsName eq "fordFaswut" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "fordFaswut") 0 297 297
6697 0 $mistakes = $policy->checkFaswut($node);
6698 0 last TYPE_INDENT;
6699 }
6700  
6701 297 ▶ if ( $lhsName eq "fordFascomElement" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "fordFascomElement") 0 297 297
6702 0 $mistakes = $policy->checkFascomElement($node);
6703 0 last TYPE_INDENT;
6704 }
6705  
6706 297 ▶ if ( $lhsName eq "lute5d" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "lute5d") 0 297 297
6707 0 $mistakes = $policy->checkLute($node);
6708 0 last TYPE_INDENT;
6709 }
6710  
6711 297 ▶ if ( $lhsName =~ m/optFordFas(hep|lus)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName =~ /optFordFas(hep|lus)/) 0 297 297
6712 0 $mistakes = $policy->checkFordHoofRune($lhsName, $node);
6713 0 last TYPE_INDENT;
6714 }
6715  
6716 297 ▶ if ( $lhsName eq "tallAttribute" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "tallAttribute") 0 297 297
6717 0 $mistakes = $policy->checkSailAttribute($node);
6718 0 last TYPE_INDENT;
6719 }
6720  
6721 297 ▶ if ( $lhsName eq "tallBarcab" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "tallBarcab") 9 288 297
6722 9 $mistakes = $policy->checkBarcab($node);
6723 9 last TYPE_INDENT;
6724 }
6725  
6726 288 ▶ if ( $lhsName eq "tallBarcen" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "tallBarcen") 12 276 288
6727 12 $mistakes = $policy->checkBarcen($node);
6728 12 last TYPE_INDENT;
6729 }
6730  
6731 276 ▶ if ( $lhsName eq "tallBarket" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "tallBarket") 0 276 276
6732 0 $mistakes = $policy->checkBarket($node);
6733 0 last TYPE_INDENT;
6734 }
6735  
6736 276 ▶ if ( $lhsName eq "tallKetdot" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "tallKetdot") 0 276 276
6737 0 $mistakes = $policy->checkKetdot($node);
6738 0 last TYPE_INDENT;
6739 }
6740  
6741 276 ▶ if ( $lhsName eq "wisp5d" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhsName eq "wisp5d") 21 255 276
6742 21 $mistakes = $policy->checkWisp5d($node);
6743 21 last TYPE_INDENT;
6744 }
6745  
6746 255 ▶ if ( $NYI_Rule->{$lhsName} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($NYI_Rule->{$lhsName}) 0 255 255
6747 0 $mistakes = $policy->checkNYI($node);
6748 0 ▶ last TYPE_INDENT if @{$mistakes};
Branch: 1 branch
BranchTrueFalseTotal
if @{$mistakes;} 0 0 0
6749  
6750 # should never reach here
6751 0 die 'NYI failure';
6752 }
6753  
6754 255 ▶ if ( $tallJogRule->{$lhsName} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tallJogRule->{$lhsName}) 15 240 255
6755 15 $mistakes = $policy->checkJog($node);
6756 15 last TYPE_INDENT;
6757 }
6758  
6759 240 ▶ if ( $tall_0RunningRule->{$lhsName} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tall_0RunningRule->{$lhsName}) 12 228 240
6760 12 $mistakes = $policy->check_0Running($node);
6761 12 last TYPE_INDENT;
6762 }
6763  
6764 228 ▶ if ( $tall_1RunningRule->{$lhsName} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tall_1RunningRule->{$lhsName}) 0 228 228
6765 0 $mistakes = $policy->check_1Running($node);
6766 0 last TYPE_INDENT;
6767 }
6768  
6769 228 ▶ if ( $tall_1JoggingRule->{$lhsName} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tall_1JoggingRule->{$lhsName}) 6 222 228
6770 6 $mistakes = $policy->check_1Jogging($node);
6771 6 last TYPE_INDENT;
6772 }
6773  
6774 222 ▶ if ( $tall_2JoggingRule->{$lhsName} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tall_2JoggingRule->{$lhsName}) 0 222 222
6775 0 $mistakes = $policy->check_2Jogging($node);
6776 0 last TYPE_INDENT;
6777 }
6778  
6779 222 ▶ if ( $tall_Jogging1Rule->{$lhsName} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tall_Jogging1Rule->{$lhsName}) 0 222 222
6780 0 $mistakes = $policy->check_Jogging1($node);
6781 0 last TYPE_INDENT;
6782 }
6783  
6784 222 ▶ if ( $tallNoteRule->{$lhsName} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tallNoteRule->{$lhsName}) 63 159 222
6785 63 $mistakes = $policy->checkBackdented($node);
6786 63 last TYPE_INDENT;
6787 }
6788  
6789 159 ▶ if ( $tallLuslusRule->{$lhsName} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tallLuslusRule->{$lhsName}) 69 90 159
6790 69 $mistakes = $policy->checkLuslus( $node, $lhsName );
6791 69 last TYPE_INDENT;
6792 }
6793  
6794 90 ▶ if ( $backdentedRule->{$lhsName} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($backdentedRule->{$lhsName}) 90 0 90
6795 90 $mistakes = $policy->checkBackdented($node);
6796 90 last TYPE_INDENT;
6797 }
6798  
6799 # By default, treat as not yet implemented
6800 {
6801 0 $mistakes = $policy->checkNYI($node);
6802 0 ▶ last TYPE_INDENT if @{$mistakes};
Branch: 1 branch
BranchTrueFalseTotal
if @{$mistakes;} 0 0 0
6803  
6804 # should never reach here
6805 0 die 'NYI failure';
6806 }
6807  
6808 }
6809 }
6810  
6811 PRINT: {
6812 336 ▶ if ( @{$mistakes} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$mistakes;}) 6 330 336
6813 6 for my $mistake ( @{$mistakes} ) {
6814 6 $mistake->{policy} = $policyShortName;
6815 $mistake->{subpolicy} = $mistake->{subpolicy}
6816 6 ▶ // $instance->diagName($node);
Condition33%1/3
$mistake->{"subpolicy"} // $instance->diagName($node)
l!l&&r!l&&!r
600
MC/DC0%0/2
$mistake->{"subpolicy"} // $instance->diagName($node)
$mistake->{"subpolicy"} $instance->diagName($node)
Truth table33%1/3
A // B
A= $mistake->{"subpolicy"}B= $instance->diagName($node)
ABresult
1X1
011
000
6817 }
6818 6 $policy->reportMistakes($mistakes);
6819 6 last PRINT;
6820 }
6821  
6822 }
6823  
6824 336 return;
6825 }
6826  
6827 6 1;
6828  
6829 # vim: expandtab shiftwidth=4:
↑ Summary blib/lib/MarpaX/Hoonlint/yahc.pm »