@Test public void testFindClassFiles() { File jarFile = getJarFile("src/test/resources/jars/qav-doc-generator.jar"); Map<String, String> parameters = new HashMap<>(); parameters.put("includes", "**/*.class"); final Map<String, Integer> entries = new HashMap<>(); ClassHandler classHandler = (name, content) -> entries.put(name, content.length); JarFileUtil.readJarFile(jarFile, parameters, classHandler); assertThat(entries.size(), is(14)); }
@SuppressWarnings("squid:S1166") public static void readJarFile(File base, Map parameters, ClassHandler classHandler) { checkNotNull(base, "Jar file must be given"); LOGGER.info("Reading JAR file: {}", FileNameUtil.getCanonicalPath(base.getAbsolutePath())); try { readJarFile(new JarFile(base), parameters, classHandler); } catch (IOException e) { LOGGER.error("Error reading jar file: {}: {}", FileNameUtil.getCanonicalPath(base.getAbsolutePath()), e.getMessage()); } }
JarFileUtil { @SuppressWarnings("squid:S1166") public static void readJarFile(File base, Map parameters, ClassHandler classHandler) { checkNotNull(base, "Jar file must be given"); LOGGER.info("Reading JAR file: {}", FileNameUtil.getCanonicalPath(base.getAbsolutePath())); try { readJarFile(new JarFile(base), parameters, classHandler); } catch (IOException e) { LOGGER.error("Error reading jar file: {}: {}", FileNameUtil.getCanonicalPath(base.getAbsolutePath()), e.getMessage()); } } }
JarFileUtil { @SuppressWarnings("squid:S1166") public static void readJarFile(File base, Map parameters, ClassHandler classHandler) { checkNotNull(base, "Jar file must be given"); LOGGER.info("Reading JAR file: {}", FileNameUtil.getCanonicalPath(base.getAbsolutePath())); try { readJarFile(new JarFile(base), parameters, classHandler); } catch (IOException e) { LOGGER.error("Error reading jar file: {}: {}", FileNameUtil.getCanonicalPath(base.getAbsolutePath()), e.getMessage()); } } private  JarFileUtil(); }
JarFileUtil { @SuppressWarnings("squid:S1166") public static void readJarFile(File base, Map parameters, ClassHandler classHandler) { checkNotNull(base, "Jar file must be given"); LOGGER.info("Reading JAR file: {}", FileNameUtil.getCanonicalPath(base.getAbsolutePath())); try { readJarFile(new JarFile(base), parameters, classHandler); } catch (IOException e) { LOGGER.error("Error reading jar file: {}: {}", FileNameUtil.getCanonicalPath(base.getAbsolutePath()), e.getMessage()); } } private  JarFileUtil(); @SuppressWarnings("squid:S1166") // wants log or rethrow exception. It's logged well enough here. static void readJarFile(File base, Map parameters, ClassHandler classHandler); static boolean isJarEntry(String name); }
JarFileUtil { @SuppressWarnings("squid:S1166") public static void readJarFile(File base, Map parameters, ClassHandler classHandler) { checkNotNull(base, "Jar file must be given"); LOGGER.info("Reading JAR file: {}", FileNameUtil.getCanonicalPath(base.getAbsolutePath())); try { readJarFile(new JarFile(base), parameters, classHandler); } catch (IOException e) { LOGGER.error("Error reading jar file: {}: {}", FileNameUtil.getCanonicalPath(base.getAbsolutePath()), e.getMessage()); } } private  JarFileUtil(); @SuppressWarnings("squid:S1166") // wants log or rethrow exception. It's logged well enough here. static void readJarFile(File base, Map parameters, ClassHandler classHandler); static boolean isJarEntry(String name);  }