ctf: Fix some Sonar warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core / src / org / eclipse / linuxtools / internal / ctf / core / event / metadata / IOStructGen.java
index 10e9282f9abb3266a227dc464e20a45c52b32faf..79a4fe6c002095e0e609757ec972ff2b1f4c5a6c 100644 (file)
@@ -38,7 +38,6 @@ import org.eclipse.linuxtools.ctf.core.event.types.SequenceDeclaration;
 import org.eclipse.linuxtools.ctf.core.event.types.StringDeclaration;
 import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration;
 import org.eclipse.linuxtools.ctf.core.event.types.VariantDeclaration;
-import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
 import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
 import org.eclipse.linuxtools.ctf.core.trace.Stream;
 import org.eclipse.linuxtools.ctf.parser.CTFParser;
@@ -55,7 +54,7 @@ public class IOStructGen {
     // Attributes
     // ------------------------------------------------------------------------
 
-    static private final boolean DEBUG_ = false;
+    private static final boolean DEBUG = false;
 
     /**
      * The trace
@@ -111,7 +110,7 @@ public class IOStructGen {
         List<CommonTree> children = root.getChildren();
         java.io.FileOutputStream fos = null;
         java.io.OutputStreamWriter out = null;
-        if (DEBUG_) {
+        if (DEBUG) {
             try {
                 fos = new java.io.FileOutputStream("/tmp/astInfo.txt"); //$NON-NLS-1$
                 out = new java.io.OutputStreamWriter(fos, "UTF-8"); //$NON-NLS-1$
@@ -137,7 +136,7 @@ public class IOStructGen {
         try {
             for (CommonTree child : children) {
                 final int type = child.getType();
-                if (DEBUG_) {
+                if (DEBUG) {
                     out.write(child.toString()
                             + " -> " + type + '\n'); //$NON-NLS-1$
                 }
@@ -171,11 +170,11 @@ public class IOStructGen {
                     childTypeError(child);
                 }
             }
-            if (DEBUG_) {
+            if (DEBUG) {
                 out.write("Declarations\n"); //$NON-NLS-1$
             }
             for (CommonTree decl : declarations) {
-                if (DEBUG_) {
+                if (DEBUG) {
                     out.write(decl.toString() + '\n');
                 }
                 parseRootDeclaration(decl);
@@ -186,31 +185,31 @@ public class IOStructGen {
 
             parseTrace(traceNode);
 
-            if (DEBUG_) {
+            if (DEBUG) {
                 out.write("Environments\n"); //$NON-NLS-1$
             }
             for (CommonTree environment : environments) {
                 parseEnvironment(environment);
             }
-            if (DEBUG_) {
+            if (DEBUG) {
                 out.write("Clocks\n"); //$NON-NLS-1$
             }
             for (CommonTree clock : clocks) {
                 parseClock(clock);
             }
-            if (DEBUG_) {
+            if (DEBUG) {
                 out.write("Callsites\n"); //$NON-NLS-1$
             }
             for (CommonTree callsite : callsites) {
                 parseCallsite(callsite);
             }
 
-            if (DEBUG_) {
+            if (DEBUG) {
                 out.write("Streams\n"); //$NON-NLS-1$
             }
             if (streams.size() > 0) {
                 for (CommonTree stream : streams) {
-                    if (DEBUG_) {
+                    if (DEBUG) {
                         try {
                             out.write(stream.toString() + '\n');
                         } catch (IOException e) {
@@ -224,19 +223,19 @@ public class IOStructGen {
                 trace.addStream(new Stream(trace));
             }
 
-            if (DEBUG_) {
+            if (DEBUG) {
                 out.write("Events\n"); //$NON-NLS-1$
             }
             for (CommonTree event : events) {
                 parseEvent(event);
-                if (DEBUG_) {
+                if (DEBUG) {
                     CommonTree name = (CommonTree) event.getChild(0).getChild(1).getChild(0).getChild(0);
                     CommonTree id = (CommonTree) event.getChild(1).getChild(1).getChild(0).getChild(0);
                     out.write("Name = " + name + " Id = " + id + '\n'); //$NON-NLS-1$ //$NON-NLS-2$
                 }
             }
 
-            if (DEBUG_) {
+            if (DEBUG) {
                 out.close();
                 fos.close();
             }
@@ -250,10 +249,10 @@ public class IOStructGen {
 
         List<CommonTree> children = callsite.getChildren();
         String name = null;
-        String func_name = null;
-        long line_number = -1;
+        String funcName = null;
+        long lineNumber = -1;
         long ip = -1;
-        String file_name = null;
+        String fileName = null;
 
         for (CommonTree child : children) {
             String left;
@@ -265,16 +264,16 @@ public class IOStructGen {
             if (left.equals("name")) { //$NON-NLS-1$
                 name = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, nullString);
             } else if (left.equals("func")) { //$NON-NLS-1$
-                func_name = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, nullString);
+                funcName = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, nullString);
             } else if (left.equals("ip")) { //$NON-NLS-1$
-                ip = Long.parseLong(child.getChild(1).getChild(0).getChild(0).getText().substring(2),16); // trim the 0x
+                ip = Long.parseLong(child.getChild(1).getChild(0).getChild(0).getText().substring(2), 16); // trim the 0x
             } else if (left.equals("file")) { //$NON-NLS-1$
-                file_name = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, nullString);
+                fileName = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, nullString);
             } else if (left.equals("line")) { //$NON-NLS-1$
-                line_number = Long.parseLong(child.getChild(1).getChild(0).getChild(0).getText());
+                lineNumber = Long.parseLong(child.getChild(1).getChild(0).getChild(0).getText());
             }
         }
-        trace.addCallsite(name, func_name, ip,file_name, line_number);
+        trace.addCallsite(name, funcName, ip,fileName, lineNumber);
     }
 
     private void parseEnvironment(CommonTree environment) {
@@ -321,8 +320,8 @@ public class IOStructGen {
             }
 
         }
-        String NameValue = ctfClock.getName();
-        trace.addClock(NameValue, ctfClock);
+        String nameValue = ctfClock.getName();
+        trace.addClock(nameValue, ctfClock);
     }
 
     private void parseTrace(CommonTree traceNode) throws ParseException {
@@ -399,7 +398,7 @@ public class IOStructGen {
              * If uuid was already set by a metadata packet, compare it to see
              * if it matches
              */
-            if (trace.UUIDIsSet()) {
+            if (trace.uuidIsSet()) {
                 if (trace.getUUID().compareTo(uuid) != 0) {
                     throw new ParseException("UUID mismatch. Packet says " //$NON-NLS-1$
                             + trace.getUUID() + " but metadata says " + uuid); //$NON-NLS-1$
@@ -880,11 +879,9 @@ public class IOStructGen {
 
         IDeclaration targetDeclaration = parseTypealiasTarget(target);
 
-        if (targetDeclaration instanceof VariantDeclaration) {
-            if (((VariantDeclaration) targetDeclaration).isTagged()) {
-                throw new ParseException(
-                        "Typealias of untagged variant is not permitted"); //$NON-NLS-1$
-            }
+        if ((targetDeclaration instanceof VariantDeclaration)
+                && ((VariantDeclaration) targetDeclaration).isTagged()) {
+            throw new ParseException("Typealias of untagged variant is not permitted"); //$NON-NLS-1$
         }
 
         String aliasString = parseTypealiasAlias(alias);
@@ -1018,7 +1015,6 @@ public class IOStructGen {
                 case CTFParser.IDENTIFIER:
                     throw new ParseException("Identifier (" + child.getText() //$NON-NLS-1$
                             + ") not expected in the typealias target"); //$NON-NLS-1$
-                    /* break; */
                 default:
                     childTypeError(child);
                     break;
@@ -1049,18 +1045,17 @@ public class IOStructGen {
         for (CommonTree typeDeclaratorNode : typeDeclaratorList) {
             StringBuilder identifierSB = new StringBuilder();
 
-            IDeclaration type_declaration = parseTypeDeclarator(
+            IDeclaration typeDeclaration = parseTypeDeclarator(
                     typeDeclaratorNode, typeSpecifierListNode, identifierSB);
 
-            if (type_declaration instanceof VariantDeclaration) {
-                if (((VariantDeclaration) type_declaration).isTagged()) {
-                    throw new ParseException(
-                            "Typealias of untagged variant is not permitted"); //$NON-NLS-1$
-                }
+            if ((typeDeclaration instanceof VariantDeclaration)
+                && ((VariantDeclaration) typeDeclaration).isTagged()) {
+                throw new ParseException(
+                        "Typealias of untagged variant is not permitted"); //$NON-NLS-1$
             }
 
             getCurrentScope().registerType(identifierSB.toString(),
-                    type_declaration);
+                    typeDeclaration);
         }
     }
 
@@ -1694,14 +1689,14 @@ public class IOStructGen {
     /**
      * Parses an enum declaration and returns the corresponding declaration.
      *
-     * @param _enum
+     * @param theEnum
      *            An ENUM node.
      * @return The corresponding enum declaration.
      * @throws ParseException
      */
-    private EnumDeclaration parseEnum(CommonTree _enum) throws ParseException {
+    private EnumDeclaration parseEnum(CommonTree theEnum) throws ParseException {
 
-        List<CommonTree> children = _enum.getChildren();
+        List<CommonTree> children = theEnum.getChildren();
 
         /* The return value */
         EnumDeclaration enumDeclaration = null;
@@ -1720,21 +1715,15 @@ public class IOStructGen {
             switch (child.getType()) {
             case CTFParser.ENUM_NAME: {
                 CommonTree enumNameIdentifier = (CommonTree) child.getChild(0);
-
                 enumName = enumNameIdentifier.getText();
-
                 break;
             }
             case CTFParser.ENUM_BODY: {
-
                 enumBody = child;
-
                 break;
             }
             case CTFParser.ENUM_CONTAINER_TYPE: {
-
                 containerTypeDeclaration = parseEnumContainerType(child);
-
                 break;
             }
             default:
@@ -2232,7 +2221,6 @@ public class IOStructGen {
         case CTFParser.STRING:
             throw new ParseException(
                     "CTF type found in createTypeSpecifierString"); //$NON-NLS-1$
-            /* break; */
         default:
             childTypeError(typeSpecifier);
             break;
@@ -2386,8 +2374,7 @@ public class IOStructGen {
             String uuidstr = parseUnaryString(firstChild);
 
             try {
-                UUID uuid = UUID.fromString(uuidstr);
-                return uuid;
+                return UUID.fromString(uuidstr);
             } catch (IllegalArgumentException e) {
                 throw new ParseException("Invalid format for UUID"); //$NON-NLS-1$
             }
This page took 0.027475 seconds and 5 git commands to generate.