3131 "PMD.TooManyMethods" ,
3232 "PMD.AvoidDuplicateLiterals" ,
3333 "PMD.ExcessivePublicCount" ,
34- "PMD.ExcessiveClassLength " ,
35- "PMD.GodClass "
34+ "PMD.GodClass " ,
35+ "PMD.CouplingBetweenObjects "
3636})
3737final class XeEoListener implements EoListener , Iterable <Directive > {
3838 /**
@@ -102,10 +102,9 @@ public void enterMetas(final EoParser.MetasContext ctx) {
102102 this .dirs .addIf ("metas" );
103103 for (final TerminalNode node : ctx .META ()) {
104104 final String [] pair = node .getText ().split (" " , 2 );
105- final String head = pair [0 ].substring (1 );
106105 this .dirs .add ("meta" )
107106 .attr ("line" , node .getSymbol ().getLine ())
108- .add ("head" ).set (head ).up ()
107+ .add ("head" ).set (pair [ 0 ]. substring ( 1 ) ).up ()
109108 .add ("tail" );
110109 if (pair .length > 1 ) {
111110 this .dirs .set (XeEoListener .qqToGlobalPhi (pair [1 ].trim ())).up ();
@@ -416,7 +415,6 @@ public void exitHapplicationHeadExtended(
416415 }
417416
418417 @ Override
419- @ SuppressWarnings ("PMD.ConfusingTernary" )
420418 public void enterApplicable (final EoParser .ApplicableContext ctx ) {
421419 this .objects .start (ctx );
422420 final String base ;
@@ -539,6 +537,7 @@ public void enterCompactTuple(final EoParser.CompactTupleContext ctx) {
539537 }
540538
541539 @ Override
540+ @ SuppressWarnings ("PMD.UseStringIsEmptyRule" )
542541 public void exitCompactTuple (final EoParser .CompactTupleContext ctx ) {
543542 final int count ;
544543 if (ctx .INT () != null ) {
@@ -807,7 +806,6 @@ public void exitMethodTail(final EoParser.MethodTailContext ctx) {
807806 }
808807
809808 @ Override
810- @ SuppressWarnings ("PMD.ConfusingTernary" )
811809 public void enterBeginner (final EoParser .BeginnerContext ctx ) {
812810 this .objects .start (ctx );
813811 if (ctx .data () == null ) {
@@ -836,7 +834,6 @@ public void exitBeginner(final EoParser.BeginnerContext ctx) {
836834 }
837835
838836 @ Override
839- @ SuppressWarnings ("PMD.ConfusingTernary" )
840837 public void enterFinisher (final EoParser .FinisherContext ctx ) {
841838 this .objects .start (ctx );
842839 final String base ;
@@ -944,7 +941,6 @@ public void exitTarrow(final EoParser.TarrowContext ctx) {
944941 }
945942
946943 @ Override
947- @ SuppressWarnings ("PMD.ConfusingTernary" )
948944 public void enterSuffix (final EoParser .SuffixContext ctx ) {
949945 this .objects .enter ();
950946 if (ctx .PHI () != null ) {
@@ -980,7 +976,6 @@ public void exitScope(final EoParser.ScopeContext ctx) {
980976 }
981977
982978 @ Override
983- @ SuppressWarnings ("PMD.ConfusingTernary" )
984979 public void enterAs (final EoParser .AsContext ctx ) {
985980 this .objects .enter ();
986981 final String has ;
@@ -998,7 +993,6 @@ public void exitAs(final EoParser.AsContext ctx) {
998993 }
999994
1000995 @ Override
1001- @ SuppressWarnings ("PMD.ConfusingTernary" )
1002996 public void enterData (final EoParser .DataContext ctx ) {
1003997 final String text = ctx .getText ();
1004998 if (ctx .BYTES () != null ) {
@@ -1023,7 +1017,7 @@ public void enterData(final EoParser.DataContext ctx) {
10231017 data = new BytesToHex (
10241018 ByteBuffer
10251019 .allocate (Double .BYTES )
1026- .putDouble ((( Long ) Long .parseLong (text .substring (2 ), 16 )). doubleValue ( ))
1020+ .putDouble (Long .parseLong (text .substring (2 ), 16 ))
10271021 .array ()
10281022 );
10291023 } else if (ctx .STRING () != null ) {
@@ -1035,10 +1029,9 @@ public void enterData(final EoParser.DataContext ctx) {
10351029 );
10361030 } else {
10371031 base = "Φ.org.eolang.string" ;
1038- final int indent = ctx .getStart ().getCharPositionInLine ();
10391032 data = new BytesToHex (
10401033 StringEscapeUtils .unescapeJava (
1041- XeEoListener .trimMargin (text , indent )
1034+ XeEoListener .trimMargin (text , ctx . getStart (). getCharPositionInLine () )
10421035 ).getBytes (StandardCharsets .UTF_8 )
10431036 );
10441037 }
@@ -1113,6 +1106,7 @@ private Objects startTest(final ParserRuleContext ctx) {
11131106 * @param comment As they come from the parser
11141107 * @param stop Stop line of the comment
11151108 */
1109+ @ SuppressWarnings ("PMD.UseStringIsEmptyRule" )
11161110 private void putComment (final List <EoParser .CommentContext > comment , final Token stop ) {
11171111 if (!comment .isEmpty ()) {
11181112 this .dirs .push ().xpath ("/object" ).addIf ("comments" ).add ("comment" ).set (
@@ -1161,13 +1155,12 @@ private String alphaAttr(final ParserRuleContext ctx, final String msg) {
11611155 * @return Trimmed text.
11621156 */
11631157 private static String trimMargin (final String text , final int indent ) {
1164- final String rexp = "[\\ s]{%d}" ;
11651158 final String cutted = text
11661159 .substring (3 , text .length () - 3 ).trim ();
11671160 final String [] splitted = cutted .split ("\n " );
11681161 StringBuilder res = new StringBuilder ();
11691162 for (final String line : splitted ) {
1170- res .append (line .replaceAll (String .format (rexp , indent ), "" )).append ('\n' );
1163+ res .append (line .replaceAll (String .format ("[ \\ s]{%d}" , indent ), "" )).append ('\n' );
11711164 }
11721165 if (res .length () > 0 && res .charAt (0 ) == '\n' ) {
11731166 res = new StringBuilder (res .substring (1 ));
0 commit comments