Skip to content

Commit 7754728

Browse files
committed
code review changes pt1, changed Jar vars to jar and converted getclass to instanceof
1 parent 5ceb11f commit 7754728

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/main/java/gr/gousiosg/javacg/stat/JCallGraph.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ public static void main(String[] args) {
140140
List<Pair<String, String>> coverageFilesAndEntryPoints=new ArrayList<>();
141141
for(Pair<String, ?> s : coverageFilesAndEntryPointsShorthand) {
142142
Pair<String,String> result=new Pair<>(s.first,null);
143-
if(s.second.getClass().toString().equals("class java.lang.String")){
143+
if(s.second instanceof String){
144144
entryPoint= (String) s.second;
145145
}
146-
else{
146+
else if(s.second instanceof ArrayList){
147147
try {
148148
Optional<String> returnType = Optional.empty();
149149
if(((ArrayList) s.second).size() > 1)
@@ -242,14 +242,14 @@ public static String generateEntryPoint(String jarPath, String shortName, Option
242242

243243
//Fetch JarEntry of all classes in a Jan using JarInputStream
244244
public static ArrayList<JarEntry> getAllClassesFromJar(JarInputStream JarInputStream) throws IOException {
245-
JarEntry Jar;
245+
JarEntry jar;
246246
ArrayList<JarEntry> listOfAllClasses = new ArrayList<>();
247247
while(true) {
248-
Jar = JarInputStream.getNextJarEntry();
249-
if(Jar == null)
248+
jar = JarInputStream.getNextJarEntry();
249+
if(jar == null)
250250
break;
251-
if((Jar.getName().endsWith(".class")))
252-
listOfAllClasses.add(Jar);
251+
if((jar.getName().endsWith(".class")))
252+
listOfAllClasses.add(jar);
253253
}
254254
return listOfAllClasses;
255255
}
@@ -259,8 +259,8 @@ public static ArrayList<JarEntry> getFilteredClassesFromJar(ArrayList<JarEntry>
259259
listOfAllClasses = listOfAllClasses.stream().filter(e -> e.getName().endsWith(className)).collect(Collectors.toCollection(ArrayList::new));
260260
return listOfAllClasses;
261261
}
262-
public static ArrayList<Pair<String, String>> fetchAllMethodSignaturesForyaml (JarFile JarFile,JarEntry Jar) throws IOException {
263-
ClassParser cp = new ClassParser(JarFile.getInputStream(Jar), Jar.getName());
262+
public static ArrayList<Pair<String, String>> fetchAllMethodSignaturesForyaml (JarFile JarFile,JarEntry jar) throws IOException {
263+
ClassParser cp = new ClassParser(JarFile.getInputStream(jar), jar.getName());
264264
JavaClass jc = cp.parse();
265265

266266
Method[] methods = jc.getMethods();
@@ -273,8 +273,8 @@ public static ArrayList<Pair<String, String>> fetchAllMethodSignaturesForyaml (J
273273
return signatureResults;
274274
}
275275
//Fetch the method signature of a method from a JarEntry
276-
public static String fetchMethodSignatures(JarFile JarFile, JarEntry Jar, String methodName, Optional<String> returnType, Optional<String> paramterTypes) throws IOException {
277-
ClassParser cp = new ClassParser(JarFile.getInputStream(Jar), Jar.getName());
276+
public static String fetchMethodSignatures(JarFile JarFile, JarEntry jar, String methodName, Optional<String> returnType, Optional<String> paramterTypes) throws IOException {
277+
ClassParser cp = new ClassParser(JarFile.getInputStream(jar), jar.getName());
278278
JavaClass jc = cp.parse();
279279

280280
Method[] methods = jc.getMethods();

src/main/java/gr/gousiosg/javacg/stat/support/RepoTool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void cleanTarget() throws IOException, InterruptedException {
129129
public List<Pair<String,?>> obtainCoverageFilesAndEntryPoints(){
130130
List<Pair<String,?>> coverageFiles = new LinkedList<>();
131131
for(Map<String, ?> m : properties){
132-
if(m.get("entryPoint").getClass().toString().equals("class java.lang.String")){
132+
if(m.get("entryPoint") instanceof String){
133133
coverageFiles.add(new Pair<>("artifacts/results/" + getProjectDir() + timeStamp + "/" + m.get("name") + ".xml", m.get("entryPoint")));
134134
}
135135
else{

0 commit comments

Comments
 (0)