in reply to Re: Where are the Perl::Critic policies for the Camel?
in thread Where are the Perl::Critic policies for the Camel?
Hm, do you think it's possible to implement any useful set of checks related to Unicode in static code analyzer? Afaik, perlcritic only checks one file, so it's impossible to say where data come from and if this text data or no. It's impossible to say if we have encoding layers for our file handles or no.I agree that static analysis has its limitations. But there are still things that can be done, I think.
These are all wrong, or at least have a code smell to them:
$ unichars -g '/[[:punct:]]/ != /\p{punct}/' U+0024 ‭ $ GC=Sc DOLLAR SIGN U+002B ‭ + GC=Sm PLUS SIGN U+003C ‭ < GC=Sm LESS-THAN SIGN U+003D ‭ = GC=Sm EQUALS SIGN U+003E ‭ > GC=Sm GREATER-THAN SIGN U+005E ‭ ^ GC=Sk CIRCUMFLEX ACCENT U+0060 ‭ ` GC=Sk GRAVE ACCENT U+007C ‭ | GC=Sm VERTICAL LINE U+007E ‭ ~ GC=Sm TILDE
Also, do note that "\r\n" = / \A \R \Z /x is also true, so like \X, \R can be more than one code point in length.$ unichars '/ ^ \R $ /x' U+000A -- GC=Cc LINE FEED (LF) U+000B -- GC=Cc LINE TABULATION U+000C -- GC=Cc FORM FEED (FF) U+000D -- GC=Cc CARRIAGE RETURN (CR) U+0085 -- GC=Cc NEXT LINE (NEL) U+2028 -- GC=Zl LINE SEPARATOR U+2029 -- GC=Zp PARAGRAPH SEPARATOR
Until Karl gets some support for $/ = q(\R) and readline and chomp into a future release, we’re stuck with this ugliness:
which is a big problem because it just doesn’t scale to superbig files or to interactive handles like two-way socket communications. And lord knows what $\ = q(\R) would ever mean for the output record separator. :)@lines = do { local $/; split /\R/, <INPUT> };
I do have an inspiration for a PerlIO::via::Unicode_Linebreak I/O layer to address all this, but haven’t thought it through.
So even though there is a lot that cannot be done about Unicode, there is also a lot that could be done with Unicode.
I really do think there could be some more P::C policies in these areas.chomp
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Where are the Perl::Critic Unicode policies for the Camel?
by vsespb (Chaplain) on Oct 06, 2013 at 19:35 UTC | |
by tchrist (Pilgrim) on Oct 06, 2013 at 21:53 UTC | |
by vsespb (Chaplain) on Oct 06, 2013 at 22:52 UTC |