@@ -33,7 +33,7 @@ function _matchFile(fname) {
33
33
|| fname ~ " /fennel/" \
34
34
|| fname ~ " /extensions/" \
35
35
|| fname ~ " /com/sqlstream/" \
36
- || ! lenient ;
36
+ || strict > 0 ;
37
37
}
38
38
function _isCpp (fname ) {
39
39
return fname ~ /\. (cpp| h)$ /;
@@ -109,7 +109,7 @@ BEGIN {
109
109
quot = sprintf (" %c" , 34 );
110
110
lf = sprintf (" %c" , 13 );
111
111
pattern = apos " (\\ " apos " |[^" apos " ])" apos;
112
- if (0 ) printf " maxLineLength=%s lenient =%s\n " , maxLineLength, lenient ;
112
+ if (0 ) printf " maxLineLength=%s strict =%s\n " , maxLineLength, strict ;
113
113
}
114
114
FNR == 1 {
115
115
if (fname) {
@@ -229,7 +229,6 @@ FNR == 1 {
229
229
thisImport = $2 ;
230
230
gsub (/; /, " " , thisImport);
231
231
gsub (/\* /, " " , thisImport);
232
- importGroup = " zzzzzzzzzzzzzzzzz" ;
233
232
if (thisPackage ~ /^ mondrian. * / && thisImport ~ /^ mondrian. * / \
234
233
|| thisPackage ~ /^ org. olap4j. * / && thisImport ~ /^ org. olap4j. * /)
235
234
{
@@ -257,7 +256,7 @@ FNR == 1 {
257
256
if (! previousLineWasEmpty) {
258
257
error(fname, FNR , " Expected blank line between import groups" );
259
258
} else if (prevImportGroup > importGroup) {
260
- error(fname, FNR , " Import group out of sequence" importGroup prevImportGroup);
259
+ error(fname, FNR , " Import group out of sequence (should precede " prevImportGroup " ) " );
261
260
}
262
261
} else if (prevImport \
263
262
&& prevImport > thisImport \
@@ -269,6 +268,34 @@ FNR == 1 {
269
268
prevImport = thisImport;
270
269
prevImportGroup = importGroup;
271
270
}
271
+ /^ \/\/ Copyright . * Julian / && strict {
272
+ if ($0 !~ /-2012 /) {
273
+ error(fname, FNR , " copyright is not current" );
274
+ }
275
+ }
276
+ /(static| public| private| protected| final| abstract) / && ! /import / && strict > 1 {
277
+ # Order of qualifiers: "public/private/protected static final abstract class ..."
278
+ s2 = s;
279
+ gsub (/\( . * $ /, " " , s2);
280
+ if (s2 ~ /abstract . * final /) {
281
+ error(fname, FNR , " 'final' must come before 'abstract'" );
282
+ }
283
+ if (s2 ~ /final . * static /) {
284
+ error(fname, FNR , " 'static' must come before 'final'" );
285
+ }
286
+ if (s2 ~ /abstract . * static /) {
287
+ error(fname, FNR , " 'static' must come before 'abstract'" );
288
+ }
289
+ if (s2 ~ /static . * (public| protected| private) /) {
290
+ error(fname, FNR , " 'public/private/protected' must come before 'static'" );
291
+ }
292
+ if (s2 ~ /final . * (public| protected| private) /) {
293
+ error(fname, FNR , " 'public/private/protected' must come before 'final'" );
294
+ }
295
+ if (s2 ~ /abstract . * (public| protected| private) /) {
296
+ error(fname, FNR , " 'public/private/protected' must come before 'abstract'" );
297
+ }
298
+ }
272
299
/^ $ / {
273
300
if (matchFile && previousLineEndedInOpenBrace) {
274
301
error(fname, FNR , " Empty line following open brace" );
@@ -504,7 +531,7 @@ match(s, /([]A-Za-z0-9() ] *)(+|-|\*|\^|\/|%|=|==|+=|-=|\*=|\/=|>=|<=|!=|&|&&|\|
504
531
else if (a[ 2 ] == " &" && isCpp && s ~ /&[^ ] /) {} # ignore case "foo(&x)" in c++
505
532
else if (isCpp && s ~ /\< operator[^ ]+ \( /) {} # ignore e.g. "operator++()" in c++
506
533
else if (isCpp && a[ 2 ] == " /" && s ~ /#include /) {} # ignore e.g. "#include <x/y.hpp>" in c++
507
- else if (lenient && fname ~ /(fennel) / && a[ 1 ] = " ," ) {} # not enabled yet
534
+ else if (strict < 2 && fname ~ /(fennel) / && a[ 1 ] = " ," ) {} # not enabled yet
508
535
else {
509
536
error(fname, FNR , " operator '" a[ 2 ] " ' must be followed by space" );
510
537
}
@@ -518,8 +545,8 @@ match(s, /( )(,)/, a) {
518
545
}
519
546
match (s, / (+ | -| \* | \/ | ==| >=| <=| !=| <<| <<<| >>| &| &&| \|\| | \? | :)$ /, a) || \
520
547
match (s, /(\. | ->)$ /, a) {
521
- if (lenient && fname ~ /(aspen) / && a[ 1 ] != " :" ) {} # not enabled yet
522
- else if (lenient && fname ~ /(fennel| farrago| aspen) / && a[ 1 ] = " +" ) {} # not enabled yet
548
+ if (strict < 2 && fname ~ /(aspen) / && a[ 1 ] != " :" ) {} # not enabled yet
549
+ else if (strict < 2 && fname ~ /(fennel| farrago| aspen) / && a[ 1 ] = " +" ) {} # not enabled yet
523
550
else if (a[ 1 ] == " :" && s ~ /(case. * | default):$ /) {
524
551
# ignore e.g. "case 5:"
525
552
} else if ((a[ 1 ] == " *" || a[ 1 ] == " &" ) && isCpp && s ~ /^ [[:alnum :] :_ ]* [* & ]$ /) {
@@ -623,7 +650,7 @@ s ~ /{/ {
623
650
gsub (/[^ (] /, " " , opens);
624
651
closes = s;
625
652
gsub (/[^ )] /, " " , closes);
626
- if (0 && lenient && fname ~ /aspen /) {} # not enabled
653
+ if (0 && strict < 2 && fname ~ /aspen /) {} # not enabled
627
654
else if (length (closes) > length (opens)) {
628
655
error(fname, FNR , " Open brace should be on new line (function call/decl spans several lines)" );
629
656
}
@@ -694,7 +721,7 @@ length($0) > maxLineLength \
694
721
if (funDeclStartLine < FNR \
695
722
&& $0 !~ /^ * {$ /)
696
723
{
697
- if (lenient && fname ~ /aspen /) {} # not enabled
724
+ if (strict < 2 && fname ~ /aspen /) {} # not enabled
698
725
else error(fname, FNR , " Open brace should be on new line (function decl spans several lines)" );
699
726
}
700
727
funDeclStartLine = 0 ;
0 commit comments