Deleted Added
full compact
xolint.pl (282100) xolint.pl (287111)
1#!/usr/bin/env perl
2#
3# Copyright (c) 2014, Juniper Networks, Inc.
4# All rights reserved.
5# This SOFTWARE is licensed under the LICENSE provided in the
6# ../Copyright file. By downloading, installing, copying, or otherwise
7# using the SOFTWARE, you agree to be bound by the terms of that
8# LICENSE.

--- 296 unchanged lines hidden (view full) ---

305 #@ xo_emit("cost: %d", cost);
306 #@ Should be:
307 #@ xo_emit("{L:cost}: {:cost/%d}", cost);
308 #@ This can be a bit surprising and could be a field that was not
309 #@ properly converted to a libxo-style format string.
310 info("a percent sign appearing in text is a literal") if $text =~ /%/;
311}
312
1#!/usr/bin/env perl
2#
3# Copyright (c) 2014, Juniper Networks, Inc.
4# All rights reserved.
5# This SOFTWARE is licensed under the LICENSE provided in the
6# ../Copyright file. By downloading, installing, copying, or otherwise
7# using the SOFTWARE, you agree to be bound by the terms of that
8# LICENSE.

--- 296 unchanged lines hidden (view full) ---

305 #@ xo_emit("cost: %d", cost);
306 #@ Should be:
307 #@ xo_emit("{L:cost}: {:cost/%d}", cost);
308 #@ This can be a bit surprising and could be a field that was not
309 #@ properly converted to a libxo-style format string.
310 info("a percent sign appearing in text is a literal") if $text =~ /%/;
311}
312
313%short = (
314 # Roles
315 "color" => "C",
316 "decoration" => "D",
317 "error" => "E",
318 "label" => "L",
319 "note" => "N",
320 "padding" => "P",
321 "title" => "T",
322 "units" => "U",
323 "value" => "V",
324 "warning" => "W",
325 "start-anchor" => "[",
326 "stop-anchor" => "]",
327 # Modifiers
328 "colon" => "c",
329 "display" => "d",
330 "encoding" => "e",
331 "hn" => "h",
332 "hn-decimal" => "@",
333 "hn-space" => "@",
334 "hn-1000" => "@",
335 "humanize" => "h",
336 "key" => "k",
337 "leaf-list" => "l",
338 "no-quotes" => "n",
339 "quotes" => "q",
340 "trim" => "t",
341 "white" => "w",
342 );
343
313sub check_field {
314 my(@field) = @_;
315 print "checking field: [" . join("][", @field) . "]\n" if $opt_debug;
316
344sub check_field {
345 my(@field) = @_;
346 print "checking field: [" . join("][", @field) . "]\n" if $opt_debug;
347
348 if ($field[0] =~ /,/) {
349 # We have long names; deal with it by turning them into short names
350 my @parts = split(/,/, $field[0]);
351 my $new = "";
352 for (my $i = 1; $i <= $#parts; $i++) {
353 my $v = $parts[$i];
354 $v =~ s/^\s+//;
355 $v =~ s/\s+$//;
356 if ($short{$v} eq "@") {
357 # ignore; has no short version
358 } elsif ($short{$v}) {
359 $new .= $short{$v};
360 } else {
361 #@ Unknown long name for role/modifier
362 #@ xo_emit("{,humanization:value}", value);
363 #@ Should be:
364 #@ xo_emit("{,humanize:value}", value);
365 #@ The hn-* modifiers (hn-decimal, hn-space, hn-1000)
366 #@ are only valid for fields with the {h:} modifier.
367 error("Unknown long name for role/modifier ($v)");
368 }
369 }
370
371 $field[4] = substr($field[0], index($field[0], ","));
372 $field[0] = $parts[0] . $new;
373 }
374
317 if ($opt_vocabulary) {
318 $vocabulary{$field[1]} = 1
319 if $field[1] && $field[0] !~ /[DELNPTUW\[\]]/;
320 return;
321 }
322
323 #@ Last character before field definition is a field type
324 #@ A common typo:

--- 96 unchanged lines hidden (view full) ---

421 #@ inverse, no-inverse, normal, and reset. Values must
422 #@ be separated by commas.
423 error("Field has invalid color or effect (role: C) ($val)");
424 }
425 }
426 }
427 }
428
375 if ($opt_vocabulary) {
376 $vocabulary{$field[1]} = 1
377 if $field[1] && $field[0] !~ /[DELNPTUW\[\]]/;
378 return;
379 }
380
381 #@ Last character before field definition is a field type
382 #@ A common typo:

--- 96 unchanged lines hidden (view full) ---

479 #@ inverse, no-inverse, normal, and reset. Values must
480 #@ be separated by commas.
481 error("Field has invalid color or effect (role: C) ($val)");
482 }
483 }
484 }
485 }
486
487 # Humanized field
488 if ($field[0] =~ /h/) {
489 if (length($field[2]) == 0) {
490 #@ Field has humanize modifier but no format string
491 #@ xo_emit("{h:value}", value);
492 #@ Should be:
493 #@ xo_emit("{h:value/%d}", value);
494 #@ Humanization is only value for numbers, which are not
495 #@ likely to use the default format ("%s").
496 error("Field has humanize modifier but no format string");
497 }
498 }
499
500 # hn-* on non-humanize field
501 if ($field[0] !~ /h/) {
502 if ($field[4] =~ /,hn-/) {
503 #@ Field has hn-* modifier but not 'h' modifier
504 #@ xo_emit("{,hn-1000:value}", value);
505 #@ Should be:
506 #@ xo_emit("{h,hn-1000:value}", value);
507 #@ The hn-* modifiers (hn-decimal, hn-space, hn-1000)
508 #@ are only valid for fields with the {h:} modifier.
509 error("Field has hn-* modifier but not 'h' modifier");
510 }
511 }
512
429 # A value field
430 if (length($field[0]) == 0 || $field[0] =~ /V/) {
431
432 #@ Value field must have a name (as content)")
433 #@ xo_emit("{:/%s}", "value");
434 #@ Should be:
435 #@ xo_emit("{:tag-name/%s}", "value");
436 #@ The field name is used for XML and JSON encodings. These

--- 179 unchanged lines hidden ---
513 # A value field
514 if (length($field[0]) == 0 || $field[0] =~ /V/) {
515
516 #@ Value field must have a name (as content)")
517 #@ xo_emit("{:/%s}", "value");
518 #@ Should be:
519 #@ xo_emit("{:tag-name/%s}", "value");
520 #@ The field name is used for XML and JSON encodings. These

--- 179 unchanged lines hidden ---