From 782a4361c2cbf950909deaf4ab3cfe689f27c3cf Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Tue, 26 Mar 2019 20:25:29 +0100 Subject: [PATCH] Fixed warnings --- src/main/java/grafos/GraphViz.java | 12 ++++++------ src/main/java/grafos/Transformador.java | 8 ++++---- src/main/java/grafos/Visitador.java | 20 ++++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/java/grafos/GraphViz.java b/src/main/java/grafos/GraphViz.java index 3b69a2e..e9c1cf5 100644 --- a/src/main/java/grafos/GraphViz.java +++ b/src/main/java/grafos/GraphViz.java @@ -86,7 +86,7 @@ public class GraphViz private final static long serialVersionUID = 1L; { try { load(new FileInputStream(cfgProp)); - } catch (Exception e) {} + } catch (Exception ignored) {} } }; @@ -166,7 +166,7 @@ private static String DOT = configFile.getProperty("dotFor" + osName); * Adds a string to the graph's source (with newline). */ public void addln(String line) { - this.graph.append(line + "\n"); + this.graph.append(line).append("\n"); } /** @@ -189,14 +189,14 @@ private static String DOT = configFile.getProperty("dotFor" + osName); public byte[] getGraph(String dot_source, String type) { File dot; - byte[] img_stream = null; + byte[] img_stream; try { dot = writeDotSourceToFile(dot_source); if (dot != null) { img_stream = get_img_stream(dot, type); - if (dot.delete() == false) + if (!dot.delete()) System.err.println("Warning: " + dot.getAbsolutePath() + " could not be deleted!"); return img_stream; } @@ -258,9 +258,9 @@ private static String DOT = configFile.getProperty("dotFor" + osName); img_stream = new byte[in.available()]; in.read(img_stream); // Close it if we need to - if( in != null ) in.close(); + in.close(); - if (img.delete() == false) + if (!img.delete()) System.err.println("Warning: " + img.getAbsolutePath() + " could not be deleted!"); } catch (java.io.IOException ioe) { diff --git a/src/main/java/grafos/Transformador.java b/src/main/java/grafos/Transformador.java index c7a8631..691bb3f 100644 --- a/src/main/java/grafos/Transformador.java +++ b/src/main/java/grafos/Transformador.java @@ -52,19 +52,19 @@ public class Transformador { // Imprime el grafo en la pantalla private static String imprimirGrafo(List arcos) { - String dotInfo=""; + StringBuilder dotInfo= new StringBuilder(); for(String arco:arcos) { - dotInfo += arco; + dotInfo.append(arco); System.out.println("ARCO: "+arco); } System.out.println("\nCFG:"); System.out.println(dotInfo); - return dotInfo; + return dotInfo.toString(); } // Elimina todos los comentarios de un nodo y sus hijos - static void quitarComentarios(Node node){ + private static void quitarComentarios(Node node){ node.removeComment(); for (Comment comment : node.getOrphanComments()) { diff --git a/src/main/java/grafos/Visitador.java b/src/main/java/grafos/Visitador.java index 0cd4763..cf40d24 100755 --- a/src/main/java/grafos/Visitador.java +++ b/src/main/java/grafos/Visitador.java @@ -11,19 +11,19 @@ import com.github.javaparser.ast.visitor.VoidVisitorAdapter; public class Visitador extends VoidVisitorAdapter> -{ - /********************************************************/ - /********************** Atributos ***********************/ - /********************************************************/ +{ + //********************************************************/ + //********************** Atributos ***********************/ + //********************************************************/ // Usamos un contador para numerar las instrucciones - int contador=1; - String nodoAnterior = "Start"; - String nodoActual = ""; + private int contador=1; + private String nodoAnterior = "Start"; + private String nodoActual = ""; - /********************************************************/ - /*********************** Metodos ************************/ - /********************************************************/ + //********************************************************/ + //*********************** Metodos ************************/ + //********************************************************/ // Visitador de métodos // Este visitador añade el nodo final al CFG